forked from boostorg/mp11
Merge branch 'develop'
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 = /*...*/;
|
||||
|
||||
|
@@ -189,17 +189,10 @@ template<class L> struct mp_repeat_c_impl<L, 1>
|
||||
using type = L;
|
||||
};
|
||||
|
||||
template<class L, class N> struct mp_repeat_impl
|
||||
{
|
||||
static_assert( N::value >= 0, "mp_repeat<L, N>: N must not be negative" );
|
||||
|
||||
using type = typename mp_repeat_c_impl<L, N::value>::type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class L, std::size_t N> using mp_repeat_c = typename detail::mp_repeat_c_impl<L, N>::type;
|
||||
template<class L, class N> using mp_repeat = typename detail::mp_repeat_impl<L, N>::type;
|
||||
template<class L, class N> using mp_repeat = typename detail::mp_repeat_c_impl<L, std::size_t{ N::value }>::type;
|
||||
|
||||
// mp_product<F, L...>
|
||||
namespace detail
|
||||
@@ -322,42 +315,27 @@ template<template<class...> class L, class T1, class T2, class T3, class T4, cla
|
||||
using type = mp_append<L<T1, T2, T3, T4, T5>, typename mp_take_c_impl<L<T...>, N-5>::type>;
|
||||
};
|
||||
|
||||
template<class L, class N> struct mp_take_impl
|
||||
{
|
||||
static_assert( N::value >= 0, "mp_take<L, N>: N must not be negative" );
|
||||
using type = typename mp_take_c_impl<L, N::value>::type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class L, std::size_t N> using mp_take_c = typename detail::mp_take_c_impl<L, N>::type;
|
||||
template<class L, class N> using mp_take = typename detail::mp_take_impl<L, N>::type;
|
||||
template<class L, class N> using mp_take = typename detail::mp_take_c_impl<L, std::size_t{ N::value }>::type;
|
||||
|
||||
// mp_replace<L, V, W>
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1800 )
|
||||
|
||||
template<class L, class V, class W> struct mp_replace_impl;
|
||||
|
||||
template<template<class...> class L, class... T, class V, class W> struct mp_replace_impl<L<T...>, V, W>
|
||||
{
|
||||
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1800 )
|
||||
template<class A> struct _f { using type = mp_if<std::is_same<A, V>, W, A>; };
|
||||
|
||||
using type = L<typename _f<T>::type...>;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
template<class L, class V, class W> struct mp_replace_impl
|
||||
{
|
||||
template<class A> using _f = mp_if<std::is_same<A, V>, W, A>;
|
||||
|
||||
using type = mp_transform<_f, L>;
|
||||
};
|
||||
|
||||
using type = L<_f<T>...>;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -367,11 +345,12 @@ template<class L, class V, class W> using mp_replace = typename detail::mp_repla
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class L, template<class...> class P, class W> struct mp_replace_if_impl
|
||||
{
|
||||
template<class T> using _f = mp_if<P<T>, W, T>;
|
||||
template<class L, template<class...> class P, class W> struct mp_replace_if_impl;
|
||||
|
||||
using type = mp_transform<_f, L>;
|
||||
template<template<class...> class L, class... T, template<class...> class P, class W> struct mp_replace_if_impl<L<T...>, P, W>
|
||||
{
|
||||
template<class U> using _f = mp_if<P<U>, W, U>;
|
||||
using type = L<_f<T>...>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
@@ -384,27 +363,15 @@ namespace detail
|
||||
|
||||
template<class L, template<class...> class P> struct mp_copy_if_impl;
|
||||
|
||||
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1800 )
|
||||
|
||||
template<template<class...> class L, class... T, template<class...> class P> struct mp_copy_if_impl<L<T...>, P>
|
||||
{
|
||||
static_assert( sizeof...(T) == 0, "T... must be empty" );
|
||||
using type = L<>;
|
||||
};
|
||||
|
||||
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1910 )
|
||||
template<class U> struct _f { using type = mp_if<P<U>, mp_list<U>, mp_list<>>; };
|
||||
using type = mp_append<L<>, typename _f<T>::type...>;
|
||||
#else
|
||||
|
||||
template<template<class...> class L, template<class...> class P> struct mp_copy_if_impl<L<>, P>
|
||||
{
|
||||
using type = L<>;
|
||||
};
|
||||
|
||||
template<class U> using _f = mp_if<P<U>, mp_list<U>, mp_list<>>;
|
||||
using type = mp_append<L<>, _f<T>...>;
|
||||
#endif
|
||||
|
||||
template<template<class...> class L, class T1, class... T, template<class...> class P> struct mp_copy_if_impl<L<T1, T...>, P>
|
||||
{
|
||||
using rest = typename mp_copy_if_impl<L<T...>, P>::type;
|
||||
using type = mp_if<P<T1>, mp_push_front<rest, T1>, rest>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
@@ -417,32 +384,15 @@ namespace detail
|
||||
|
||||
template<class L, class V> struct mp_remove_impl;
|
||||
|
||||
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1800 )
|
||||
|
||||
template<template<class...> class L, class... T, class V> struct mp_remove_impl<L<T...>, V>
|
||||
{
|
||||
static_assert( sizeof...(T) == 0, "T... must be empty" );
|
||||
using type = L<>;
|
||||
};
|
||||
|
||||
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1910 )
|
||||
template<class U> struct _f { using type = mp_if<std::is_same<U, V>, mp_list<>, mp_list<U>>; };
|
||||
using type = mp_append<L<>, typename _f<T>::type...>;
|
||||
#else
|
||||
|
||||
template<template<class...> class L, class V> struct mp_remove_impl<L<>, V>
|
||||
{
|
||||
using type = L<>;
|
||||
};
|
||||
|
||||
template<class U> using _f = mp_if<std::is_same<U, V>, mp_list<>, mp_list<U>>;
|
||||
using type = mp_append<L<>, _f<T>...>;
|
||||
#endif
|
||||
|
||||
template<template<class...> class L, class T1, class... T> struct mp_remove_impl<L<T1, T...>, T1>
|
||||
{
|
||||
using type = typename mp_remove_impl<L<T...>, T1>::type;
|
||||
};
|
||||
|
||||
template<template<class...> class L, class T1, class... T, class V> struct mp_remove_impl<L<T1, T...>, V>
|
||||
{
|
||||
using rest = typename mp_remove_impl<L<T...>, V>::type;
|
||||
using type = mp_push_front<rest, T1>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
@@ -455,27 +405,15 @@ namespace detail
|
||||
|
||||
template<class L, template<class...> class P> struct mp_remove_if_impl;
|
||||
|
||||
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1800 )
|
||||
|
||||
template<template<class...> class L, class... T, template<class...> class P> struct mp_remove_if_impl<L<T...>, P>
|
||||
{
|
||||
static_assert( sizeof...(T) == 0, "T... must be empty" );
|
||||
using type = L<>;
|
||||
};
|
||||
|
||||
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1910 )
|
||||
template<class U> struct _f { using type = mp_if<P<U>, mp_list<>, mp_list<U>>; };
|
||||
using type = mp_append<L<>, typename _f<T>::type...>;
|
||||
#else
|
||||
|
||||
template<template<class...> class L, template<class...> class P> struct mp_remove_if_impl<L<>, P>
|
||||
{
|
||||
using type = L<>;
|
||||
};
|
||||
|
||||
template<class U> using _f = mp_if<P<U>, mp_list<>, mp_list<U>>;
|
||||
using type = mp_append<L<>, _f<T>...>;
|
||||
#endif
|
||||
|
||||
template<template<class...> class L, class T1, class... T, template<class...> class P> struct mp_remove_if_impl<L<T1, T...>, P>
|
||||
{
|
||||
using rest = typename mp_remove_if_impl<L<T...>, P>::type;
|
||||
using type = mp_if<P<T1>, rest, mp_push_front<rest, T1>>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
@@ -488,27 +426,9 @@ namespace detail
|
||||
|
||||
template<class L, template<class...> class P> struct mp_partition_impl;
|
||||
|
||||
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1800 )
|
||||
|
||||
template<template<class...> class L, class... T, template<class...> class P> struct mp_partition_impl<L<T...>, P>
|
||||
{
|
||||
static_assert( sizeof...(T) == 0, "T... must be empty" );
|
||||
using type = L<L<>, L<>>;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
template<template<class...> class L, template<class...> class P> struct mp_partition_impl<L<>, P>
|
||||
{
|
||||
using type = L<L<>, L<>>;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
template<template<class...> class L, class T1, class... T, template<class...> class P> struct mp_partition_impl<L<T1, T...>, P>
|
||||
{
|
||||
using rest = typename mp_partition_impl<L<T...>, P>::type;
|
||||
using type = mp_if<P<T1>, L<mp_push_front<mp_first<rest>, T1>, mp_second<rest>>, L<mp_first<rest>, mp_push_front<mp_second<rest>, T1>>>;
|
||||
using type = L<mp_copy_if<L<T...>, P>, mp_remove_if<L<T...>, P>>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
@@ -760,9 +680,29 @@ template<template<class...> class L, class T1, class T2, class T3, class T4, cla
|
||||
using type = L<T5, T4, T3, T2, T1>;
|
||||
};
|
||||
|
||||
template<template<class...> class L, class T1, class T2, class T3, class T4, class T5, class T6, class... T> struct mp_reverse_impl<L<T1, T2, T3, T4, T5, T6, T...>>
|
||||
template<template<class...> class L, class T1, class T2, class T3, class T4, class T5, class T6> struct mp_reverse_impl<L<T1, T2, T3, T4, T5, T6>>
|
||||
{
|
||||
using type = mp_push_back<typename mp_reverse_impl<L<T...>>::type, T6, T5, T4, T3, T2, T1>;
|
||||
using type = L<T6, T5, T4, T3, T2, T1>;
|
||||
};
|
||||
|
||||
template<template<class...> class L, class T1, class T2, class T3, class T4, class T5, class T6, class T7> struct mp_reverse_impl<L<T1, T2, T3, T4, T5, T6, T7>>
|
||||
{
|
||||
using type = L<T7, T6, T5, T4, T3, T2, T1>;
|
||||
};
|
||||
|
||||
template<template<class...> class L, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8> struct mp_reverse_impl<L<T1, T2, T3, T4, T5, T6, T7, T8>>
|
||||
{
|
||||
using type = L<T8, T7, T6, T5, T4, T3, T2, T1>;
|
||||
};
|
||||
|
||||
template<template<class...> class L, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9> struct mp_reverse_impl<L<T1, T2, T3, T4, T5, T6, T7, T8, T9>>
|
||||
{
|
||||
using type = L<T9, T8, T7, T6, T5, T4, T3, T2, T1>;
|
||||
};
|
||||
|
||||
template<template<class...> class L, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class... T> struct mp_reverse_impl<L<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T...>>
|
||||
{
|
||||
using type = mp_push_back<typename mp_reverse_impl<L<T...>>::type, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
@@ -797,6 +737,11 @@ template<template<class...> class L, class T1, class... T, class V, template<cla
|
||||
using type = typename mp_fold_impl<L<T...>, F<V, T1>, F>::type;
|
||||
};
|
||||
|
||||
template<template<class...> class L, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class... T, class V, template<class...> class F> struct mp_fold_impl<L<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T...>, V, F>
|
||||
{
|
||||
using type = typename mp_fold_impl<L<T...>, F<F<F<F<F<F<F<F<F<F<V, T1>, T2>, T3>, T4>, T5>, T6>, T7>, T8>, T9>, T10>, F>::type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class L, class V, template<class...> class F> using mp_fold = typename detail::mp_fold_impl<L, V, F>::type;
|
||||
@@ -830,6 +775,12 @@ template<template<class...> class L, class T1, class... T, class V, template<cla
|
||||
using type = F<T1, rest>;
|
||||
};
|
||||
|
||||
template<template<class...> class L, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class... T, class V, template<class...> class F> struct mp_reverse_fold_impl<L<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T...>, V, F>
|
||||
{
|
||||
using rest = typename mp_reverse_fold_impl<L<T...>, V, F>::type;
|
||||
using type = F<T1, F<T2, F<T3, F<T4, F<T5, F<T6, F<T7, F<T8, F<T9, F<T10, rest>>>>>>>>>>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class L, class V, template<class...> class F> using mp_reverse_fold = typename detail::mp_reverse_fold_impl<L, V, F>::type;
|
||||
|
@@ -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.
|
||||
//
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <boost/mp11/algorithm.hpp>
|
||||
#include <boost/mp11/list.hpp>
|
||||
#include <boost/mp11/integral.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <type_traits>
|
||||
#include <tuple>
|
||||
@@ -17,6 +18,10 @@ struct X1 {};
|
||||
struct X2 {};
|
||||
struct X3 {};
|
||||
|
||||
using boost::mp11::mp_bool;
|
||||
|
||||
template<class N> using is_even = mp_bool<N::value % 2 == 0>;
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::mp11::mp_list;
|
||||
@@ -46,5 +51,17 @@ int main()
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_copy_if<L2, std::is_pointer>, std::tuple<X1*, X2*, X3*>>));
|
||||
}
|
||||
|
||||
using boost::mp11::mp_iota_c;
|
||||
using boost::mp11::mp_size_t;
|
||||
|
||||
{
|
||||
int const N = 12;
|
||||
using L1 = mp_iota_c<N>;
|
||||
|
||||
using R1 = mp_copy_if<L1, is_even>;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<R1, mp_list<mp_size_t<0>, mp_size_t<2>, mp_size_t<4>, mp_size_t<6>, mp_size_t<8>, mp_size_t<10>>>));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <boost/mp11/algorithm.hpp>
|
||||
#include <boost/mp11/list.hpp>
|
||||
#include <boost/mp11/integral.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <type_traits>
|
||||
#include <tuple>
|
||||
@@ -53,5 +54,25 @@ int main()
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold<std::tuple<X1, X2, X3, X4>, mp_list<>, mp_push_front>, mp_list<X4, X3, X2, X1>>));
|
||||
}
|
||||
|
||||
using boost::mp11::mp_iota_c;
|
||||
using boost::mp11::mp_reverse;
|
||||
using boost::mp11::mp_size_t;
|
||||
using boost::mp11::mp_plus;
|
||||
|
||||
{
|
||||
int const N = 37;
|
||||
|
||||
using L = mp_iota_c<N>;
|
||||
|
||||
using R1 = mp_fold<L, mp_list<>, mp_push_back>;
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<R1, L>));
|
||||
|
||||
using R2 = mp_fold<L, mp_list<>, mp_push_front>;
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<R2, mp_reverse<L>>));
|
||||
|
||||
using R3 = mp_fold<L, mp_size_t<0>, mp_plus>;
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<R3, mp_size_t<N*(N-1)/2>>));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2015 Peter Dimov.
|
||||
// Copyright 2015-2017 Peter Dimov.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <boost/mp11/algorithm.hpp>
|
||||
#include <boost/mp11/list.hpp>
|
||||
#include <boost/mp11/integral.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <type_traits>
|
||||
#include <tuple>
|
||||
@@ -17,6 +18,10 @@ struct X1 {};
|
||||
struct X2 {};
|
||||
struct X3 {};
|
||||
|
||||
using boost::mp11::mp_bool;
|
||||
|
||||
template<class N> using is_odd = mp_bool<N::value % 2 != 0>;
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::mp11::mp_list;
|
||||
@@ -46,5 +51,17 @@ int main()
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove_if<L2, std::is_pointer>, std::tuple<X1, X1 const, X2 const>>));
|
||||
}
|
||||
|
||||
using boost::mp11::mp_iota_c;
|
||||
using boost::mp11::mp_size_t;
|
||||
|
||||
{
|
||||
int const N = 12;
|
||||
using L1 = mp_iota_c<N>;
|
||||
|
||||
using R1 = mp_remove_if<L1, is_odd>;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<R1, mp_list<mp_size_t<0>, mp_size_t<2>, mp_size_t<4>, mp_size_t<6>, mp_size_t<8>, mp_size_t<10>>>));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@@ -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();
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2015 Peter Dimov.
|
||||
// Copyright 2015-2017 Peter Dimov.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <boost/mp11/algorithm.hpp>
|
||||
#include <boost/mp11/list.hpp>
|
||||
#include <boost/mp11/integral.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <type_traits>
|
||||
#include <tuple>
|
||||
@@ -22,6 +23,9 @@ struct X6 {};
|
||||
struct X7 {};
|
||||
struct X8 {};
|
||||
struct X9 {};
|
||||
struct X10 {};
|
||||
struct X11 {};
|
||||
struct X12 {};
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -39,6 +43,9 @@ int main()
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<mp_list<X1, X2, X3, X4, X5, X6, X7>>, mp_list<X7, X6, X5, X4, X3, X2, X1>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<mp_list<X1, X2, X3, X4, X5, X6, X7, X8>>, mp_list<X8, X7, X6, X5, X4, X3, X2, X1>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<mp_list<X1, X2, X3, X4, X5, X6, X7, X8, X9>>, mp_list<X9, X8, X7, X6, X5, X4, X3, X2, X1>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<mp_list<X1, X2, X3, X4, X5, X6, X7, X8, X9, X10>>, mp_list<X10, X9, X8, X7, X6, X5, X4, X3, X2, X1>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<mp_list<X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11>>, mp_list<X11, X10, X9, X8, X7, X6, X5, X4, X3, X2, X1>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<mp_list<X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12>>, mp_list<X12, X11, X10, X9, X8, X7, X6, X5, X4, X3, X2, X1>>));
|
||||
}
|
||||
|
||||
{
|
||||
@@ -52,11 +59,35 @@ int main()
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<std::tuple<X1, X2, X3, X4, X5, X6, X7>>, std::tuple<X7, X6, X5, X4, X3, X2, X1>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<std::tuple<X1, X2, X3, X4, X5, X6, X7, X8>>, std::tuple<X8, X7, X6, X5, X4, X3, X2, X1>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<std::tuple<X1, X2, X3, X4, X5, X6, X7, X8, X9>>, std::tuple<X9, X8, X7, X6, X5, X4, X3, X2, X1>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<std::tuple<X1, X2, X3, X4, X5, X6, X7, X8, X9, X10>>, std::tuple<X10, X9, X8, X7, X6, X5, X4, X3, X2, X1>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<std::tuple<X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11>>, std::tuple<X11, X10, X9, X8, X7, X6, X5, X4, X3, X2, X1>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<std::tuple<X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12>>, std::tuple<X12, X11, X10, X9, X8, X7, X6, X5, X4, X3, X2, X1>>));
|
||||
}
|
||||
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<std::pair<X1, X2>>, std::pair<X2, X1>>));
|
||||
}
|
||||
|
||||
using boost::mp11::mp_iota_c;
|
||||
using boost::mp11::mp_size_t;
|
||||
using boost::mp11::mp_transform;
|
||||
using boost::mp11::mp_plus;
|
||||
using boost::mp11::mp_fill;
|
||||
|
||||
{
|
||||
int const N = 37;
|
||||
|
||||
using L = mp_iota_c<N>;
|
||||
|
||||
using R1 = mp_reverse<L>;
|
||||
using R2 = mp_reverse<R1>;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<R2, L>));
|
||||
|
||||
using R3 = mp_transform<mp_plus, R1, R2>;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<R3, mp_fill<L, mp_size_t<N-1>>>));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2015 Peter Dimov.
|
||||
// Copyright 2015-2017 Peter Dimov.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <boost/mp11/algorithm.hpp>
|
||||
#include <boost/mp11/list.hpp>
|
||||
#include <boost/mp11/integral.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <type_traits>
|
||||
#include <tuple>
|
||||
@@ -55,5 +56,25 @@ int main()
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold<std::tuple<X1, X2, X3, X4>, mp_list<>, rev_push_front>, mp_list<X1, X2, X3, X4>>));
|
||||
}
|
||||
|
||||
using boost::mp11::mp_iota_c;
|
||||
using boost::mp11::mp_reverse;
|
||||
using boost::mp11::mp_size_t;
|
||||
using boost::mp11::mp_plus;
|
||||
|
||||
{
|
||||
int const N = 37;
|
||||
|
||||
using L = mp_iota_c<N>;
|
||||
|
||||
using R1 = mp_reverse_fold<L, mp_list<>, rev_push_front>;
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<R1, L>));
|
||||
|
||||
using R2 = mp_reverse_fold<L, mp_list<>, rev_push_back>;
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<R2, mp_reverse<L>>));
|
||||
|
||||
using R3 = mp_reverse_fold<L, mp_size_t<0>, mp_plus>;
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<R3, mp_size_t<N*(N-1)/2>>));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2015 Peter Dimov.
|
||||
// Copyright 2015 Peter Dimov.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
@@ -27,7 +27,7 @@ template<class T> using add_extents = T[];
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::mp11::mp_valid;
|
||||
using boost::mp11::mp_valid;
|
||||
using boost::mp11::mp_identity;
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_identity>));
|
||||
@@ -49,7 +49,7 @@ int main()
|
||||
BOOST_TEST_TRAIT_FALSE((mp_valid<add_pointer, void, void>));
|
||||
|
||||
#if !defined( BOOST_GCC ) || !BOOST_WORKAROUND( BOOST_GCC, < 70000 )
|
||||
// g++ up to at least 6.2 doesn't like add_reference for some reason or other
|
||||
// g++ up to at least 6.3 doesn't like add_reference for some reason or other
|
||||
BOOST_TEST_TRAIT_FALSE((mp_valid<add_reference>));
|
||||
#if !defined( BOOST_MSVC ) || !BOOST_WORKAROUND( BOOST_MSVC, <= 1800 )
|
||||
// msvc-12.0 gives an internal error here
|
||||
|
Reference in New Issue
Block a user