forked from boostorg/mp11
Move mp_assign, mp_clear from algorithm to list
This commit is contained in:
@ -13,50 +13,6 @@ http://www.boost.org/LICENSE_1_0.txt
|
||||
:toc-title:
|
||||
:idprefix:
|
||||
|
||||
## mp_assign<L1, L2>
|
||||
|
||||
template<class L1, class L2> using mp_assign = /*...*/;
|
||||
|
||||
`mp_assign<L1<T1...>, L2<T2...>>` is an alias for `L1<T2...>`. That is, it replaces the elements of `L1` with those of `L2`.
|
||||
|
||||
.Using mp_assign with mp_list and std::tuple
|
||||
```
|
||||
using L1 = std::tuple<long>;
|
||||
using L2 = mp_list<int, float>;
|
||||
|
||||
using R1 = mp_assign<L1, L2>; // std::tuple<int, float>
|
||||
```
|
||||
|
||||
.Using mp_assign with mp_list and std::pair
|
||||
```
|
||||
using L1 = std::pair<long, char>;
|
||||
using L2 = mp_list<int, float>;
|
||||
|
||||
using R1 = mp_assign<L1, L2>; // std::pair<int, float>
|
||||
```
|
||||
|
||||
.mp_assign
|
||||
[cols="<.^4m,4*^.^1m",width=85%]
|
||||
|===
|
||||
|*L1*|A~1~|A~2~|...|A~n~
|
||||
5+|
|
||||
|*L2*|B~1~|B~2~|...|B~n~
|
||||
5+|
|
||||
|*mp_assign<L1, L2>*|B~1~|B~2~|...|B~n~
|
||||
|===
|
||||
|
||||
## mp_clear<L>
|
||||
|
||||
template<class L> using mp_clear = mp_assign<L, mp_list<>>;
|
||||
|
||||
`mp_clear<L<T...>>` is an alias for `L<>`, that is, it removes the elements of `L`.
|
||||
|
||||
.Using mp_clear with std::tuple
|
||||
```
|
||||
using L1 = std::tuple<int, float>;
|
||||
using R1 = mp_clear<L1>; // std::tuple<>
|
||||
```
|
||||
|
||||
## mp_transform<F, L...>
|
||||
|
||||
template<template<class...> class F, class... L> using mp_transform = /*...*/;
|
||||
|
@ -79,6 +79,40 @@ using L2 = std::tuple<>;
|
||||
using R2 = mp_empty<L2>; // mp_true
|
||||
```
|
||||
|
||||
## mp_assign<L1, L2>
|
||||
|
||||
template<class L1, class L2> using mp_assign = /*...*/;
|
||||
|
||||
`mp_assign<L1<T1...>, L2<T2...>>` is an alias for `L1<T2...>`. That is, it replaces the elements of `L1` with those of `L2`.
|
||||
|
||||
.Using mp_assign with mp_list and std::tuple
|
||||
```
|
||||
using L1 = std::tuple<long>;
|
||||
using L2 = mp_list<int, float>;
|
||||
|
||||
using R1 = mp_assign<L1, L2>; // std::tuple<int, float>
|
||||
```
|
||||
|
||||
.Using mp_assign with mp_list and std::pair
|
||||
```
|
||||
using L1 = std::pair<long, char>;
|
||||
using L2 = mp_list<int, float>;
|
||||
|
||||
using R1 = mp_assign<L1, L2>; // std::pair<int, float>
|
||||
```
|
||||
|
||||
## mp_clear<L>
|
||||
|
||||
template<class L> using mp_clear = mp_assign<L, mp_list<>>;
|
||||
|
||||
`mp_clear<L<T...>>` is an alias for `L<>`, that is, it removes the elements of `L`.
|
||||
|
||||
.Using mp_clear with std::tuple
|
||||
```
|
||||
using L1 = std::tuple<int, float>;
|
||||
using R1 = mp_clear<L1>; // std::tuple<>
|
||||
```
|
||||
|
||||
## mp_front<L>
|
||||
|
||||
template<class L> using mp_front = /*...*/;
|
||||
|
@ -29,24 +29,6 @@ namespace boost
|
||||
namespace mp11
|
||||
{
|
||||
|
||||
// mp_assign<L1, L2>
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class L1, class L2> struct mp_assign_impl;
|
||||
|
||||
template<template<class...> class L1, class... T, template<class...> class L2, class... U> struct mp_assign_impl<L1<T...>, L2<U...>>
|
||||
{
|
||||
using type = L1<U...>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class L1, class L2> using mp_assign = typename detail::mp_assign_impl<L1, L2>::type;
|
||||
|
||||
// mp_clear<L>
|
||||
template<class L> using mp_clear = mp_assign<L, mp_list<>>;
|
||||
|
||||
// mp_fold<L, V, F> forward declaration
|
||||
namespace detail
|
||||
{
|
||||
|
@ -62,6 +62,24 @@ template<class L> using mp_size = typename detail::mp_size_impl<L>::type;
|
||||
// mp_empty<L>
|
||||
template<class L> using mp_empty = mp_bool< mp_size<L>::value == 0 >;
|
||||
|
||||
// mp_assign<L1, L2>
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class L1, class L2> struct mp_assign_impl;
|
||||
|
||||
template<template<class...> class L1, class... T, template<class...> class L2, class... U> struct mp_assign_impl<L1<T...>, L2<U...>>
|
||||
{
|
||||
using type = L1<U...>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class L1, class L2> using mp_assign = typename detail::mp_assign_impl<L1, L2>::type;
|
||||
|
||||
// mp_clear<L>
|
||||
template<class L> using mp_clear = mp_assign<L, mp_list<>>;
|
||||
|
||||
// mp_front<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.
|
||||
//
|
||||
@ -7,9 +7,8 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <boost/mp11/algorithm.hpp>
|
||||
#include <boost/mp11/list.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <type_traits>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2015 Peter Dimov.
|
||||
// Copyright 2015, 2017 Peter Dimov.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
@ -7,12 +7,10 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <boost/mp11/algorithm.hpp>
|
||||
#include <boost/mp11/list.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <type_traits>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
int main()
|
||||
{
|
||||
|
Reference in New Issue
Block a user