1
0
forked from boostorg/mp11
Files
boost_mp11/doc/mp11/list.qbk

130 lines
4.5 KiB
Plaintext
Raw Normal View History

2017-03-14 22:57:07 +02:00
[/
/ Copyright 2017 Peter Dimov
/
/ Distributed under the Boost Software License, Version 1.0. (See
/ accompanying file LICENSE_1_0.txt or copy at
/ http://www.boost.org/LICENSE_1_0.txt)
/]
[section:list List Operations, `<boost/mp11/list.hpp>`]
[section `mp_list<T...>`]
template<class... T> struct mp_list {};
`mp_list` is the standard list type of Mp11, although the library is not restricted to it and can operate on arbitrary class templates
such as `std::tuple` or `std::variant`. Even `std::pair` can be used if the transformation does not alter the number of the elements in
the list.
[endsect]
[section `mp_size<L>`]
template<class L> using mp_size = /*...*/;
`mp_size<L>` returns the number of elements in the list `L`, as a `mp_size_t`. In other words, `mp_size<L<T...>>` is an alias for
`mp_size_t<sizeof...(T)>`.
[endsect]
[section `mp_empty<L>`]
template<class L> using mp_empty = mp_bool<mp_size<L>::value == 0>;
`mp_empty<L>` is an alias for `mp_true` if the list `L` is empty, for `mp_false` otherwise.
[endsect]
[section `mp_front<L>`]
template<class L> using mp_front = /*...*/;
`mp_front<L>` is the first element of the list `L`. That is, `mp_front<L<T1, T...>>` is an alias for `T1`.
[endsect]
[section `mp_pop_front<L>`]
template<class L> using mp_pop_front = /*...*/;
`mp_pop_front<L>` removes the first element of the list `L`. That is, `mp_pop_front<L<T1, T...>>` is an alias for `L<T...>`.
[endsect]
[section `mp_first<L>`]
template<class L> using mp_first = mp_front<L>;
`mp_first` is another name for `mp_front`.
[endsect]
[section `mp_rest<L>`]
template<class L> using mp_rest = mp_pop_front<L>;
`mp_rest` is another name for `mp_pop_front`.
[endsect]
[section `mp_second<L>`]
template<class L> using mp_second = /*...*/;
`mp_second<L>` is the second element of the list `L`. That is, `mp_second<L<T1, T2, T...>>` is an alias for `T2`.
[endsect]
[section `mp_third<L>`]
template<class L> using mp_third = /*...*/;
`mp_third<L>` is the third element of the list `L`. That is, `mp_third<L<T1, T2, T3, T...>>` is an alias for `T3`.
[endsect]
[section `mp_push_front<L, T...>`]
template<class L, class... T> using mp_push_front = /*...*/;
`mp_push_front<L, T...>` inserts the elements `T...` at the front of the list `L`. That is, `mp_push_front<L<U...>, T...>`
is an alias for `L<T..., U...>`.
[endsect]
[section `mp_push_back<L, T...>`]
template<class L, class... T> using mp_push_back = /*...*/;
`mp_push_back<L, T...>` inserts the elements `T...` at the back of the list `L`. That is, `mp_push_back<L<U...>, T...>`
is an alias for `L<U..., T...>`.
[endsect]
[section `mp_rename<L, Y>`]
template<class L, template<class...> class Y> using mp_rename = /*...*/;
`mp_rename<L, Y>` changes the type of the list `L` to `Y`. That is, `mp_rename<L<T...>, Y>` is an alias for `Y<T...>`.
[endsect]
2017-03-24 14:26:31 +02:00
[section `mp_apply<F, L>`]
template<template<class...> class F, class L> using mp_apply = mp_rename<L, F>;
2017-03-25 03:02:59 +02:00
`mp_apply<F, L>` applies the metafunction `F` to the contents of the list `L`, that is, `mp_rename<F, L<T...>>` is an alias for `F<T...>`.
2017-03-24 14:26:31 +02:00
(`mp_apply` is the same as `mp_rename` with the arguments reversed.)
[endsect]
2017-03-14 22:57:07 +02:00
[section `mp_append<L...>`]
template<class... L> using mp_append = /*...*/;
`mp_append<L...>` concatenates the lists in `L...` into a single list that has the same type as the first list. `mp_append<>`
is an alias for `mp_list<>`. `mp_append<L1<T1...>, L2<T2...>, ..., Ln<Tn...>>` is an alias for `L1<T1..., T2..., ..., Tn...>`.
[endsect]
2017-03-18 20:36:58 +02:00
[section `mp_replace_front<L, T>`]
template<class L, class T> using mp_replace_front = /*...*/;
`mp_replace_front<L, T>` replaces the first element of the list `L` with `T`. That is, `mp_replace_front<L<U1, U...>, T>` is
an alias for `L<T, U...>`.
[endsect]
[section `mp_replace_first<L, T>`]
template<class L, class T> using mp_replace_first = mp_replace_front<L, T>;
`mp_replace_first` is another name for `mp_replace_front`.
[endsect]
[section `mp_replace_second<L, T>`]
template<class L, class T> using mp_replace_second = /*...*/;
`mp_replace_second<L, T>` replaces the second element of the list `L` with `T`. That is, `mp_replace_second<L<U1, U2, U...>, T>`
is an alias for `L<U1, T, U...>`.
[endsect]
[section `mp_replace_third<L, T>`]
template<class L, class T> using mp_replace_third = /*...*/;
`mp_replace_third<L, T>` replaces the third element of the list `L` with `T`. That is, `mp_replace_third<L<U1, U2, U3, U...>, T>`
is an alias for `L<U1, U2, T, U...>`.
[endsect]
2017-03-14 22:57:07 +02:00
[endsect]