Range-v3
Range algorithms, views, and actions for the Standard Library
meta Namespace Reference

Tiny metaprogramming library. More...

Namespaces

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

Classes

struct  and_c
 
struct  bind_back
 An invocable that partially applies the invocable Fn by binding the arguments Us to the back of Fn. More...
 
struct  bind_front
 An invocable that partially applies the invocable Fn by binding the arguments Ts to the front of Fn. More...
 
struct  compose_
 Compose the Invocables Fns in the parameter pack Ts. More...
 
struct  compose_< Fn0 >
 
struct  compose_< Fn0, Fns... >
 
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
 An invocable that reverses the order of the first two arguments. More...
 
struct  id
 A trait that always returns its argument T. It is also an invocable 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  or_c
 Logically OR together all the Boolean parameters. More...
 
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  var
 For use when defining local variables in meta::let expressions. More...
 

Typedefs

using _args = vararg< void >
 
using _args_a = vararg< _a >
 
using _args_b = vararg< _b >
 
using _args_c = vararg< _c >
 
template<trait T>
using _t = typename T::type
 Type alias for T::type.
 
template<list_like L, typename State , invocable Fn>
using accumulate = fold< L, State, Fn >
 An alias for meta::fold. 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<list_like L, 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<typename... Bs>
using and_ = _t< detail::_and_< Bs... > >
 Logically AND together all the integral constant-wrapped Boolean parameters, with short-circuiting.
 
template<list_like L, 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<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<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<list_like L, integral N>
using at = at_c< L, N::type::value >
 Return the N th element in the meta::list L. More...
 
template<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<list_like L>
using back = _t< detail::back_< L > >
 Return the last element in meta::list L. More...
 
template<integral T, 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<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<integral T, 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<integral T, 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<bool B>
using bool_ = std::integral_constant< bool, B >
 An integral constant wrapper for bool.
 
template<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. 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... Fns>
using compose = compose_< Fns... >
 
template<typename... Lists>
using concat = concat_< Lists... >
 
template<list_like ... Ls>
using concat_ = _t< detail::concat_< Ls... > >
 Concatenates several lists into a single list. More...
 
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<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<list_like L, 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<invocable Fn, 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<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<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<integral T, 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<list_like L, 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<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<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<integral T, 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<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. That is, those elements that don't satisfy the Pred are "removed". More...
 
template<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<list_like L, 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<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. 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<list_like L, typename State , invocable Fn>
using fold = _t< detail::fold_< L, 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. That is, the State(N) for the list element A(N) is computed by Fn(State(N-1), A(N)) -> State(N). More...
 
template<list_like L>
using front = _t< detail::front_< L > >
 Return the first element in meta::list L. More...
 
template<integral T, 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<integral T, 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<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<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<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<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<list_like L>
using inherit = meta::_t< detail::inherit_< L > >
 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<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<invocable Fn, typename... Args>
using invoke = typename Fn::template invoke< Args... >
 Evaluate the invocable Fn 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 > >
 
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<list_like ListOfLists>
using join = apply< quote< concat >, ListOfLists >
 Joins a list of lists into a single list. More...
 
template<typename... Ts>
using lambda = detail::lambda_< list< Ts... > >
 For creating anonymous Invocables. More...
 
template<integral T, 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<integral T, 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<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 = _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... Ts>
using max = max_< Ts... >
 
template<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 min = min_< Ts... >
 
template<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<integral T, 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<integral T, 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<integral T, 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<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<list_like L, 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<integral B>
using not_ = not_c< B::type::value >
 Logically negate the integral constant-wrapped Boolean parameter.
 
template<bool B>
using not_c = bool_<!B >
 Logically negate the Boolean parameter.
 
template<integral T, 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<invocable Fn>
using not_fn = compose< quote< not_ >, Fn >
 Logically negate the result of invocable Fn.
 
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... Fns>
using on = on_< Fns... >
 
template<invocable ... Fns>
using on_ = detail::on_< Fns... >
 Use as on<Fn, Gs...>. Creates an invocable that applies invocable Fn to the result of applying invocable compose<Gs...> to all the arguments.
 
template<typename... Bs>
using or_ = _t< detail::_or_< Bs... > >
 Logically OR together all the integral constant-wrapped Boolean parameters, with short-circuiting.
 
template<typename F , typename S >
using pair = list< F, S >
 A list with exactly two elements.
 
template<list_like L, 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<integral T, 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<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<typename T >
using protect = detail::protect_< T >
 For preventing the evaluation of a nested defered computation in a let or lambda expression.
 
template<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<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<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<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<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<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<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<list_like L>
using reverse = _t< detail::reverse_< L > >
 Return a new meta::list by reversing the elements in the list L. More...
 
template<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<list_like L, 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<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. Returns #meta::npos if the type T was not found. More...
 
template<list_like L, typename State , 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. That is, the State(N) for the list element A(N) is computed by Fn(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<list_like L>
using size = meta::size_t< L::size()>
 An integral constant wrapper that is the size of the meta::list L.
 
template<std::size_t N>
using size_t = std::integral_constant< std::size_t, N >
 An integral constant wrapper for std::size_t.
 
template<typename T >
using sizeof_ = meta::size_t< sizeof(T)>
 An alias that computes the size of the type T. More...
 
template<list_like L, 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... Bs>
using strict_and = strict_and_< Bs... >
 
template<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_or = strict_or_< Bs... >
 
template<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... Args>
using transform = _t< detail::transform_< Args... > >
 Return a new meta::list constructed by transforming all the elements in L with the unary invocable Fn. transform can also be called with two lists of the same length and a binary invocable, in which case it returns a new list constructed with the results of calling Fn with each element in the lists, pairwise. More...
 
template<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<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<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<typename T >
using vararg = detail::vararg_< T >
 For defining variadic placeholders.
 
template<typename... >
using void_ = void
 An alias for void.
 
template<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<invocable Fn, 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...
 

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

template<integral 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.
 
template<typename , template< typename... > class>
constexpr bool is_v = false
 is_v Test whether a type T is an instantiation of class template C.
 
template<typename... Ts, template< typename... > class C>
constexpr bool is_v< C< Ts... >, C > = true
 

Detailed Description

Tiny metaprogramming library.