Malloy
Loading...
Searching...
No Matches
Typedefs
malloy::mp Namespace Reference

Namespace for metaprogramming utils. More...

Typedefs

template<typename V >
using unwrap_variant = std::conditional_t< std::variant_size_v< V >==1, std::variant_alternative_t< 0, V >, V >
 Pattern: unwrap_variant<variant<T>> -> T unwrap_variant<variant<T, ...> -> std::variant<T, ...>
 
template<typename V >
using body_type = unwrap_variant< V >
 Converts from a variant of possible bodies to the actual body type taken by callbacks.
 
template<typename F >
using bodies_for_t = std::invoke_result_t< decltype(&F::body_for), const F *, const typename F::header_type & >
 Resolves the body type used by a filter F.
 
template<typename Bodies >
using to_responses = typename decltype(detail::conv_to_resp_helper{std::declval< Bodies >()})::type
 Converts a variant<T...> where T is body to a variant<response<T>...>
 
template<typename Filter >
using filter_resp_t = unwrap_variant< to_responses< bodies_for_t< Filter > > >
 Resolves to the type that must be taken in callbacks handling responses for Filter.
 

Detailed Description

Namespace for metaprogramming utils.

Typedef Documentation

◆ unwrap_variant

template<typename V >
using malloy::mp::unwrap_variant = typedef std::conditional_t<std::variant_size_v<V> == 1, std::variant_alternative_t<0, V>, V>

Pattern: unwrap_variant<variant<T>> -> T unwrap_variant<variant<T, ...> -> std::variant<T, ...>

i.e. If it is a 1 element it just returns that type, otherwise the entire variant type.