4.6.0
Freundlich's C++ toolkit
|
A metaprogramming library.
MPL stands for meta programming library and refers to the fact that you can write "programs" using C++ templates. As an example, consider the following variant type:
First of all, an implementation would have to check if Types...
are disjoint. Second of all, it would have to gather the sizes of all the types. This can all be written by hand, often using recursion on a template parameter pack, or it can be done using a MP library:
There are two key concepts here:
Instead of using a template parameter pack Types...
directly, we use fcppt::mpl::list::object<Types...>
. This way, the parameter pack becomes a single type and can be handled more easily.
template<typename...> class F
directly, we use fcppt::mpl::lambda<F>
. Again, this way, we turn F
into a single template parameter. fcppt::mpl::list::distinct expects an fcppt::mpl::list::object and returns std::true_type
if all types in the list are distinct and std::false_type
otherwise.
fcppt::mpl::list::map applies an fcppt::mpl::lambda to every element of a list. For example, if type_list = fcppt::mpl::object::list<int, float>
, then sizes = fcppt::mpl::list::object<sizeof_<int>,sizeof_<float>>
.
To understand how to write MP algorithms, it is important to understand lambdas and how they can be combined. The definition of fcppt::mpl::lambda is
This way, it can take any template of arbitrary arity:
Here, add_pointer
is a unary lambda and common_type
is a binary lambda. Since fcppt::mpl::list::object is a variadic template, make_list
is a variadic lambda.
To actually call a lambda, we use fcppt::mpl::apply:
Note that providing the wrong number of template parameters will lead to a compile error, for example fcppt::mpl::apply<add_pointer,int,float>
will not compile.
As terminology, we say that a lambda L
holds a function F of arity n
, if L = fcppt::mpl::lambda<F>
and F
is either an n-ary template or a variadic template.
Now consider the following example: We would like to create a lambda that evaluates to true if and only if the first parameter is int
. We can implement this writing an explicit function:
To do this more directly, we can also write the following code:
To understand why these are equivalent, we have to understand what fcppt::mpl::arg
, fcppt::mpl::constant
and fcppt::mpl::bind
do.
fcppt::mpl::arg<i>
is the i'th projection function. Formally, for every integer m >= i
it is a lambda that holds a function F_m
of arity m
, such that F_m<T_1,...,T_m> = T_i
.
fcppt::mpl::constant<C>
is the constant function. Formally, for every integer m
it holds a function F_m
of arity m
, such that F_m<T_1,...,T_m> = C
.
fcppt::mpl::bind
is function composition. Let L
be a lambda that holds a function G
of arity k
and let L_1, ..., L_k
be lambdas that hold functions G_1, ..., G_k
of arity m
. Then fcppt::mpl::bind<L,L_1,...,L_k>
holds a function F
of arity m
, such that F<T_1,...,T_m> = G<G_1<T_1,...,T_m>,...,G_k<T_1,...,T_m>>
. In our example, fcppt::mpl::lambda<std::is_same>
holds a function or arity 2, and both fcppt::mpl::arg<1>
and fcppt::mpl::constant<int>
hold functions or arity 1. Therefore, we have k=2
and m=1
and is_int2
holds a function of arity 1. We have
Classes | |
struct | fcppt::mpl::lambda< F > |
The lambda type. More... | |
struct | fcppt::mpl::list::object< Args > |
The list type used by this library. More... | |
struct | fcppt::mpl::map::element< Key, Value > |
The element type of a map.An element of a map is a key-value pair. More... | |
struct | fcppt::mpl::map::object< Args > |
The map type used by this library. More... | |
struct | fcppt::mpl::set::object< Args > |
The set type used by this library.A map is constructed from a variadic list of types, which must be pairwise disjoint. More... | |
Typedefs | |
template<fcppt::mpl::integral_concept T1, fcppt::mpl::integral_concept T2> | |
using | fcppt::mpl::add = typename fcppt::mpl::detail::add<T1,T2>::type |
Adds two integral constants.Let T1 = std::integral_constant<T,V_1> and T2 = std::integral_constant<T,V_2> . Then the result is std::integral_constant<T,V_1 + V_2> . | |
template<fcppt::mpl::lambda_concept L, typename... Args> | |
using | fcppt::mpl::apply = typename fcppt::mpl::detail::apply<L,Args...>::type |
Calls a lambda. | |
template<std::size_t Arg> | |
using | fcppt::mpl::arg = typename fcppt::mpl::detail::arg<Arg - 1U>::type |
A lambda that returns an argument in a specific position. | |
template<fcppt::mpl::lambda_concept L, fcppt::mpl::lambda_concept ... Ls> | |
using | fcppt::mpl::bind = typename fcppt::mpl::detail::bind<L,Ls...>::type |
Function composition on multiple lambdas. | |
template<typename T > | |
using | fcppt::mpl::constant = typename fcppt::mpl::detail::constant<T>::type |
The constant lambda. | |
template<fcppt::mpl::integral_concept T> | |
using | fcppt::mpl::dec = typename fcppt::mpl::detail::dec<T>::type |
Subtracts one from an integral constant.Let T = std::integral_constant<U,V> . Then the result is std::integral_constant<U,V--> . | |
template<typename Function > | |
using | fcppt::mpl::function_args = typename fcppt::mpl::detail::function_args<Function>::type |
The argument types of a function as a list. | |
template<fcppt::mpl::integral_concept T1, fcppt::mpl::integral_concept T2> | |
using | fcppt::mpl::greater = typename fcppt::mpl::detail::greater<T1,T2>::type |
Checks if one integral constant is greater than another.Let T1 = std::integral_constant<T,V_1> and T2 = std::integral_constant<T,V_2> . Then the result is std::bool_constant<(V1 > V2)> . | |
template<fcppt::mpl::bool_concept B, typename T , typename F > | |
using | fcppt::mpl::if_ = std::conditional_t<B::value, T, F> |
The if-then-else function.Similar to std::conditional_t but takes a bool_concept , i.e., a std::bool_constant<V> for any bool V instead of V directly. | |
template<typename F , fcppt::mpl::list::object_concept L> | |
using | fcppt::mpl::is_invocable |
Checks if a function can be invoked with a given argument list.Checks if function F can be invoked with the types in L , i.e. if L = list::object<L_1,...,L_n> , then the result is. | |
template<typename T > | |
using | fcppt::mpl::is_lambda = typename fcppt::mpl::detail::is_lambda<T>::type |
Checks if a type is a lambda. | |
template<typename T > | |
using | fcppt::mpl::is_size_type = typename fcppt::mpl::detail::is_size_type<T>::type |
Checks if a type is a size_type.T is a size type if and only if it is of the form fcppt::mpl::size_type<N> for some std::size_t N . | |
template<fcppt::mpl::integral_concept T1, fcppt::mpl::integral_concept T2> | |
using | fcppt::mpl::less = typename fcppt::mpl::detail::less<T1, T2>::type |
Checks if one integral constant is less than another.Let T1 = std::integral_constant<T,V_1> and T2 = std::integral_constant<T,V_2> . Then the result is std::bool_constant<(V1 < V2)> . | |
template<fcppt::mpl::list::object_concept List, fcppt::mpl::lambda_concept L> | |
using | fcppt::mpl::list::all_of |
Checks if a predicate holds for all types of a list.If List=list::object<L_1,...,L_n> and L holds a function F of arity 1 , then the result is. | |
template<fcppt::mpl::list::object_concept List, fcppt::mpl::lambda_concept L> | |
using | fcppt::mpl::list::any_of |
Checks if a predicate holds for any type of a list.If List=list::object<L_1,...,L_n> and L holds a function F of arity 1 , then the result is. | |
template<fcppt::mpl::list::object_concept List1, fcppt::mpl::list::object_concept List2> | |
using | fcppt::mpl::list::append = typename fcppt::mpl::list::detail::append<List1,List2>::type |
Appends two lists.If List1 = list::object<L_1,...,L_n> and List2 = list::object<R_1,...,R_m> then the result is. | |
template<fcppt::mpl::lambda_concept L, fcppt::mpl::list::object_concept Args> | |
using | fcppt::mpl::list::apply = typename fcppt::mpl::list::detail::apply<L,Args>::type |
Calls a lambda using a list of arguments. | |
template<fcppt::mpl::list::object_concept List, fcppt::mpl::size_type_concept Index> | |
using | fcppt::mpl::list::at = typename fcppt::mpl::list::detail::at<List,Index>::type |
The element of a list at a given position.If List = list::object<L_1,...,L_n> and Index = fcppt::mpl::size_type<j> with 0 <= j < n then the result is L_{j-1} . | |
template<fcppt::mpl::list::object_concept List> | |
using | fcppt::mpl::list::back = fcppt::mpl::list::at<List,fcppt::mpl::dec<fcppt::mpl::list::size<List>>> |
The last element of a list.If List = list::object<L_1,...,L_n> then the result is L_n . | |
template<fcppt::mpl::list::object_concept List, typename E > | |
using | fcppt::mpl::list::contains |
Checks if a list contains an element.Let List = list::object<L_1,...,L_n> . The result is std::true_type if E = L_i for some 1 <= i <= n . Otherwise, it is std::false_type . | |
template<fcppt::mpl::list::object_concept List> | |
using | fcppt::mpl::list::distinct = typename fcppt::mpl::list::detail::distinct<List>::type |
Checks if all elements of a list are pairwise disjoint.Let List = list::object<L_1,...,L_n> . If L_i != L_j for all 1 <= i != j <= n then the result is std::true_type . Otherwise, it is std::false_type . | |
template<fcppt::mpl::list::object_concept List, fcppt::mpl::size_type_concept S> | |
using | fcppt::mpl::list::drop |
Removes some elements of a list from the beginning.If List = list::object<L_1,...,L_n> then the result is. | |
template<fcppt::mpl::list::object_concept List> | |
using | fcppt::mpl::list::empty = std::is_same<fcppt::mpl::list::size<List>,fcppt::mpl::size_type<0U>> |
Checks if a list is empty.Let List = list::object<L_1,...,L_n> . If n = 0 then std::true_type is returned. Otherwise, std::false_type is returned. | |
template<fcppt::mpl::list::object_concept List, fcppt::mpl::lambda_concept L, typename V > | |
using | fcppt::mpl::list::fold = typename fcppt::mpl::list::detail::fold<List,L,V>::type |
Folds a list. | |
template<typename Type > | |
using | fcppt::mpl::list::from = typename fcppt::mpl::list::detail::from<Type>::type |
Converts a template type to a list.If Type = T<L_1, ..., L_n> then the result is list::object<L_1,...,L_n> . | |
template<fcppt::mpl::list::object_concept List> | |
using | fcppt::mpl::list::front = typename fcppt::mpl::list::detail::front<List>::type |
The first element of a list.If List = list::object<L_1,...,L_n> then the result is L_1 . | |
template<fcppt::mpl::list::object_concept List, typename E > | |
using | fcppt::mpl::list::index_of |
The first index of a given element inside a list.Let List = list::object<L_1,...,L_n> . Returns size_type<Index> where Index is the smallest number such that L_{Index} = E . | |
template<fcppt::mpl::list::object_concept List, fcppt::mpl::lambda_concept L> | |
using | fcppt::mpl::list::index_of_if = typename fcppt::mpl::list::detail::index_of_if<List,L,fcppt::mpl::size_type<0U>>::type |
The first index where an element matches a predicate inside a list.Let List = list::object<L_1,...,L_n> and let L hold a function F of arity 1 . Returns size_type<Index> where Index is the smallest number such that F<L_{Index}> = std::true_type . | |
template<fcppt::mpl::list::object_concept List> | |
using | fcppt::mpl::list::indices = fcppt::mpl::list::interval<fcppt::mpl::size_type<0U>,fcppt::mpl::list::size<List>> |
Returns the positions of a list.If List = list::object<L_1,...,L_n> then the result is. | |
template<fcppt::type_traits::integral_constant_concept Begin, fcppt::type_traits::integral_constant_concept End> | |
using | fcppt::mpl::list::interval |
Return the interval between two numbers.If Begin = std::integral_constant<Type,B> and End = std::integral_constant<Type,E> then the result is. | |
template<typename T > | |
using | fcppt::mpl::list::is_object = typename fcppt::mpl::list::detail::is_object<T>::type |
Checks if a type is a list. | |
template<fcppt::mpl::list::object_concept List> | |
using | fcppt::mpl::list::join |
Joins a list of lists.If List = list::object<L_1,...,L_n> and L_1, ..., L_n are lists, then the result is. | |
template<fcppt::mpl::list::object_concept List, fcppt::mpl::lambda_concept Pred> | |
using | fcppt::mpl::list::keep_if |
Only keeps elements that satisfy a predicate.Keeps the elements of List for which Pred is std::true_type . The order of the elements stays the same. | |
template<fcppt::mpl::list::object_concept List, fcppt::mpl::lambda_concept F> | |
using | fcppt::mpl::list::map = typename fcppt::mpl::list::detail::map<List,F>::type |
Applies a lambda to every element of a list.If List=list::object<L_1,...,L_n> and L holds a function F of arity 1 , then the result is. | |
template<fcppt::mpl::lambda_concept F, fcppt::mpl::list::object_concept... Lists> | |
using | fcppt::mpl::list::map_multi |
Applies an n-ary lambda to every element-tuple of n lists.If Lists=list::object<L_{1,1},...,L_{1,k}>, ... list::object<L_{1,n},...,L_{n,k}> and L holds a function F of arity n , then the result is. | |
template<typename Sequence > | |
using | fcppt::mpl::list::maximum |
Calculates the maximum value of a list. | |
template<fcppt::mpl::list::object_concept List> | |
using | fcppt::mpl::list::pop_back = typename fcppt::mpl::list::detail::pop_back<fcppt::mpl::list::object<>,List>::type |
Removes the last element of a list.If List = list::object<L_1,...,L_n> , where n >= 1 , then the result is. | |
template<fcppt::mpl::list::object_concept List, typename T > | |
using | fcppt::mpl::list::push_back = typename fcppt::mpl::list::detail::push_back<List,T>::type |
Adds an element to the back of a list.If List = list::object<L_1,...,L_n> , then the result is. | |
template<fcppt::mpl::list::object_concept List, typename T > | |
using | fcppt::mpl::list::push_front = typename fcppt::mpl::list::detail::push_front<List,T>::type |
Adds an element to the front of a list.If List = list::object<L_1,...,L_n> , then the result is. | |
template<fcppt::mpl::list::object_concept List, typename T > | |
using | fcppt::mpl::list::remove |
Removes a specific type from a list.Removes every occurrence of T from List. The order of the remaining elements stays the same. | |
template<fcppt::mpl::list::object_concept List, fcppt::mpl::lambda_concept Pred> | |
using | fcppt::mpl::list::remove_if |
Removes the elements that satisfy a predicate.Removes the elements of List for which Pred is std::true_type . The order of the remaining elements stays the same. | |
template<typename T , fcppt::mpl::size_type_concept S> | |
using | fcppt::mpl::list::repeat |
Creates a list that consists of n elements that are all the same.Let S = fcppt::mpl::size_type<n> . Then the result is. | |
template<fcppt::mpl::list::object_concept List> | |
using | fcppt::mpl::list::size = typename fcppt::mpl::list::detail::size<List>::type |
The size of a list.If List = list::object<L_1,...,L_n> then the result is fcppt::mpl::size_type<n> . | |
template<fcppt::mpl::list::object_concept List> | |
using | fcppt::mpl::list::tail = typename fcppt::mpl::list::detail::tail<List>::type |
Removes the first element of a list.If List = list::object<L_1,...,L_n> , where n >= 1 , then the result is. | |
template<fcppt::mpl::list::object_concept List, fcppt::mpl::size_type_concept S> | |
using | fcppt::mpl::list::take = typename fcppt::mpl::list::detail::take<List,std::make_index_sequence<S::value>>::type |
Keeps some elements of a list from the beginning.If List = list::object<L_1,...,L_n> then the result is. | |
template<fcppt::mpl::list::object_concept List> | |
using | fcppt::mpl::list::transpose = typename fcppt::mpl::list::detail::transpose<List>::type |
Transposes n lists of length k into k lists of length n.If. | |
template<fcppt::mpl::map::object_concept Map, typename Key > | |
using | fcppt::mpl::map::at = typename fcppt::mpl::map::detail::at<Map,Key>::type |
The value type associated with a key in a map.Let Map = map::object<element<K_1,V_1>,...,element<K_n,V_n>> , where Key = K_i for some 1 <= i <= n . Then the result is V_i . | |
template<fcppt::mpl::map::element_concept Element> | |
using | fcppt::mpl::map::element_key = typename fcppt::mpl::map::detail::element_key<Element>::type |
The key type of an element.Returns K if Element=map::element<K,V> . | |
template<fcppt::mpl::map::element_concept Element> | |
using | fcppt::mpl::map::element_value = typename fcppt::mpl::map::detail::element_value<Element>::type |
The value type of an element.Returns V if Element=map::element<K,V> . | |
template<fcppt::mpl::map::object_concept Map1, fcppt::mpl::map::object_concept Map2> | |
using | fcppt::mpl::map::equal |
Checks if two maps are equal. | |
template<fcppt::mpl::map::object_concept Map> | |
using | fcppt::mpl::map::flip = typename fcppt::mpl::map::detail::flip<Map>::type |
Flips the key-value pairs inside a map.Let Map=map::object<element<K_1,V_1>,...,element<K_n,V_n>> . Then the result is. | |
template<fcppt::mpl::map::object_concept Map, typename Key > | |
using | fcppt::mpl::map::has_key = typename fcppt::mpl::map::detail::has_key<Map,Key>::type |
Checks if a map contains a key.Let Map = map::object<element<K_1,V_1>,...,element<K_n,V_n>> . If Key = K_i for some 1 <= i <= n , then the result is std::true_type . Otherwise, it is std::false_type . | |
template<fcppt::mpl::map::object_concept Map, typename Key , typename Value > | |
using | fcppt::mpl::map::insert = typename fcppt::mpl::map::detail::insert<Map,Key,Value>::type |
Inserts a new element into a map.Let Map = map::object<element<K_1,V_1>,...,element<K_n,V_n>> . Then the result is. | |
template<typename T > | |
using | fcppt::mpl::map::is_element = typename fcppt::mpl::map::detail::is_element<T>::type |
Checks if a type is a map element.T is a map element if an only if it is of the form fcppt::mpl::map::element<K,V> for some types K, V . | |
template<typename T > | |
using | fcppt::mpl::map::is_object = typename fcppt::mpl::map::detail::is_object<T>::type |
Checks if a type is a map. | |
template<fcppt::mpl::map::object_concept Map> | |
using | fcppt::mpl::map::keys = typename fcppt::mpl::map::detail::keys<Map>::type |
They keys of a map as a set.Let Map = map::object<element<K_1,V_1>,...,element<K_n,V_n>> . Then the result is. | |
template<fcppt::mpl::map::element_concept... Args> | |
using | fcppt::mpl::map::keys_unique |
Checks if the keys of elements are pairwise disjoint.Let Args=element<K_1,V_1>,...,element<K_n,V_n> . The result is std::true_type if all the keys K_1,...,K_n are pairwise disjoint. Otherwise, it is std::false_type . | |
template<fcppt::mpl::integral_concept T1, fcppt::mpl::integral_concept T2> | |
using | fcppt::mpl::mul = typename fcppt::mpl::detail::mul<T1,T2>::type |
Multiplies two integral constants.Let T1 = std::integral_constant<T,V_1> and T2 = std::integral_constant<T,V_2> . Then the result is std::integral_constant<T,V_1 * V_2> . | |
template<fcppt::mpl::set::object_concept Set, typename Key > | |
using | fcppt::mpl::set::contains = typename fcppt::mpl::set::detail::contains<Set,Key>::type |
Checks if a set contains an element.Let Set = set::object<E_1,...,E_n> . The result is std::true_type if Key = E_i for some 1 <= i <= n . Otherwise, it is std::false_type . | |
template<fcppt::mpl::set::object_concept Set1, fcppt::mpl::set::object_concept Set2> | |
using | fcppt::mpl::set::difference |
The difference of two sets.The result contains every element that is in Set1, but not in Set2. | |
template<fcppt::mpl::set::object_concept Set1, fcppt::mpl::set::object_concept Set2> | |
using | fcppt::mpl::set::equal |
Checks if two sets are equal. | |
template<fcppt::mpl::list::object_concept List> | |
using | fcppt::mpl::set::from_list = typename fcppt::mpl::set::detail::from_list<List>::type |
Converts a list with no duplicates into a set.Let List = list::object<L_1,...,L_n> , where L_1,...,L_n are pairwise disjoint. The result is. | |
template<fcppt::mpl::list::object_concept List> | |
using | fcppt::mpl::set::from_list_relaxed |
Converts a list with into a set, removing duplicates.Unlike fcppt::mpl::set::from_list, this function allows duplicate elements. | |
template<fcppt::mpl::set::object_concept Set, typename E > | |
using | fcppt::mpl::set::insert = typename fcppt::mpl::set::detail::insert<Set,E>::type |
Inserts a new element into a set.Let Set = set::object<E_1,...,E_n> . Then the result is. | |
template<fcppt::mpl::set::object_concept Set, typename Value > | |
using | fcppt::mpl::set::insert_relaxed |
Inserts an element into a set.Let Set = set::object<E_1,...,E_n> . If E is not equal to any of the E_1,...,E_n , then the result is. | |
template<fcppt::mpl::set::object_concept Set1, fcppt::mpl::set::object_concept Set2> | |
using | fcppt::mpl::set::intersection |
The intersection of two sets.The result contains every element that is both in Set1 and Set2. | |
template<typename T > | |
using | fcppt::mpl::set::is_object = typename fcppt::mpl::set::detail::is_object<T>::type |
Checks if a type is a set. | |
template<fcppt::mpl::set::object_concept Set> | |
using | fcppt::mpl::set::size = fcppt::mpl::list::size<fcppt::mpl::set::to_list<Set>> |
The size of a set.If Set = set::object<L_1,...,L_n> then the result is fcppt::mpl::size_type<n> . | |
template<fcppt::mpl::set::object_concept Set1, fcppt::mpl::set::object_concept Set2> | |
using | fcppt::mpl::set::symmetric_difference |
The symmetric difference of two sets.The result contains every element that is either in Set1 or in Set2, but not in both. | |
template<fcppt::mpl::set::object_concept Set> | |
using | fcppt::mpl::set::to_list = typename fcppt::mpl::set::detail::to_list<Set>::type |
Converts a set to a list.Let Set = set::object<E_1,...,E_n> . The result is. | |
template<fcppt::mpl::set::object_concept Set1, fcppt::mpl::set::object_concept Set2> | |
using | fcppt::mpl::set::union_ |
The union of two sets.The result contains every element that is in Set1 or in Set2. | |
template<typename... Args> | |
using | fcppt::mpl::set::unique = fcppt::mpl::list::distinct<fcppt::mpl::list::object<Args...>> |
Checks if a variadic list is pairwise disjoint. | |
template<std::size_t I> | |
using | fcppt::mpl::size_type = std::integral_constant<std::size_t,I> |
The size type used by this library. | |
Functions | |
template<fcppt::mpl::list::object_concept List, typename Function > | |
void | fcppt::mpl::list::for_each_break (Function const &_function) |
Calls a runtime function for each element of a listing, possibly breaking out early. | |
template<fcppt::mpl::list::object_concept List, typename Function , typename FailFunction > | |
FCPPT_PP_PUSH_WARNING std::invoke_result_t< FailFunction > | fcppt::mpl::list::invoke_on (std::size_t const _index, Function const &_function, FailFunction const &_fail_function) |
Applies a function to the nth element of an mpl::list::object with a runtime index. | |
template<typename Ch , typename Traits , typename... Types> | |
std::basic_ostream< Ch, Traits > & | fcppt::mpl::list::operator<< (std::basic_ostream< Ch, Traits > &_stream, fcppt::mpl::list::object< Types... > const &) |
Prints a list.Prints List to _stream. Every type in List will be converted to a string using fcppt::type_name. | |
Variables | |
template<fcppt::mpl::lambda_concept L, typename... Args> | |
constexpr bool | fcppt::mpl::apply_v = fcppt::mpl::apply<L,Args...>::value |
Calls a lambda. | |
template<typename F , fcppt::mpl::list::object_concept L> | |
constexpr bool | fcppt::mpl::is_invocable_v = fcppt::mpl::is_invocable<F,L>::value |
Checks if a function can be invoked with a given argument list. | |
template<fcppt::mpl::list::object_concept List, fcppt::mpl::lambda_concept L> | |
constexpr bool | fcppt::mpl::list::all_of_v = fcppt::mpl::list::all_of<List,L>::value |
Checks if a predicate holds for all types of a list. | |
template<fcppt::mpl::list::object_concept List, fcppt::mpl::lambda_concept L> | |
constexpr bool | fcppt::mpl::list::any_of_v = fcppt::mpl::list::any_of<List,L>::value |
Checks if a predicate holds for any type of a list. | |
template<fcppt::mpl::lambda_concept L, fcppt::mpl::list::object_concept Args> | |
constexpr bool | fcppt::mpl::list::apply_v = fcppt::mpl::list::apply<L,Args>::value |
Calls a lambda using a list of arguments. | |
template<fcppt::mpl::list::object_concept List, typename E > | |
constexpr bool | fcppt::mpl::list::contains_v = fcppt::mpl::list::contains<List,E>::value |
Checks if a list contains an element. | |
template<fcppt::mpl::list::object_concept List> | |
constexpr bool | fcppt::mpl::list::distinct_v = fcppt::mpl::list::distinct<List>::value |
Checks if all elements of a list are pairwise disjoint. | |
template<fcppt::mpl::list::object_concept List> | |
constexpr bool | fcppt::mpl::list::empty_v = fcppt::mpl::list::empty<List>::value |
Checks if a list is empty. | |
template<fcppt::mpl::map::object_concept Map1, fcppt::mpl::map::object_concept Map2> | |
constexpr bool | fcppt::mpl::map::equal_v = fcppt::mpl::map::equal<Map1,Map2>::value |
Checks if two maps are equal. | |
template<fcppt::mpl::map::object_concept Map, typename Key > | |
constexpr bool | fcppt::mpl::map::has_key_v = fcppt::mpl::map::has_key<Map,Key>::value |
Checks if a map contains a key. | |
template<fcppt::mpl::set::object_concept Set, typename Key > | |
constexpr bool | fcppt::mpl::set::contains_v = fcppt::mpl::set::contains<Set,Key>::value |
Checks if a set contains an element. | |
template<fcppt::mpl::set::object_concept Set1, fcppt::mpl::set::object_concept Set2> | |
constexpr bool | fcppt::mpl::set::equal_v = fcppt::mpl::set::equal<Set1,Set2>::value |
Checks if two sets are equal. | |
using fcppt::mpl::add = typename fcppt::mpl::detail::add<T1,T2>::type |
Adds two integral constants.Let T1 = std::integral_constant<T,V_1>
and T2 = std::integral_constant<T,V_2>
. Then the result is std::integral_constant<T,V_1 + V_2>
.
using fcppt::mpl::list::all_of |
Checks if a predicate holds for all types of a list.If List=list::object<L_1,...,L_n>
and L
holds a function F
of arity 1
, then the result is.
TODO(concepts)
using fcppt::mpl::list::any_of |
Checks if a predicate holds for any type of a list.If List=list::object<L_1,...,L_n>
and L
holds a function F
of arity 1
, then the result is.
TODO(concepts)
using fcppt::mpl::list::append = typename fcppt::mpl::list::detail::append<List1,List2>::type |
Appends two lists.If List1 = list::object<L_1,...,L_n>
and List2 = list::object<R_1,...,R_m>
then the result is.
using fcppt::mpl::apply = typename fcppt::mpl::detail::apply<L,Args...>::type |
Calls a lambda.
If L
holds a function F
of arity n and Args = A_1,...,A_n
, then F<A_1,...,A_n>
is returned.
using fcppt::mpl::list::apply = typename fcppt::mpl::list::detail::apply<L,Args>::type |
Calls a lambda using a list of arguments.
If L
holds a function F
of arity n and Args = list::object<A_1,...,A_n>
, then F<A_1,...,A_n>
is returned.
using fcppt::mpl::arg = typename fcppt::mpl::detail::arg<Arg - 1U>::type |
A lambda that returns an argument in a specific position.
A lambda that returns the argument in position Arg
. Formally, for every integer m >= Arg
it is a lambda that holds a function F_m
of arity m
, such that F_m<T_1,...,T_m> = T_Arg
.
1
instead of 0
. using fcppt::mpl::list::at = typename fcppt::mpl::list::detail::at<List,Index>::type |
The element of a list at a given position.If List = list::object<L_1,...,L_n>
and Index = fcppt::mpl::size_type<j>
with 0 <= j < n
then the result is L_{j-1}
.
using fcppt::mpl::map::at = typename fcppt::mpl::map::detail::at<Map,Key>::type |
The value type associated with a key in a map.Let Map = map::object<element<K_1,V_1>,...,element<K_n,V_n>>
, where Key = K_i
for some 1 <= i <= n
. Then the result is V_i
.
using fcppt::mpl::list::back = fcppt::mpl::list::at<List,fcppt::mpl::dec<fcppt::mpl::list::size<List>>> |
The last element of a list.If List = list::object<L_1,...,L_n>
then the result is L_n
.
using fcppt::mpl::bind = typename fcppt::mpl::detail::bind<L,Ls...>::type |
Function composition on multiple lambdas.
Suppose that L
holds a function G
and Ls...
hold functions Gs...
, then bind<L,Ls...>
is a lambda that when called with arguments Args...
it returns
Formally, let G
be of arity k
and Gs... = G_1, ..., G_k
be of arity m
. Then fcppt::mpl::bind<L,L_1,...,L_k>
holds a function F
of arity m
, such that F<T_1,...,T_m> = G<G_1<T_1,...,T_m>,...,G_k<T_1,...,T_m>>
.
using fcppt::mpl::constant = typename fcppt::mpl::detail::constant<T>::type |
The constant lambda.
This is a lambda that returns T
.
Formally, for every integer m
it holds a function F_m
of arity m
, such that F_m<T_1,...,T_m> = C
.
using fcppt::mpl::list::contains |
Checks if a list contains an element.Let List = list::object<L_1,...,L_n>
. The result is std::true_type
if E = L_i
for some 1 <= i <= n
. Otherwise, it is std::false_type
.
using fcppt::mpl::set::contains = typename fcppt::mpl::set::detail::contains<Set,Key>::type |
Checks if a set contains an element.Let Set = set::object<E_1,...,E_n>
. The result is std::true_type
if Key = E_i
for some 1 <= i <= n
. Otherwise, it is std::false_type
.
using fcppt::mpl::dec = typename fcppt::mpl::detail::dec<T>::type |
Subtracts one from an integral constant.Let T = std::integral_constant<U,V>
. Then the result is std::integral_constant<U,V-->
.
using fcppt::mpl::set::difference |
The difference of two sets.The result contains every element that is in Set1, but not in Set2.
using fcppt::mpl::list::distinct = typename fcppt::mpl::list::detail::distinct<List>::type |
Checks if all elements of a list are pairwise disjoint.Let List = list::object<L_1,...,L_n>
. If L_i != L_j
for all 1 <= i != j <= n
then the result is std::true_type
. Otherwise, it is std::false_type
.
using fcppt::mpl::list::drop |
Removes some elements of a list from the beginning.If List = list::object<L_1,...,L_n>
then the result is.
using fcppt::mpl::map::element_key = typename fcppt::mpl::map::detail::element_key<Element>::type |
The key type of an element.Returns K
if Element=map::element<K,V>
.
using fcppt::mpl::map::element_value = typename fcppt::mpl::map::detail::element_value<Element>::type |
The value type of an element.Returns V
if Element=map::element<K,V>
.
using fcppt::mpl::list::empty = std::is_same<fcppt::mpl::list::size<List>,fcppt::mpl::size_type<0U>> |
Checks if a list is empty.Let List = list::object<L_1,...,L_n>
. If n = 0
then std::true_type
is returned. Otherwise, std::false_type
is returned.
using fcppt::mpl::map::equal |
Checks if two maps are equal.
Two maps are equal if and only if they contain the same key-value pairs. Let Map1=map::object<element<K_1,V_1>,...,element<K_n,V_n>>
and Map2=map::object<element<K_1',V_1'>,...,element<K_m',V_m'>>
. Then the result is std::true_type
if
Otherwise, the result is std::false_type
.
using fcppt::mpl::set::equal |
Checks if two sets are equal.
Two sets are equal if and only if they contain the same elements. Let Set1=set::object<E_1,...,E_n>
and Set2=set::object<E_1',...,E_m'>>
. Then the result is std::true_type
if
Otherwise, the result is std::false_type
.
using fcppt::mpl::map::flip = typename fcppt::mpl::map::detail::flip<Map>::type |
Flips the key-value pairs inside a map.Let Map=map::object<element<K_1,V_1>,...,element<K_n,V_n>>
. Then the result is.
This only works if all the values V_1,...,V_n
are pairwise disjoint.
using fcppt::mpl::list::fold = typename fcppt::mpl::list::detail::fold<List,L,V>::type |
Folds a list.
Let List = list::object<L_1,...,L_n>
and L
hold a function F
of arity 2
. Let V_i = F<L_{i+1},V_{i+1}>
for 0 <= i < n
and V_n = V
. Then the result is V_0
. The calculations are
Notice that if n=0
then V_0 = V.
using fcppt::mpl::list::from = typename fcppt::mpl::list::detail::from<Type>::type |
Converts a template type to a list.If Type = T<L_1, ..., L_n>
then the result is list::object<L_1,...,L_n>
.
using fcppt::mpl::set::from_list = typename fcppt::mpl::set::detail::from_list<List>::type |
Converts a list with no duplicates into a set.Let List = list::object<L_1,...,L_n>
, where L_1,...,L_n
are pairwise disjoint. The result is.
using fcppt::mpl::set::from_list_relaxed |
Converts a list with into a set, removing duplicates.Unlike fcppt::mpl::set::from_list, this function allows duplicate elements.
using fcppt::mpl::list::front = typename fcppt::mpl::list::detail::front<List>::type |
The first element of a list.If List = list::object<L_1,...,L_n>
then the result is L_1
.
using fcppt::mpl::function_args = typename fcppt::mpl::detail::function_args<Function>::type |
The argument types of a function as a list.
Function | Must be a function type. |
TODO(concepts)
using fcppt::mpl::greater = typename fcppt::mpl::detail::greater<T1,T2>::type |
Checks if one integral constant is greater than another.Let T1 = std::integral_constant<T,V_1>
and T2 = std::integral_constant<T,V_2>
. Then the result is std::bool_constant<(V1 > V2)>
.
using fcppt::mpl::map::has_key = typename fcppt::mpl::map::detail::has_key<Map,Key>::type |
Checks if a map contains a key.Let Map = map::object<element<K_1,V_1>,...,element<K_n,V_n>>
. If Key = K_i
for some 1 <= i <= n
, then the result is std::true_type
. Otherwise, it is std::false_type
.
using fcppt::mpl::if_ = std::conditional_t<B::value, T, F> |
The if-then-else function.Similar to std::conditional_t
but takes a bool_concept
, i.e., a std::bool_constant<V>
for any bool V
instead of V
directly.
using fcppt::mpl::list::index_of |
The first index of a given element inside a list.Let List = list::object<L_1,...,L_n>
. Returns size_type<Index>
where Index
is the smallest number such that L_{Index} = E
.
using fcppt::mpl::list::index_of_if = typename fcppt::mpl::list::detail::index_of_if<List,L,fcppt::mpl::size_type<0U>>::type |
The first index where an element matches a predicate inside a list.Let List = list::object<L_1,...,L_n>
and let L
hold a function F
of arity 1
. Returns size_type<Index>
where Index
is the smallest number such that F<L_{Index}> = std::true_type
.
using fcppt::mpl::list::indices = fcppt::mpl::list::interval<fcppt::mpl::size_type<0U>,fcppt::mpl::list::size<List>> |
Returns the positions of a list.If List = list::object<L_1,...,L_n>
then the result is.
using fcppt::mpl::map::insert = typename fcppt::mpl::map::detail::insert<Map,Key,Value>::type |
Inserts a new element into a map.Let Map = map::object<element<K_1,V_1>,...,element<K_n,V_n>>
. Then the result is.
This only works if Key
is not equal to any of the K_1,...,K_n
.
using fcppt::mpl::set::insert = typename fcppt::mpl::set::detail::insert<Set,E>::type |
Inserts a new element into a set.Let Set = set::object<E_1,...,E_n>
. Then the result is.
This only works if E
is not equal to any of the E_1,...,E_n
.
using fcppt::mpl::set::insert_relaxed |
Inserts an element into a set.Let Set = set::object<E_1,...,E_n>
. If E
is not equal to any of the E_1,...,E_n
, then the result is.
Otherwise, the result is Set
.
using fcppt::mpl::set::intersection |
The intersection of two sets.The result contains every element that is both in Set1 and Set2.
using fcppt::mpl::list::interval |
Return the interval between two numbers.If Begin = std::integral_constant<Type,B>
and End = std::integral_constant<Type,E>
then the result is.
End
is not included in the range but Begin
is. using fcppt::mpl::map::is_element = typename fcppt::mpl::map::detail::is_element<T>::type |
Checks if a type is a map element.T
is a map element if an only if it is of the form fcppt::mpl::map::element<K,V>
for some types K, V
.
using fcppt::mpl::is_invocable |
Checks if a function can be invoked with a given argument list.Checks if function F
can be invoked with the types in L
, i.e. if L = list::object<L_1,...,L_n>
, then the result is.
using fcppt::mpl::is_lambda = typename fcppt::mpl::detail::is_lambda<T>::type |
Checks if a type is a lambda.
T
is a lambda if an only if it is of the form fcppt::mpl::lambda<F>
for some type F
.
using fcppt::mpl::list::is_object = typename fcppt::mpl::list::detail::is_object<T>::type |
Checks if a type is a list.
T
is a list if an only if it is of the form fcppt::mpl::list::object<T_1, ..., T_n>
for some types T_1, ..., T_n
.
using fcppt::mpl::map::is_object = typename fcppt::mpl::map::detail::is_object<T>::type |
Checks if a type is a map.
T
is a map if an only if it is of the form fcppt::mpl::map::object<E_1, ..., E_n>
for some elements E_1, ..., E_n
.
using fcppt::mpl::set::is_object = typename fcppt::mpl::set::detail::is_object<T>::type |
Checks if a type is a set.
T
is a set if an only if it is of the form fcppt::mpl::set::object<T_1, ..., T_n>
for some types T_1, ..., T_n
.
using fcppt::mpl::is_size_type = typename fcppt::mpl::detail::is_size_type<T>::type |
Checks if a type is a size_type.T
is a size type if and only if it is of the form fcppt::mpl::size_type<N>
for some std::size_t N
.
using fcppt::mpl::list::join |
Joins a list of lists.If List = list::object<L_1,...,L_n>
and L_1, ..., L_n
are lists, then the result is.
List | Must be a list of lists. TODO(concepts) |
using fcppt::mpl::list::keep_if |
Only keeps elements that satisfy a predicate.Keeps the elements of List for which Pred is std::true_type
. The order of the elements stays the same.
using fcppt::mpl::map::keys = typename fcppt::mpl::map::detail::keys<Map>::type |
They keys of a map as a set.Let Map = map::object<element<K_1,V_1>,...,element<K_n,V_n>>
. Then the result is.
using fcppt::mpl::map::keys_unique |
Checks if the keys of elements are pairwise disjoint.Let Args=element<K_1,V_1>,...,element<K_n,V_n>
. The result is std::true_type
if all the keys K_1,...,K_n
are pairwise disjoint. Otherwise, it is std::false_type
.
using fcppt::mpl::less = typename fcppt::mpl::detail::less<T1, T2>::type |
Checks if one integral constant is less than another.Let T1 = std::integral_constant<T,V_1>
and T2 = std::integral_constant<T,V_2>
. Then the result is std::bool_constant<(V1 < V2)>
.
using fcppt::mpl::list::map = typename fcppt::mpl::list::detail::map<List,F>::type |
Applies a lambda to every element of a list.If List=list::object<L_1,...,L_n>
and L
holds a function F
of arity 1
, then the result is.
using fcppt::mpl::list::map_multi |
Applies an n-ary lambda to every element-tuple of n lists.If Lists=list::object<L_{1,1},...,L_{1,k}>, ... list::object<L_{1,n},...,L_{n,k}>
and L
holds a function F
of arity n
, then the result is.
Lists | Must all have the same size. TODO(concepts) |
using fcppt::mpl::list::maximum |
Calculates the maximum value of a list.
Sequence | A non empty mpl::list::object of std::integral_constants. TODO(concepts) |
using fcppt::mpl::mul = typename fcppt::mpl::detail::mul<T1,T2>::type |
Multiplies two integral constants.Let T1 = std::integral_constant<T,V_1>
and T2 = std::integral_constant<T,V_2>
. Then the result is std::integral_constant<T,V_1 * V_2>
.
using fcppt::mpl::list::pop_back = typename fcppt::mpl::list::detail::pop_back<fcppt::mpl::list::object<>,List>::type |
Removes the last element of a list.If List = list::object<L_1,...,L_n>
, where n >= 1
, then the result is.
using fcppt::mpl::list::push_back = typename fcppt::mpl::list::detail::push_back<List,T>::type |
Adds an element to the back of a list.If List = list::object<L_1,...,L_n>
, then the result is.
using fcppt::mpl::list::push_front = typename fcppt::mpl::list::detail::push_front<List,T>::type |
Adds an element to the front of a list.If List = list::object<L_1,...,L_n>
, then the result is.
using fcppt::mpl::list::remove |
Removes a specific type from a list.Removes every occurrence of T from List. The order of the remaining elements stays the same.
using fcppt::mpl::list::remove_if |
Removes the elements that satisfy a predicate.Removes the elements of List for which Pred is std::true_type
. The order of the remaining elements stays the same.
using fcppt::mpl::list::repeat |
Creates a list that consists of n elements that are all the same.Let S = fcppt::mpl::size_type<n>
. Then the result is.
where T_1 = ... = T_n = T
.
using fcppt::mpl::list::size = typename fcppt::mpl::list::detail::size<List>::type |
The size of a list.If List = list::object<L_1,...,L_n>
then the result is fcppt::mpl::size_type<n>
.
using fcppt::mpl::set::size = fcppt::mpl::list::size<fcppt::mpl::set::to_list<Set>> |
The size of a set.If Set = set::object<L_1,...,L_n>
then the result is fcppt::mpl::size_type<n>
.
using fcppt::mpl::size_type = std::integral_constant<std::size_t,I> |
The size type used by this library.
using fcppt::mpl::set::symmetric_difference |
The symmetric difference of two sets.The result contains every element that is either in Set1 or in Set2, but not in both.
using fcppt::mpl::list::tail = typename fcppt::mpl::list::detail::tail<List>::type |
Removes the first element of a list.If List = list::object<L_1,...,L_n>
, where n >= 1
, then the result is.
using fcppt::mpl::list::take = typename fcppt::mpl::list::detail::take<List,std::make_index_sequence<S::value>>::type |
Keeps some elements of a list from the beginning.If List = list::object<L_1,...,L_n>
then the result is.
using fcppt::mpl::set::to_list = typename fcppt::mpl::set::detail::to_list<Set>::type |
Converts a set to a list.Let Set = set::object<E_1,...,E_n>
. The result is.
using fcppt::mpl::list::transpose = typename fcppt::mpl::list::detail::transpose<List>::type |
Transposes n lists of length k into k lists of length n.If.
then the result is
TODO(concepts)
using fcppt::mpl::set::union_ |
The union of two sets.The result contains every element that is in Set1 or in Set2.
using fcppt::mpl::set::unique = fcppt::mpl::list::distinct<fcppt::mpl::list::object<Args...>> |
Checks if a variadic list is pairwise disjoint.
|
inline |
Calls a runtime function for each element of a listing, possibly breaking out early.
Let List = list::object<L_1,...,L_n>
. Calls r_1 = _function(fcppt::tag<L_1>{})
. If r_1 == fcppt::loop::break_
, the algorithm stops. If r_1 == fcppt::loop::continue_
, then r_2 = _function(fcppt::tag<L_2>{})
and so on, up to r_n = _function(fcppt::tag<L_n>{})
.
TODO(concepts)
FCPPT_PP_PUSH_WARNING std::invoke_result_t< FailFunction > fcppt::mpl::list::invoke_on | ( | std::size_t const | _index, |
Function const & | _function, | ||
FailFunction const & | _fail_function ) |
Applies a function to the nth element of an mpl::list::object with a runtime index.
Let List = list::object<L_1,...,L_n>
. If _index < n
the result is _function(fcppt::tag<L_i>{})
. Otherwise, the result is _fail_function()
.
Function | Must be callable as R fcppt::tag<T>() for every T in List , where R is the result type. |
FailFunction | Must be a callable as R () , where R is the result tye. |
TODO(concepts)
std::basic_ostream< Ch, Traits > & fcppt::mpl::list::operator<< | ( | std::basic_ostream< Ch, Traits > & | _stream, |
fcppt::mpl::list::object< Types... > const & | ) |
Prints a list.Prints List to _stream. Every type in List will be converted to a string using fcppt::type_name.
|
inlineconstexpr |
Checks if a predicate holds for all types of a list.
|
inlineconstexpr |
Checks if a predicate holds for any type of a list.
|
inlineconstexpr |
Calls a lambda.
|
inlineconstexpr |
Calls a lambda using a list of arguments.
|
inlineconstexpr |
Checks if a list contains an element.
|
inlineconstexpr |
Checks if a set contains an element.
|
inlineconstexpr |
Checks if all elements of a list are pairwise disjoint.
|
inlineconstexpr |
Checks if a list is empty.
|
inlineconstexpr |
Checks if two maps are equal.
|
inlineconstexpr |
Checks if two sets are equal.
|
inlineconstexpr |
Checks if a map contains a key.
|
inlineconstexpr |
Checks if a function can be invoked with a given argument list.