Horizon
Namespaces | Classes | Typedefs | Functions | Variables
meta Namespace Reference

Tiny metaprogramming library. More...

Namespaces

 extension
 Extend meta with your own datatypes.
 
 lazy
 Lazy versions of meta actions.
 

Classes

struct  nil_
 An empty type. More...
 
struct  integer_sequence
 A container for a sequence of compile-time integer constants. More...
 
struct  id
 A trait that always returns its argument T. More...
 
struct  defer
 A wrapper that defers the instantiation of a template C with type parameters Ts in a lambda or let expression. More...
 
struct  defer_i
 A wrapper that defers the instantiation of a template C with integral constant parameters Is in a lambda or let expression. More...
 
struct  compose_
 Compose the Invocables Fns in the parameter pack Ts. More...
 
struct  compose_< Fn0 >
 
struct  compose_< Fn0, Fns... >
 
struct  quote
 Turn a template C into an invocable. More...
 
struct  quote_i
 Turn a template C taking literals of type T into a invocable. More...
 
struct  bind_front
 An invocable that partially applies the invocable Fn by binding the arguments Ts to the front of Fn. More...
 
struct  bind_back
 An invocable that partially applies the invocable Fn by binding the arguments Us to the back of Fn. More...
 
struct  flip
 An invocable that reverses the order of the first two arguments. More...
 
struct  and_c
 
struct  or_c
 Logically OR together all the Boolean parameters. More...
 
struct  list
 A list of types. More...
 
struct  var
 For use when defining local variables in meta::let expressions. More...
 

Typedefs

template<META_TYPE_CONSTRAINT(trait) T>
using _t = typename T::type
 Type alias for T::type.
 
template<std::size_t N>
using size_t = std::integral_constant< std::size_t, N >
 An integral constant wrapper for std::size_t.
 
template<bool B>
using bool_ = std::integral_constant< bool, B >
 An integral constant wrapper for bool.
 
template<int I>
using int_ = std::integral_constant< int, I >
 An integral constant wrapper for int.
 
template<char Ch>
using char_ = std::integral_constant< char, Ch >
 An integral constant wrapper for char.
 
template<META_TYPE_CONSTRAINT(integral) T>
using inc = std::integral_constant< decltype(T::type::value+1), T::type::value+1 >
 An integral constant wrapper around the result of incrementing the wrapped integer T::type::value.
 
template<META_TYPE_CONSTRAINT(integral) T>
using dec = std::integral_constant< decltype(T::type::value - 1), T::type::value - 1 >
 An integral constant wrapper around the result of decrementing the wrapped integer T::type::value.
 
template<META_TYPE_CONSTRAINT(integral) T, META_TYPE_CONSTRAINT(integral) U>
using plus = std::integral_constant< decltype(T::type::value+U::type::value), T::type::value+U::type::value >
 An integral constant wrapper around the result of adding the two wrapped integers T::type::value and U::type::value.
 
template<META_TYPE_CONSTRAINT(integral) T, META_TYPE_CONSTRAINT(integral) U>
using minus = std::integral_constant< decltype(T::type::value - U::type::value), T::type::value - U::type::value >
 An integral constant wrapper around the result of subtracting the two wrapped integers T::type::value and U::type::value.
 
template<META_TYPE_CONSTRAINT(integral) T, META_TYPE_CONSTRAINT(integral) U>
using multiplies = std::integral_constant< decltype(T::type::value *U::type::value), T::type::value *U::type::value >
 An integral constant wrapper around the result of multiplying the two wrapped integers T::type::value and U::type::value.
 
template<META_TYPE_CONSTRAINT(integral) T, META_TYPE_CONSTRAINT(integral) U>
using divides = std::integral_constant< decltype(T::type::value/U::type::value), T::type::value/U::type::value >
 An integral constant wrapper around the result of dividing the two wrapped integers T::type::value and U::type::value.
 
template<META_TYPE_CONSTRAINT(integral) T>
using negate = std::integral_constant< decltype(-T::type::value), -T::type::value >
 An integral constant wrapper around the result of negating the wrapped integer T::type::value.
 
template<META_TYPE_CONSTRAINT(integral) T, META_TYPE_CONSTRAINT(integral) U>
using modulus = std::integral_constant< decltype(T::type::value % U::type::value), T::type::value % U::type::value >
 An integral constant wrapper around the remainder of dividing the two wrapped integers T::type::value and U::type::value.
 
