Meta  0.1
A tiny metaprogramming library
meta Namespace Reference

Tiny metaprogramming library. More...

Namespaces

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

Classes

struct  bind_back
 A Callable that partially applies the Callable F by binding the arguments Us to the back of F. More...
 
struct  bind_front
 A Callable that partially applies the Callable F by binding the arguments Ts to the front of F. More...
 
struct  compose
 Compose the Callables Fs in the parameter pack Ts. 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  flip
 A Callable that reverses the order of the first two arguments. More...
 
struct  id
 A trait that always returns its argument T. Also, a Callable that always returns T. More...
 
struct  integer_sequence
 A container for a sequence of compile-time integer constants. More...
 
struct  list
 A list of types. More...
 
struct  nil_
 An empty type. More...
 
struct  quote
 Turn a class template or alias template C into a Callable. More...
 
struct  quote_i
 Turn a class template or alias template C taking literals of type T into a Callable. More...
 
struct  var
 For use when defining local variables in meta::let expressions. More...
 

Typedefs

template<typename T >
using _t = typename T::type
 Type alias for T::type.
 
template<typename List , typename State , typename Fun >
using accumulate = fold< List, State, Fun >
 An alias for meta::fold. More...
 
template<class 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 List , typename F >
using all_of = empty< find_if< List, not_fn< F >>>
 A Boolean integral constant wrapper around true if invoke<F, A>::value is true for all elements A in meta::list List; false, otherwise. More...
 
template<typename... Bools>
using and_ = _t< detail::_and_< Bools... >>
 Logically and together all the integral constant-wrapped Boolean parameters, with short-circuiting.
 
template<bool... Bools>
using and_c = std::is_same< integer_sequence< bool, Bools... >, integer_sequence< bool,(Bools||true)... >>
 Logically and together all the Boolean parameters.
 
template<typename List , typename F >
using any_of = not_< empty< find_if< List, F >>>
 A Boolean integral constant wrapper around true if invoke<F, A>::value is true for any element A in meta::list List; false, otherwise. More...
 
template<typename C , typename List >
using apply = _t< extension::apply< C, List >>
 Applies the Callable C using the types in the type list List as arguments.
 
template<typename Sequence >
using as_list = _t< detail::as_list_< Sequence >>
 Turn a type into an instance of meta::list in a way determined by meta::invoke.
 
template<typename List , typename N >
using at = _t< detail::at_< List, N >>
 Return the N th element in the meta::list List. More...
 
template<typename List , std::size_t N>
using at_c = at< List, meta::size_t< N >>
 Return the N th element in the meta::list List. More...
 
template<typename List >
using back = _t< detail::back_< List >>
 Return the last element in meta::list List. More...
 
template<typename T , typename 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<typename 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<typename T , typename 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<typename T , typename 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<bool B>
using bool_ = std::integral_constant< bool, B >
 An integral constant wrapper for bool.
 
template<typename 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. Like the sequence function from the Haskell Prelude. More...
 
template<char Ch>
using char_ = std::integral_constant< char, Ch >
 An integral constant wrapper for char.
 
template<typename... Lists>
using concat = _t< detail::concat_< Lists... >>
 Concatenates several lists into a single list. More...
 
template<typename List , typename T >
using count = fold< List, meta::size_t< 0 >, bind_back< quote< detail::count_fn >, T >>
 Count the number of times a type T appears in the list List. More...
 
template<typename List , typename Fn >
using count_if = fold< List, meta::size_t< 0 >, bind_back< quote< detail::count_if_fn >, Fn >>
 Count the number of times the predicate Fn evaluates to true for all the elements in the list List. More...
 
template<typename F , typename Q = quote<list>>
using curry = compose< F, Q >
 A Callable that takes a bunch of arguments, bundles them into a type list, and then calls the Callable F with the type list Q.
 
template<typename 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<template< typename... > class C, typename... Ts>
using defer_trait = lazy::_t< 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 = lazy::_t< 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 , typename 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<typename List , typename N >
using drop = _t< detail::drop_< List, N >>
 Return a new meta::list by removing the first N elements from List. More...
 
template<typename List , std::size_t N>
using drop_c = _t< detail::drop_< List, meta::size_t< N >>>
 Return a new meta::list by removing the first N elements from List. More...
 
template<typename List >
using empty = bool_< 0==size< List >::type::value >
 An Boolean integral constant wrapper around true if List is an empty type list; false, otherwise. More...
 
template<typename T , typename 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<typename List , typename Pred >
using filter = fold< List, list<>, detail::filter_< Pred >>
 Returns a new meta::list where only those elements of List that satisfy the Callable Pred such that invoke<Pred,A>::value is true are present. That is, those elements that don't satisfy the Pred are "removed". More...
 
template<typename List , typename T >
using find = drop< List, min< find_index< List, T >, size< List >>>
 Return the tail of the list List starting at the first occurrence of T, if any such element exists; the empty list, otherwise. More...
 
