diff --git a/doc/html/mp11.html b/doc/html/mp11.html
index 6489b42..1945ad0 100644
--- a/doc/html/mp11.html
+++ b/doc/html/mp11.html
@@ -134,6 +134,25 @@
mp_map_update<M, T, F>
mp_map_erase<M, K>
+Helper Metafunctions, <boost/mp11/function.hpp>
+
+mp_and<T...>
+mp_all<T...>
+mp_or<T...>
+mp_any<T...>
+
+Integer Sequences,
+ <boost/integer_sequence.hpp>
+
+integer_sequence<T, I...>
+make_integer_sequence<T, N>
+index_sequence<I...>
+make_index_sequence<N>
+index_sequence_for<T...>
+
+A "for each"
+ algorithm for tuple-like types, <boost/tuple_for_each.hpp>
+tuple_for_each
@@ -142,17 +161,54 @@
Overview
- ...
+ Mp11 is a C++11 metaprogramming library based on template aliases and variadic
+ templates. It implements the approach outlined in the article Simple
+ C++11 metaprogramming (part
+ 2).
+
+
+ The general principles upon which Mp11 is built are that algorithms and metafunctions
+ are template aliases of the form F<T...>
+ and data structures are lists of the form L<T...>
,
+ with the library placing no requirements on L
.
+ mp_list<T...>
+ is the built-in list type, but std::tuple<T...>
,
+ std::pair<T1, T2>
and std::variant<T...>
+ are also perfectly legitimate list types, although of course std:pair<T1,
+ T2>
,
+ due to having exactly two elements, is not resizeable and will consequently
+ not work with algorithms that need to add or remove elements.
+
+
+ Another distinguishing feature of this approach is that lists (L<T...>
) have the same form as metafunctions
+ (F<T...>
)
+ and can therefore be used as such. For example, applying std::add_pointer_t
+ to the list std::tuple<int, float>
by way of mp_transform<std::tuple<int, float>, std::add_pointer_t>
gives us std::tuple<int*, float*>
, but we can also apply mp_list
+ to the same tuple:
+
+using R = mp_transform<std::tuple<int, float>, mp_list>;
+
+
+ and get std::tuple<mp_list<int>, mp_list<float>>
.
+
+ The contents of the library are in namespace boost::mp11
, unless
+ specified otherwise.
+
+
+ For an Mp11 integral constant type T
,
+ T::value
is an integral constant in the C++
+ sense.
+
+
+
+
+
+
template<class... T> using mp_and = ;
+
+
+ mp_and<T...>
+ is an alias for the first type U
+ in T...
+ for which mp_to_bool<U>
+ is mp_false
. If no such
+ type exists, the last one is returned. mp_and<>
is mp_true
.
+ Similar to std::conjunction
in C++17.
+
+
+
+
+
template<class... T> using mp_all = ;
+
+
+ mp_all<T...>
+ is mp_true
if mp_to_bool<U>
+ is mp_true
for all types
+ U
in T...
, mp_false
+ otherwise. Same as mp_and
,
+ but does not perform short-circuit evaluation. mp_and<mp_false, void>
+ is mp_false
, but mp_all<mp_false, void>
+ is an error because void
does
+ not have a nested value
.
+ The upside is that mp_all
+ is faster.
+
+
+
+
+
template<class... T> using mp_or = ;
+
+
+ mp_or<T...>
+ is an alias for the first type U
+ in T...
+ for which mp_to_bool<U>
+ is mp_true
. If no such
+ type exists, the last one is returned. mp_or<>
is mp_false
.
+ Similar to std::disjunction
in C++17.
+
+
+
+
+
template<class... T> using mp_any = ;
+
+
+ mp_any<T...>
+ is mp_true
if mp_to_bool<U>
+ is mp_true
for any type
+ U
in T...
, mp_false
+ otherwise. Same as mp_or
,
+ but does not perform short-circuit evaluation.
+
+
+
+
+
+
+ The contents of this header are defined in namespace boost
.
+
+
+
+
template<class T, T... I> struct integer_sequence
+{
+};
+
+
+ integer_sequence<T, I...>
holds a sequence of integers of
+ type T
. Same as C++14's
+ std::integer_sequence
.
+
+
+
+
+
template<class T, T N> using make_integer_sequence = ;
+
+
+ make_integer_sequence<T, N>
is integer_sequence<T, 0,
+ 1, ..., N-1>
.
+ Same as C++14's std::make_integer_sequence
.
+
+
+
+
+
template<std::size_t... I> using index_sequence = integer_sequence<std::size_t, I...>;
+
+
+ index_sequence<I...>
+ is an alias for integer_sequence<size_t, I...>
.
+ Same as C++14's std::index_sequence
.
+
+
+
+
+
template<std::size_t N> using make_index_sequence = make_integer_sequence<std::size_t, N>;
+
+
+ make_index_sequence<N>
+ is index_sequence<0, 1, ..., N-1>
. Same as C++14's std::make_index_sequence
.
+
+
+
+
+
template<class... T> using index_sequence_for = make_integer_sequence<std::size_t, sizeof...(T)>;
+
+
+ index_sequence_for<N>
+ is make_index_sequence<sizeof...(T)>
. Same as C++14's std::index_sequence_for
.
+
+
+
+
+
+
+ The contents of this header are defined in namespace boost
.
+
+
+
+
template<class Tp, class F> constexpr F tuple_for_each(Tp&& tp, F&& f);
+
+
+ tuple_for_each(tp, f)
applies
+ the function object f
to
+ each element of tp
by evaluating
+ the expression f(std::get<J>(std::forward<Tp>(tp)))
+ for J
in 0..N-1
,
+ where N
is std::tuple_size<std::remove_reference_t<Tp>>::value
.
+
+
+ Returns std::forward<F>(f)
.
+
+
+
-Last revised: March 15, 2017 at 18:15:15 GMT |
+Last revised: March 16, 2017 at 17:05:33 GMT |
|
diff --git a/doc/mp11.qbk b/doc/mp11.qbk
index 4b9795f..b28efa0 100644
--- a/doc/mp11.qbk
+++ b/doc/mp11.qbk
@@ -25,17 +25,22 @@
[section Overview]
-...
+[include mp11/overview.qbk]
[endsect]
[section Reference]
+The contents of the library are in namespace `boost::mp11`, unless specified otherwise.
+
[include mp11/integral.qbk]
[include mp11/list.qbk]
[include mp11/utility.qbk]
[include mp11/algorithm.qbk]
[include mp11/set.qbk]
[include mp11/map.qbk]
+[include mp11/function.qbk]
+[include mp11/integer_sequence.qbk]
+[include mp11/tuple_for_each.qbk]
[endsect]
diff --git a/doc/mp11/function.qbk b/doc/mp11/function.qbk
new file mode 100644
index 0000000..01948c2
--- /dev/null
+++ b/doc/mp11/function.qbk
@@ -0,0 +1,40 @@
+[/
+ / 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:function Helper Metafunctions, `
`]
+
+[section `mp_and`]
+ template using mp_and = /*...*/;
+
+`mp_and` is an alias for the first type `U` in `T...` for which `mp_to_bool` is `mp_false`.
+If no such type exists, the last one is returned. `mp_and<>` is `mp_true`. Similar to `std::conjunction` in C++17.
+[endsect]
+
+[section `mp_all`]
+ template using mp_all = /*...*/;
+
+`mp_all` is `mp_true` if `mp_to_bool` is `mp_true` for all types `U` in `T...`, `mp_false` otherwise. Same as
+`mp_and`, but does not perform short-circuit evaluation. `mp_and` is `mp_false`, but `mp_all`
+is an error because `void` does not have a nested `value`. The upside is that `mp_all` is faster.
+[endsect]
+
+[section `mp_or`]
+ template using mp_or = /*...*/;
+
+`mp_or` is an alias for the first type `U` in `T...` for which `mp_to_bool` is `mp_true`.
+If no such type exists, the last one is returned. `mp_or<>` is `mp_false`. Similar to `std::disjunction` in C++17.
+[endsect]
+
+[section `mp_any`]
+ template using mp_any = /*...*/;
+
+`mp_any` is `mp_true` if `mp_to_bool` is `mp_true` for any type `U` in `T...`, `mp_false` otherwise. Same as
+`mp_or`, but does not perform short-circuit evaluation.
+[endsect]
+
+[endsect]
diff --git a/doc/mp11/integer_sequence.qbk b/doc/mp11/integer_sequence.qbk
new file mode 100644
index 0000000..e33df75
--- /dev/null
+++ b/doc/mp11/integer_sequence.qbk
@@ -0,0 +1,45 @@
+[/
+ / 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:integer_sequence Integer Sequences, ``]
+
+The contents of this header are defined in namespace `boost`.
+
+[section `integer_sequence`]
+ template struct integer_sequence
+ {
+ };
+
+`integer_sequence` holds a sequence of integers of type `T`. Same as C++14's `std::integer_sequence`.
+[endsect]
+
+[section `make_integer_sequence`]
+ template using make_integer_sequence = /*...*/;
+
+`make_integer_sequence` is `integer_sequence`. Same as C++14's `std::make_integer_sequence`.
+[endsect]
+
+[section `index_sequence`]
+ template using index_sequence = integer_sequence;
+
+`index_sequence` is an alias for `integer_sequence`. Same as C++14's `std::index_sequence`.
+[endsect]
+
+[section `make_index_sequence`]
+ template using make_index_sequence = make_integer_sequence;
+
+`make_index_sequence` is `index_sequence<0, 1, ..., N-1>`. Same as C++14's `std::make_index_sequence`.
+[endsect]
+
+[section `index_sequence_for`]
+ template using index_sequence_for = make_integer_sequence;
+
+`index_sequence_for` is `make_index_sequence`. Same as C++14's `std::index_sequence_for`.
+[endsect]
+
+[endsect]
diff --git a/doc/mp11/integral.qbk b/doc/mp11/integral.qbk
index 95f0260..77c45c8 100644
--- a/doc/mp11/integral.qbk
+++ b/doc/mp11/integral.qbk
@@ -8,6 +8,8 @@
[section:integral Integral Constants, ``]
+For an Mp11 integral constant type `T`, `T::value` is an integral constant in the C++ sense.
+
[section `mp_bool`]
template using mp_bool = std::integral_constant;
[endsect]
diff --git a/doc/mp11/overview.qbk b/doc/mp11/overview.qbk
new file mode 100644
index 0000000..89f7cff
--- /dev/null
+++ b/doc/mp11/overview.qbk
@@ -0,0 +1,29 @@
+[/
+ / 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)
+ /]
+
+Mp11 is a C++11 metaprogramming library based on template aliases and variadic templates.
+It implements the approach outlined in the article
+[@http://pdimov.com/cpp2/simple_cxx11_metaprogramming.html Simple C++11 metaprogramming]
+([@http://pdimov.com/cpp2/simple_cxx11_metaprogramming_2.html part 2]).
+
+The general principles upon which Mp11 is built are that algorithms and metafunctions are
+template aliases of the form `F` and data structures are lists of the form `L`,
+with the library placing no requirements on `L`. `mp_list` is the built-in list type,
+but `std::tuple`, `std::pair` and `std::variant` are also perfectly
+legitimate list types, although of course `std:pair`, due to having exactly two elements,
+is not resizeable and will consequently not work with algorithms that need to add or remove
+elements.
+
+Another distinguishing feature of this approach is that lists (`L`) have the same form as
+metafunctions (`F`) and can therefore be used as such. For example, applying `std::add_pointer_t`
+to the list `std::tuple` by way of `mp_transform, std::add_pointer_t>`
+gives us `std::tuple`, but we can also apply `mp_list` to the same tuple:
+
+ using R = mp_transform, mp_list>;
+
+and get `std::tuple, mp_list>`.
diff --git a/doc/mp11/tuple_for_each.qbk b/doc/mp11/tuple_for_each.qbk
new file mode 100644
index 0000000..bfdf767
--- /dev/null
+++ b/doc/mp11/tuple_for_each.qbk
@@ -0,0 +1,22 @@
+[/
+ / 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:tuple_for_each A "for each" algorithm for tuple-like types, ``]
+
+The contents of this header are defined in namespace `boost`.
+
+[section `tuple_for_each`]
+ template constexpr F tuple_for_each(Tp&& tp, F&& f);
+
+`tuple_for_each(tp, f)` applies the function object `f` to each element of `tp` by evaluating the
+expression `f(std::get(std::forward(tp)))` for `J` in 0..`N-1`, where `N` is `std::tuple_size>::value`.
+
+Returns `std::forward(f)`.
+[endsect]
+
+[endsect]