template<META_TYPE_CONSTRAINT(integral) T, META_TYPE_CONSTRAINT(integral) U>
using equal_to = bool_< T::type::value==U::type::value >
 A Boolean integral constant wrapper around the result of comparing T::type::value and U::type::value for equality.
 
template<META_TYPE_CONSTRAINT(integral) T, META_TYPE_CONSTRAINT(integral) U>
using not_equal_to = bool_< T::type::value !=U::type::value >
 A Boolean integral constant wrapper around the result of comparing T::type::value and U::type::value for inequality.
 
template<META_TYPE_CONSTRAINT(integral) T, META_TYPE_CONSTRAINT(integral) U>
using greater = bool_<(T::type::value > U::type::value)>
 A Boolean integral constant wrapper around true if T::type::value is greater than U::type::value; false, otherwise.
 
template<META_TYPE_CONSTRAINT(integral) T, META_TYPE_CONSTRAINT(integral) U>
using less = bool_<(T::type::value< U::type::value)>
 A Boolean integral constant wrapper around true if T::type::value is less than U::type::value; false, otherwise.
 
template<META_TYPE_CONSTRAINT(integral) T, META_TYPE_CONSTRAINT(integral) U>
using greater_equal = bool_<(T::type::value >=U::type::value)>
 A Boolean integral constant wrapper around true if T::type::value is greater than or equal to U::type::value; false, otherwise.
 
template<META_TYPE_CONSTRAINT(integral) T, META_TYPE_CONSTRAINT(integral) U>
using less_equal = bool_<(T::type::value<=U::type::value)>
 A Boolean integral constant wrapper around true if T::type::value is less than or equal to U::type::value; false, otherwise.
 
template<META_TYPE_CONSTRAINT(integral) T, META_TYPE_CONSTRAINT(integral) U>
using bit_and = std::integral_constant< decltype(T::type::value &U::type::value), T::type::value &U::type::value >
 An integral constant wrapper around the result of bitwise-and'ing the two wrapped integers T::type::value and U::type::value.
 
template<META_TYPE_CONSTRAINT(integral) T, META_TYPE_CONSTRAINT(integral) U>
using bit_or = std::integral_constant< decltype(T::type::value|U::type::value), T::type::value|U::type::value >
 An integral constant wrapper around the result of bitwise-or'ing the two wrapped integers T::type::value and U::type::value.
 
template<META_TYPE_CONSTRAINT(integral) T, META_TYPE_CONSTRAINT(integral) U>
using bit_xor = std::integral_constant< decltype(T::type::value ^ U::type::value), T::type::value ^ U::type::value >
 An integral constant wrapper around the result of bitwise-exclusive-or'ing the two wrapped integers T::type::value and U::type::value.
 
template<META_TYPE_CONSTRAINT(integral) T>
using bit_not = std::integral_constant< decltype(~T::type::value), ~T::type::value >
 An integral constant wrapper around the result of bitwise-complementing the wrapped integer T::type::value.
 
template<std::size_t... Is>
using index_sequence = integer_sequence< std::size_t, Is... >
 A container for a sequence of compile-time integer constants of type std::size_t.
 
template<std::size_t N>
using make_index_sequence = _t< detail::make_indices_< N, index_sequence< 0 >, detail::strategy_(1, N)> >
 Generate index_sequence containing integer constants [0,1,2,...,N-1]. More...
 
template<typename T , T N>
using make_integer_sequence = _t< detail::coerce_indices_< T, 0, make_index_sequence< static_cast< std::size_t >(N)> >>
 Generate integer_sequence containing integer constants [0,1,2,...,N-1]. More...
 
template<typename T , T From, T To>
using integer_range = _t< detail::coerce_indices_< T, From, make_index_sequence< detail::range_distance_(From, To)> >>
 Makes the integer sequence [From, To). More...
 
template<META_TYPE_CONSTRAINT(invocable) Fn, typename... Args>
using invoke = typename Fn::template invoke< Args... >
 Evaluate the invocable Fn with the arguments Args.
 
template<typename T >
using id_t = _t< id< T > >
 An alias for type T. More...
 
template<typename... >
using void_ = void
 An alias for void.
 