template<typename List , typename Fun >
using find_if = _t< detail::find_if_< List, Fun >>
 Return the tail of the list List starting at the first element A such that invoke<Fun, A>::value is true, if any such element exists; the empty list, otherwise. More...
 
template<typename List , typename T >
using find_index = _t< detail::find_index_< List, T >>
 Finds the index of the first occurrence of the type T within the list List. Returns meta::npos if the type T was not found. More...
 
template<typename Pair >
using first = front< Pair >
 Retrieve the first element of the pair Pair.
 
template<typename List , typename State , typename Fun >
using fold = _t< detail::fold_< List, State, Fun >>
 Return a new meta::list constructed by doing a left fold of the list List using binary Callable Fun and initial state State. That is, the State_N for the list element A_N is computed by Fun(State_N-1, A_N) -> State_N. More...
 
template<typename List >
using front = _t< detail::front_< List >>
 Return the first element in meta::list List. More...
 
template<typename T , typename 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<typename T , typename 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<typename T >
using id_t = _t< id< T >>
 An alias for type T. Useful in non-deduced contexts.
 
template<typename... Args>
using if_ = _t< detail::_if_< Args... >>
 Select one type or another depending on a compile-time Boolean.
 
template<bool If, typename... Args>
using if_c = _t< detail::_if_< bool_< If >, Args... >>
 Select one type or another depending on a compile-time Boolean.
 
template<typename List , typename T >
using in = not_< empty< find< List, T >>>
 A Boolean integral constant wrapper around true if there is at least one occurrence of T in List. More...
 
template<typename 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<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<typename List >
using inherit = meta::_t< detail::inherit_< List >>
 A type that inherits from all the types in the list. More...
 
template<int I>
using int_ = std::integral_constant< int, I >
 An integral constant wrapper for int.
 
template<class T , T from, T to>
using integer_range = meta::_t< detail::offset_integer_sequence_< T, from, meta::make_integer_sequence< T, to-from >>>
 Makes the integer sequence [from, to).
 
template<typename F , typename... Args>
using invoke = typename F::template invoke< Args... >
 Evaluate the Callable F with the arguments Args.
 
template<typename T , template< typename... > class C>
using is = _t< detail::is_< T, C >>
 is More...
 
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<typename T >
using is_trait = _t< detail::is_trait_< T >>
 An alias for std::true_type if T::type exists and names a type; otherwise, it's an alias for std::false_type.
 
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 ListOfLists >
using join = apply< quote< concat >, ListOfLists >
 Joins a list of lists into a single list. More...
 
template<typename... Ts>
using lambda = if_c<(sizeof...(Ts) > 0), detail::lambda_< list< Ts... >>>
 For creating anonymous Callables. More...
 
template<typename T , typename 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<typename T , typename 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<typename... As>
using let = _t< _t< detail::let_< As... >>>
 A lexically scoped expression with local variables. More...
 
template<std::size_t N>
using make_index_sequence = make_integer_sequence< std::size_t, N >
 Generate index_sequence containing integer constants [0,1,2,...,N-1]. More...
 
template<typename T , T N>
using make_integer_sequence = _t< detail::make_integer_sequence_< T,(std::size_t) N >>
 Generate integer_sequence containing integer constants [0,1,2,...,N-1]. More...
 
template<typename... 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 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 T , typename 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<typename T , typename 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<typename T , typename 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<typename 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<typename List , typename F >
using none_of = empty< find_if< List, F >>
 A Boolean integral constant wrapper around true if invoke<F, A>::value is false for all elements A in meta::list List; false, otherwise. More...
 
template<typename Bool >
using not_ = not_c< Bool::type::value >
 Logically negate the integral constant-wrapped Boolean parameter.
 
template<bool Bool>
using not_c = bool_<!Bool >
 Logically negate the Boolean parameter.
 
template<typename T , typename 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<typename F >
using not_fn = compose< quote< not_ >, F >
 Logically negate the result of Callable F.
 
using npos = meta::size_t< std::size_t(-1)>
 A special value used to indicate no matches. It equals the maximum value representable by std::size_t.
 
template<typename... Fs>
using on = detail::on_< Fs... >
 Use as on<F, Gs...>. Creates an Callable that applies Callable F to the result of applying Callable compose<Gs...> to all the arguments.
 
template<typename... Bools>
using or_ = _t< detail::_or_< Bools... >>
 Logically or together all the integral constant-wrapped Boolean parameters, with short-circuiting.
 
template<bool... Bools>
using or_c = not_< std::is_same< integer_sequence< bool, Bools... >, integer_sequence< bool,(Bools &&false)... >>>
 Logically or together all the Boolean parameters.
 
template<typename F , typename S >
using pair = list< F, S >
 A list with exactly two elements.
 
template<typename List , typename Pred >
using partition = fold< List, pair< list<>, list<>>, detail::partition_< Pred >>
 Returns a pair of lists, where the elements of List that satisfy the Callable Pred such that invoke<Pred,A>::value is true are present in the first list and the rest are in the second. More...
 
