forked from boostorg/mp11
Add mp_apply as an alias for mp_rename
This commit is contained in:
@@ -68,6 +68,8 @@
|
||||
<dt><span class="section"><a href="mp11.html#mp11.reference.list.mp_push_back_l_t"><code class="computeroutput"><span class="identifier">mp_push_back</span><span class="special"><</span><span class="identifier">L</span><span class="special">,</span> <span class="identifier">T</span><span class="special">...></span></code></a></span></dt>
|
||||
<dt><span class="section"><a href="mp11.html#mp11.reference.list.mp_rename_l_y"><code class="computeroutput"><span class="identifier">mp_rename</span><span class="special"><</span><span class="identifier">L</span><span class="special">,</span>
|
||||
<span class="identifier">Y</span><span class="special">></span></code></a></span></dt>
|
||||
<dt><span class="section"><a href="mp11.html#mp11.reference.list.mp_apply_f_l"><code class="computeroutput"><span class="identifier">mp_apply</span><span class="special"><</span><span class="identifier">F</span><span class="special">,</span>
|
||||
<span class="identifier">L</span><span class="special">></span></code></a></span></dt>
|
||||
<dt><span class="section"><a href="mp11.html#mp11.reference.list.mp_append_l"><code class="computeroutput"><span class="identifier">mp_append</span><span class="special"><</span><span class="identifier">L</span><span class="special">...></span></code></a></span></dt>
|
||||
<dt><span class="section"><a href="mp11.html#mp11.reference.list.mp_replace_front_l_t"><code class="computeroutput"><span class="identifier">mp_replace_front</span><span class="special"><</span><span class="identifier">L</span><span class="special">,</span> <span class="identifier">T</span><span class="special">></span></code></a></span></dt>
|
||||
<dt><span class="section"><a href="mp11.html#mp11.reference.list.mp_replace_first_l_t"><code class="computeroutput"><span class="identifier">mp_replace_first</span><span class="special"><</span><span class="identifier">L</span><span class="special">,</span> <span class="identifier">T</span><span class="special">></span></code></a></span></dt>
|
||||
@@ -699,6 +701,21 @@
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="mp11.reference.list.mp_apply_f_l"></a><a class="link" href="mp11.html#mp11.reference.list.mp_apply_f_l" title="mp_apply<F, L>"><code class="computeroutput"><span class="identifier">mp_apply</span><span class="special"><</span><span class="identifier">F</span><span class="special">,</span>
|
||||
<span class="identifier">L</span><span class="special">></span></code></a>
|
||||
</h4></div></div></div>
|
||||
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...></span> <span class="keyword">class</span> <span class="identifier">F</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">L</span><span class="special">></span> <span class="keyword">using</span> <span class="identifier">mp_apply</span> <span class="special">=</span> <span class="identifier">mp_rename</span><span class="special"><</span><span class="identifier">L</span><span class="special">,</span> <span class="identifier">F</span><span class="special">>;</span>
|
||||
</pre>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">mp_apply</span><span class="special"><</span><span class="identifier">F</span><span class="special">,</span> <span class="identifier">L</span><span class="special">></span></code> applies the function <code class="computeroutput"><span class="identifier">F</span></code> to the contents of the list <code class="computeroutput"><span class="identifier">L</span></code>, that is, <code class="computeroutput"><span class="identifier">mp_rename</span><span class="special"><</span><span class="identifier">F</span><span class="special">,</span> <span class="identifier">L</span><span class="special"><</span><span class="identifier">T</span><span class="special">...>></span></code>
|
||||
is an alias for <code class="computeroutput"><span class="identifier">F</span><span class="special"><</span><span class="identifier">T</span><span class="special">...></span></code>.
|
||||
(<code class="computeroutput"><span class="identifier">mp_apply</span></code> is the same as
|
||||
<code class="computeroutput"><span class="identifier">mp_rename</span></code> with the arguments
|
||||
reversed.)
|
||||
</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="mp11.reference.list.mp_append_l"></a><a class="link" href="mp11.html#mp11.reference.list.mp_append_l" title="mp_append<L...>"><code class="computeroutput"><span class="identifier">mp_append</span><span class="special"><</span><span class="identifier">L</span><span class="special">...></span></code></a>
|
||||
</h4></div></div></div>
|
||||
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> <span class="identifier">L</span><span class="special">></span> <span class="keyword">using</span> <span class="identifier">mp_append</span> <span class="special">=</span> <span class="comment">/*...*/</span><span class="special">;</span>
|
||||
@@ -1688,7 +1705,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"><p><small>Last revised: March 20, 2017 at 14:09:13 GMT</small></p></td>
|
||||
<td align="left"><p><small>Last revised: March 24, 2017 at 12:24:11 GMT</small></p></td>
|
||||
<td align="right"><div class="copyright-footer"></div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
|
@@ -85,6 +85,13 @@ is an alias for `L<U..., T...>`.
|
||||
`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]
|
||||
|
||||
[section `mp_apply<F, L>`]
|
||||
template<template<class...> class F, class L> using mp_apply = mp_rename<L, F>;
|
||||
|
||||
`mp_apply<F, L>` applies the function `F` to the contents of the list `L`, that is, `mp_rename<F, L<T...>>` is an alias for `F<T...>`.
|
||||
(`mp_apply` is the same as `mp_rename` with the arguments reversed.)
|
||||
[endsect]
|
||||
|
||||
[section `mp_append<L...>`]
|
||||
template<class... L> using mp_append = /*...*/;
|
||||
|
||||
|
@@ -147,6 +147,8 @@ template<template<class...> class A, class... T, template<class...> class B> str
|
||||
|
||||
template<class A, template<class...> class B> using mp_rename = typename detail::mp_rename_impl<A, B>::type;
|
||||
|
||||
template<template<class...> class F, class L> using mp_apply = typename detail::mp_rename_impl<L, F>::type;
|
||||
|
||||
// mp_append<L...>
|
||||
namespace detail
|
||||
{
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2015 Peter Dimov.
|
||||
// Copyright 2015-2017 Peter Dimov.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
@@ -20,68 +20,126 @@ int main()
|
||||
{
|
||||
using boost::mp11::mp_list;
|
||||
using boost::mp11::mp_rename;
|
||||
using boost::mp11::mp_apply;
|
||||
|
||||
using L1 = mp_list<>;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L1, mp_list>, mp_list<>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L1, std::tuple>, std::tuple<>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L1, X>, X<>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L1, Y>, Y<>>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L1>, mp_list<>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L1>, std::tuple<>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L1>, X<>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L1>, Y<>>));
|
||||
|
||||
using L2 = mp_list<char>;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L2, mp_list>, mp_list<char>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L2, std::tuple>, std::tuple<char>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L2, X>, X<char>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L2, Y>, Y<char>>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L2>, mp_list<char>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L2>, std::tuple<char>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L2>, X<char>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L2>, Y<char>>));
|
||||
|
||||
using L3 = mp_list<char, double>;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L3, mp_list>, mp_list<char, double>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L3, std::tuple>, std::tuple<char, double>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L3, X>, X<char, double>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L3, Y>, Y<char, double>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L3, std::pair>, std::pair<char, double>>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L3>, mp_list<char, double>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L3>, std::tuple<char, double>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L3>, X<char, double>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L3>, Y<char, double>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::pair, L3>, std::pair<char, double>>));
|
||||
|
||||
using L4 = mp_list<int, char, float>;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L4, mp_list>, mp_list<int, char, float>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L4, std::tuple>, std::tuple<int, char, float>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L4, X>, X<int, char, float>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L4, Y>, Y<int, char, float>>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L4>, mp_list<int, char, float>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L4>, std::tuple<int, char, float>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L4>, X<int, char, float>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L4>, Y<int, char, float>>));
|
||||
|
||||
//
|
||||
|
||||
using L5 = std::tuple<>;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L5, mp_list>, mp_list<>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L5, std::tuple>, std::tuple<>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L5, X>, X<>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L5, Y>, Y<>>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L5>, mp_list<>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L5>, std::tuple<>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L5>, X<>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L5>, Y<>>));
|
||||
|
||||
using L6 = std::tuple<char>;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L6, mp_list>, mp_list<char>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L6, std::tuple>, std::tuple<char>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L6, X>, X<char>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L6, Y>, Y<char>>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L6>, mp_list<char>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L6>, std::tuple<char>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L6>, X<char>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L6>, Y<char>>));
|
||||
|
||||
using L7 = std::tuple<char, double>;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L7, mp_list>, mp_list<char, double>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L7, std::tuple>, std::tuple<char, double>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L7, X>, X<char, double>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L7, Y>, Y<char, double>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L7, std::pair>, std::pair<char, double>>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L7>, mp_list<char, double>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L7>, std::tuple<char, double>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L7>, X<char, double>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L7>, Y<char, double>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::pair, L7>, std::pair<char, double>>));
|
||||
|
||||
using L8 = std::tuple<int, char, float>;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L8, mp_list>, mp_list<int, char, float>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L8, std::tuple>, std::tuple<int, char, float>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L8, X>, X<int, char, float>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L8, Y>, Y<int, char, float>>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L8>, mp_list<int, char, float>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L8>, std::tuple<int, char, float>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L8>, X<int, char, float>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L8>, Y<int, char, float>>));
|
||||
|
||||
//
|
||||
|
||||
using L9 = std::pair<char, double>;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L9, mp_list>, mp_list<char, double>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L9, std::tuple>, std::tuple<char, double>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L9, X>, X<char, double>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L9, Y>, Y<char, double>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L9, std::pair>, std::pair<char, double>>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L9>, mp_list<char, double>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L9>, std::tuple<char, double>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L9>, X<char, double>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L9>, Y<char, double>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::pair, L9>, std::pair<char, double>>));
|
||||
|
||||
//
|
||||
|
||||
return boost::report_errors();
|
||||
|
Reference in New Issue
Block a user