template<typename T >
using is_trait = _t< detail::is_trait_< T > >
 
template<typename T >
using is_callable = _t< detail::is_callable_< T > >
 An alias for std::true_type if T::invoke exists and names a class template or alias template; otherwise, it's an alias for std::false_type.
 
template<template< typename... > class C, typename... Ts>
using defer_trait = defer< detail::_t_t, detail::defer_< C, Ts... > >
 A wrapper that defers the instantiation of a trait C with type parameters Ts in a lambda or let expression. More...
 
template<typename T , template< T... > class C, T... Is>
using defer_trait_i = defer< detail::_t_t, detail::defer_i_< T, C, Is... > >
 A wrapper that defers the instantiation of a trait C with integral constant parameters Is in a lambda or let expression. More...
 
template<typename T >
using sizeof_ = meta::size_t< sizeof(T)>
 An alias that computes the size of the type T. More...
 
template<typename T >
using alignof_ = meta::size_t< alignof(T)>
 An alias that computes the alignment required for any instance of the type T. More...
 
template<typename T , template< typename... > class C>
using is = _t< detail::is_< T, C > >
 is More...
 
template<typename... Fns>
using compose = compose_< Fns... >
 
template<template< typename... > class C>
using quote_trait = compose< quote< _t >, quote< C > >
 Turn a trait template C into an invocable. More...
 
template<typename T , template< T... > class C>
using quote_trait_i = compose< quote< _t >, quote_i< T, C > >
 Turn a trait template C taking literals of type T into an invocable.
 
template<META_TYPE_CONSTRAINT(invocable) Fn, typename L >
using apply = _t< extension::apply< Fn, L > >
 Applies the invocable Fn using the types in the type list L as arguments.
 
template<META_TYPE_CONSTRAINT(invocable) Fn, META_TYPE_CONSTRAINT(invocable) Q = quote<list>>
using curry = compose< Fn, Q >
 An invocable that takes a bunch of arguments, bundles them into a type list, and then calls the invocable Fn with the type list Q.
 
template<META_TYPE_CONSTRAINT(invocable) Fn>
using uncurry = bind_front< quote< apply >, Fn >
 An invocable that takes a type list, unpacks the types, and then calls the invocable Fn with the types.
 
template<META_TYPE_CONSTRAINT(invocable)... Fns>
using on_ = detail::on_< Fns... >
 Use as on<Fn, Gs...>. More...
 
template<typename... Fns>
using on = on_< Fns... >
 
template<bool If, typename Then , typename Else = void>
using conditional_t = typename detail::_cond< If >::template invoke< Then, Else >
 Select one type or another depending on a compile-time Boolean.
 
template<typename... Args>
using if_ = _t< detail::_if_< list< Args... > >>
 Select one type or another depending on a compile-time Boolean.
 
template<bool If, typename... Args>
using if_c = _t< detail::_if_< list< bool_< If >, Args... > >>
 
template<bool B>
using not_c = bool_<!B >
 Logically negate the Boolean parameter.
 
template<META_TYPE_CONSTRAINT(integral) B>
using not_ = not_c< B::type::value >
 Logically negate the integral constant-wrapped Boolean parameter.
 
template<META_TYPE_CONSTRAINT(integral)... Bs>
using strict_and_ = and_c< Bs::type::value... >
 Logically AND together all the integral constant-wrapped Boolean parameters, without short-circuiting.
 
template<typename... Bs>
using strict_and = strict_and_< Bs... >
 
template<typename... Bs>
using and_ = _t< defer< detail::_and_< 0==sizeof...(Bs)>::template invoke, Bs... > >
 Logically AND together all the integral constant-wrapped Boolean parameters, with short-circuiting.
 
template<META_TYPE_CONSTRAINT(integral)... Bs>
using strict_or_ = or_c< Bs::type::value... >
 Logically OR together all the integral constant-wrapped Boolean parameters, without short-circuiting.
 
template<typename... Bs>
using strict_or = strict_or_< Bs... >
 
template<typename... Bs>
using or_ = _t< defer< detail::_or_< 0==sizeof...(Bs)>::template invoke, Bs... > >
 Logically OR together all the integral constant-wrapped Boolean parameters, with short-circuiting.
 