template<typename T , typename 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<typename List >
using pop_front = _t< detail::pop_front_< List >>
 Return a new meta::list by removing the first element from the front of List. More...
 
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 List , typename T >
using push_back = _t< detail::push_back_< List, T >>
 Return a new meta::list by adding the element T to the back of List. More...
 
template<typename List , typename T >
using push_front = _t< detail::push_front_< List, T >>
 Return a new meta::list by adding the element T to the front of List. More...
 
template<template< typename... > class C>
using quote_trait = compose< quote< _t >, quote< C >>
 Turn a trait template C into a Callable. More...
 
template<typename T , template< T... > class C>
using quote_trait_i = compose< quote< _t >, quote_i< T, C >>
 Turn a trait C taking literals of type T into a Callable. More...
 
template<typename N , typename T = void>
using repeat_n = _t< detail::repeat_n_c_< N::type::value, T >>
 Generate list<T,T,T...T> of size N arguments. More...
 
template<std::size_t N, typename T = void>
using repeat_n_c = _t< detail::repeat_n_c_< N, T >>
 Generate list<T,T,T...T> of size N arguments. More...
 
template<typename List , typename T , typename U >
using replace = _t< detail::replace_< List, T, U >>
 Return a new meta::list where all instances of type T have been replaced with U. More...
 
template<typename List , typename C , typename U >
using replace_if = _t< detail::replace_if_< List, C, U >>
 Return a new meta::list where all elements A of the list List for which invoke<C,A>::value is true have been replaced with U. More...
 
template<typename List >
using reverse = reverse_fold< List, list<>, quote< push_back >>
 Return a new meta::list by reversing the elements in the list List. More...
 
template<typename List , typename T >
using reverse_find = drop< List, min< reverse_find_index< List, T >, size< List >>>
 Return the tail of the list List starting at the last occurrence of T, if any such element exists; the empty list, otherwise. More...
 
template<typename List , typename Fun >
using reverse_find_if = _t< detail::reverse_find_if_< List, Fun >>
 Return the tail of the list List starting at the last element A such that invoke<Fun, A>::value is true, if any such element exists; the empty list, otherwise. More...
 
template<typename List , typename T >
using reverse_find_index = _t< detail::reverse_find_index_< List, T >>
 Finds the index of the last occurrence of the type T within the list List. Returns meta::npos if the type T was not found. More...
 
template<typename List , typename State , typename Fun >
using reverse_fold = _t< detail::reverse_fold_< List, State, Fun >>
 Return a new meta::list constructed by doing a right fold of the list List using binary Callable Fun and initial state State. That is, the State_N for the list element A_N is computed by Fun(A_N, State_N+1) -> State_N. More...
 
template<typename Pair >
using second = front< pop_front< Pair >>
 Retrieve the first element of the pair Pair.
 
template<typename List >
using size = meta::size_t< List::size()>
 An integral constant wrapper that is the size of the meta::list List.
 
template<std::size_t N>
using size_t = std::integral_constant< std::size_t, N >
 An integral constant wrapper for std::size_t.
 
template<class T >
using sizeof_ = meta::size_t< sizeof(T)>
 An alias that computes the size of the type T. More...
 
template<typename List , typename Pred >
using sort = _t< detail::sort_< List, Pred >>
 Return a new meta::list that is sorted according to Callable predicate Pred. More...
 
template<typename... Bools>
using strict_and = and_c< Bools::type::value... >
 Logically and together all the integral constant-wrapped Boolean parameters, without doing short-circuiting.
 
template<typename... Bools>
using strict_or = or_c< Bools::type::value... >
 Logically or together all the integral constant-wrapped Boolean parameters, without doing short-circuiting.
 
template<typename... Args>
using transform = _t< detail::transform_< list< Args... >>>
 Return a new meta::list constructed by transforming all the elements in List with the unary Callable Fun. transform can also be called with two lists of the same length and a binary Callable, in which case it returns a new list constructed with the results of calling Fun with each element in the lists, pairwise. More...
 
template<typename 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<typename F >
using uncurry = bind_front< quote< apply >, F >
 A Callable that takes a type list, unpacks the types, and then calls the Callable F with the types.
 
template<typename List >
using unique = fold< List, list<>, quote_trait< detail::insert_back_ >>
 Return a new meta::list where all duplicate elements have been removed. More...
 
template<typename T >
using vararg = detail::vararg_< T >
 For defining variadic placeholders.
 
template<typename... Ts>
using void_ = invoke< id< void >, Ts... >
 An alias for void.
 
template<typename 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 Fun , typename ListOfLists >
using zip_with = transform< transpose< ListOfLists >, uncurry< Fun >>
 Given a list of lists of types ListOfLists and a Callable Fun, construct a new list by calling Fun with the elements from the lists pairwise. More...
 

Variables

template<typename T >
constexpr T::type::value_type _v = T::type::value
 Variable alias for T::type::value. More...
 
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.