template<META_TYPE_CONSTRAINT(list_like) L, typename State , META_TYPE_CONSTRAINT(invocable) Fn>
using fold = _t< detail::fold_< L, id< State >, Fn > >
 Return a new meta::list constructed by doing a left fold of the list L using binary invocable Fn and initial state State. More...
 
template<META_TYPE_CONSTRAINT(list_like) L, typename State , META_TYPE_CONSTRAINT(invocable) Fn>
using accumulate = fold< L, State, Fn >
 An alias for meta::fold. More...
 
template<META_TYPE_CONSTRAINT(list_like) L, typename State , META_TYPE_CONSTRAINT(invocable) Fn>
using reverse_fold = _t< detail::reverse_fold_< L, State, Fn > >
 Return a new meta::list constructed by doing a right fold of the list L using binary invocable Fn and initial state State. More...
 
using npos = meta::size_t< std::size_t(-1)>
 A special value used to indicate no matches. More...
 
template<META_TYPE_CONSTRAINT(list_like) L>
using size = meta::size_t< L::size()>
 An integral constant wrapper that is the size of the meta::list L.
 
template<META_TYPE_CONSTRAINT(list_like)... Ls>
using concat_ = _t< detail::concat_< Ls... > >
 Concatenates several lists into a single list. More...
 
template<typename... Lists>
using concat = concat_< Lists... >
 
template<META_TYPE_CONSTRAINT(list_like) ListOfLists>
using join = apply< quote< concat >, ListOfLists >
 Joins a list of lists into a single list. More...
 
template<typename... Args>
using transform = _t< detail::transform_< list< Args... > >>
 Return a new meta::list constructed by transforming all the elements in L with the unary invocable Fn. More...
 
template<std::size_t N, typename T = void>
using repeat_n_c = _t< detail::repeat_n_c_< T, make_index_sequence< N > >>
 Generate list<T,T,T...T> of size N arguments. More...
 
template<META_TYPE_CONSTRAINT(integral) N, typename T = void>
using repeat_n = repeat_n_c< N::type::value, T >
 Generate list<T,T,T...T> of size N arguments. More...
 
template<META_TYPE_CONSTRAINT(list_like) L, std::size_t N>
using at_c = _t< detail::at_< L, N > >
 Return the N th element in the meta::list L. More...
 
template<META_TYPE_CONSTRAINT(list_like) L, META_TYPE_CONSTRAINT(integral) N>
using at = at_c< L, N::type::value >
 Return the N th element in the meta::list L. More...
 
template<META_TYPE_CONSTRAINT(list_like) L, std::size_t N>
using drop_c = _t< detail::drop_< L, N > >
 Return a new meta::list by removing the first N elements from L. More...
 
template<META_TYPE_CONSTRAINT(list_like) L, META_TYPE_CONSTRAINT(integral) N>
using drop = drop_c< L, N::type::value >
 Return a new meta::list by removing the first N elements from L. More...
 
template<META_TYPE_CONSTRAINT(list_like) L>
using front = _t< detail::front_< L > >
 Return the first element in meta::list L. More...
 
template<META_TYPE_CONSTRAINT(list_like) L>
using back = _t< detail::back_< L > >
 Return the last element in meta::list L. More...
 
template<META_TYPE_CONSTRAINT(list_like) L, typename... Ts>
using push_front = apply< bind_front< quote< list >, Ts... >, L >
 Return a new meta::list by adding the element T to the front of L. More...
 
template<META_TYPE_CONSTRAINT(list_like) L>
using pop_front = _t< detail::pop_front_< L > >
 Return a new meta::list by removing the first element from the front of L. More...
 
template<META_TYPE_CONSTRAINT(list_like) L, typename... Ts>
using push_back = apply< bind_back< quote< list >, Ts... >, L >
 Return a new meta::list by adding the element T to the back of L. More...
 
template<META_TYPE_CONSTRAINT(integral)... Ts>
using min_ = fold< pop_front< list< Ts... > >, front< list< Ts... > >, quote< detail::min_ > >
 An integral constant wrapper around the minimum of Ts::type::value...
 
template<typename... Ts>
using min = min_< Ts... >
 
template<META_TYPE_CONSTRAINT(integral)... Ts>
using max_ = fold< pop_front< list< Ts... > >, front< list< Ts... > >, quote< detail::max_ > >
 An integral constant wrapper around the maximum of Ts::type::value...
 
template<typename... Ts>
using max = max_< Ts... >
 
template<META_TYPE_CONSTRAINT(list_like) L>
using empty = bool_< 0==size< L >::type::value >
 An Boolean integral constant wrapper around true if L is an empty type list; false, otherwise. More...
 
template<typename F , typename S >
using pair = list< F, S >
 A list with exactly two elements.
 
template<typename Pair >
using first = front< Pair >
 Retrieve the first element of the pair Pair.
 
template<typename Pair >
using second = front< pop_front< Pair > >
 Retrieve the first element of the pair Pair.
 
template<META_TYPE_CONSTRAINT(list_like) L, typename T >
using find_index = _t< detail::find_index_< L, T > >
 Finds the index of the first occurrence of the type T within the list L. More...
 
template<META_TYPE_CONSTRAINT(list_like) L, typename T >
using reverse_find_index = _t< detail::reverse_find_index_< L, T > >
 Finds the index of the last occurrence of the type T within the list L. More...
 
template<META_TYPE_CONSTRAINT(list_like) L, typename T >
using find = drop< L, min< find_index< L, T >, size< L > >>
 Return the tail of the list L starting at the first occurrence of T, if any such element exists; the empty list, otherwise. More...
 
template<META_TYPE_CONSTRAINT(list_like) L, typename T >
using reverse_find = drop< L, min< reverse_find_index< L, T >, size< L > >>
 Return the tail of the list L starting at the last occurrence of T, if any such element exists; the empty list, otherwise. More...
 
template<META_TYPE_CONSTRAINT(list_like) L, META_TYPE_CONSTRAINT(invocable) Fn>
using find_if = _t< detail::find_if_< L, Fn > >
 Return the tail of the list L starting at the first element A such that invoke<Fn, A>::value is true, if any such element exists; the empty list, otherwise. More...
 
template<META_TYPE_CONSTRAINT(list_like) L, META_TYPE_CONSTRAINT(invocable) Fn>
using reverse_find_if = _t< detail::reverse_find_if_< L, Fn > >
 Return the tail of the list L starting at the last element A such that invoke<Fn, A>::value is true, if any such element exists; the empty list, otherwise. More...
 
template<META_TYPE_CONSTRAINT(list_like) L, typename T , typename U >
using replace = _t< detail::replace_< L, T, U > >
 Return a new meta::list where all instances of type T have been replaced with U. More...
 
template<META_TYPE_CONSTRAINT(list_like) L, typename C , typename U >
using replace_if = _t< detail::replace_if_< L, C, U > >
 Return a new meta::list where all elements A of the list L for which invoke<C,A>::value is true have been replaced with U. More...
 
template<META_TYPE_CONSTRAINT(list_like) L, typename T >
using count = _t< detail::count_< L, T > >
 Count the number of times a type T appears in the list L. More...
 
template<META_TYPE_CONSTRAINT(list_like) L, META_TYPE_CONSTRAINT(invocable) Fn>
using count_if = _t< detail::count_if_< L, Fn > >
 Count the number of times the predicate Fn evaluates to true for all the elements in the list L. More...
 
template<typename L , typename Pred >
using filter = join< transform< L, detail::filter_< Pred > >>
 Returns a new meta::list where only those elements of L that satisfy the Callable Pred such that invoke<Pred,A>::value is true are present. More...
 
template<META_TYPE_CONSTRAINT(list_like) ListOfLists>
using transpose = fold< ListOfLists, repeat_n< size< front< ListOfLists > >, list<> >, bind_back< quote< transform >, quote< push_back > >>
 Given a list of lists of types ListOfLists, transpose the elements from the lists. More...
 
template<META_TYPE_CONSTRAINT(invocable) Fn, META_TYPE_CONSTRAINT(list_like) ListOfLists>
using zip_with = transform< transpose< ListOfLists >, uncurry< Fn > >
 Given a list of lists of types ListOfLists and an invocable Fn, construct a new list by calling Fn with the elements from the lists pairwise. More...
 
template<META_TYPE_CONSTRAINT(list_like) ListOfLists>
using zip = transpose< ListOfLists >
 Given a list of lists of types ListOfLists, construct a new list by grouping the elements from the lists pairwise into meta::lists. More...
 
template<typename Sequence >
using as_list = _t< detail::as_list_< detail::uncvref_t< Sequence > >>
 Turn a type into an instance of meta::list in a way determined by meta::apply.
 
template<META_TYPE_CONSTRAINT(list_like) L>
using reverse = _t< detail::reverse_< L > >
 Return a new meta::list by reversing the elements in the list L. More...
 
template<META_TYPE_CONSTRAINT(invocable) Fn>
using not_fn = compose< quote< not_ >, Fn >
 Logically negate the result of invocable Fn.
 
template<META_TYPE_CONSTRAINT(list_like) L, META_TYPE_CONSTRAINT(invocable) Fn>
using all_of = empty< find_if< L, not_fn< Fn > >>
 A Boolean integral constant wrapper around true if invoke<Fn, A>::value is true for all elements A in meta::list L; false, otherwise. More...
 
template<META_TYPE_CONSTRAINT(list_like) L, META_TYPE_CONSTRAINT(invocable) Fn>
using any_of = not_< empty< find_if< L, Fn > >>
 A Boolean integral constant wrapper around true if invoke<Fn, A>::value is true for any element A in meta::list L; false, otherwise. More...
 
template<META_TYPE_CONSTRAINT(list_like) L, META_TYPE_CONSTRAINT(invocable) Fn>
using none_of = empty< find_if< L, Fn > >
 A Boolean integral constant wrapper around true if invoke<Fn, A>::value is false for all elements A in meta::list L; false, otherwise. More...
 
template<META_TYPE_CONSTRAINT(list_like) L, typename T >
using in = not_< empty< find< L, T > >>
 A Boolean integral constant wrapper around true if there is at least one occurrence of T in L. More...
 
template<META_TYPE_CONSTRAINT(list_like) L>
using inherit = meta::_t< detail::inherit_< L > >
 A type that inherits from all the types in the list. More...
 
template<META_TYPE_CONSTRAINT(list_like) L>
using unique = fold< L, list<>, quote_trait< detail::insert_back_ > >
 Return a new meta::list where all duplicate elements have been removed. More...
 
template<META_TYPE_CONSTRAINT(list_like) L, META_TYPE_CONSTRAINT(invocable) Fn>
using partition = fold< L, pair< list<>, list<> >, detail::partition_< Fn > >
 Returns a pair of lists, where the elements of L that satisfy the invocable Fn such that invoke<Fn,A>::value is true are present in the first list and the rest are in the second. More...
 
template<META_TYPE_CONSTRAINT(list_like) L, META_TYPE_CONSTRAINT(invocable) Fn>
using sort = _t< detail::sort_< L, Fn > >
 Return a new meta::list that is sorted according to invocable predicate Fn. More...
 
template<typename... Ts>
using lambda = if_c<(sizeof...(Ts) > 0), detail::lambda_< list< Ts... > >>
 For creating anonymous Invocables. More...
 
template<typename T >
using is_valid = detail::is_valid_< T >
 For testing whether a deferred computation will succeed in a let or a lambda.
 
template<typename T >
using vararg = detail::vararg_< T >
 For defining variadic placeholders.
 
template<typename T >
using protect = detail::protect_< T >
 For preventing the evaluation of a nested defered computation in a let or lambda expression.
 
template<typename... As>
using let = _t< _t< detail::let_< As... > >>
 A lexically scoped expression with local variables. More...
 
using _args = vararg< void >
 
using _args_a = vararg< _a >
 
using _args_b = vararg< _b >
 
using _args_c = vararg< _c >
 
template<META_TYPE_CONSTRAINT(list_like) ListOfLists>
using cartesian_product = reverse_fold< ListOfLists, list< list<> >, quote_trait< detail::cartesian_product_fn > >
 Given a list of lists ListOfLists, return a new list of lists that is the Cartesian Product. More...
 

Functions

template<char... Chs>
constexpr fold< list< char_< Chs >... >, meta::size_t< 0 >, quote< detail::atoi_ > > operator""_z ()
 A user-defined literal that generates objects of type meta::size_t.
 

Variables

constexpr auto && for_each = detail::static_const<detail::for_each_fn>::value
 for_each(List, UnaryFunction) calls the UnaryFunction for each argument in the List.
 

Detailed Description

Tiny metaprogramming library.