1
0
forked from boostorg/mp11

Merge branch 'develop'

This commit is contained in:
Peter Dimov
2015-07-24 13:54:53 +03:00
11 changed files with 859 additions and 2 deletions

View File

@@ -9,6 +9,7 @@
// http://www.boost.org/LICENSE_1_0.txt // http://www.boost.org/LICENSE_1_0.txt
#include <boost/mp11/list.hpp> #include <boost/mp11/list.hpp>
#include <boost/mp11/set.hpp>
#include <boost/mp11/integral.hpp> #include <boost/mp11/integral.hpp>
#include <boost/mp11/utility.hpp> #include <boost/mp11/utility.hpp>
#include <boost/mp11/detail/mp_plus.hpp> #include <boost/mp11/detail/mp_plus.hpp>
@@ -387,6 +388,44 @@ template<template<class...> class L, class T1, class... T, template<class...> cl
template<class L, template<class...> class P> using mp_copy_if = typename detail::mp_copy_if_impl<L, P>::type; template<class L, template<class...> class P> using mp_copy_if = typename detail::mp_copy_if_impl<L, P>::type;
// mp_remove<L, V>
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<>;
};
#else
template<template<class...> class L, class V> struct mp_remove_impl<L<>, V>
{
using type = L<>;
};
#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
template<class L, class V> using mp_remove = typename detail::mp_remove_impl<L, V>::type;
// mp_remove_if<L, P> // mp_remove_if<L, P>
namespace detail namespace detail
{ {
@@ -619,10 +658,145 @@ template<class L, class V> using mp_find = mp_drop<L, mp_find_index<L, V>>;
template<class L, template<class...> class P> using mp_find_if = mp_drop<L, mp_find_index_if<L, P>>; template<class L, template<class...> class P> using mp_find_if = mp_drop<L, mp_find_index_if<L, P>>;
// mp_reverse<L> // mp_reverse<L>
namespace detail
{
template<class L> struct mp_reverse_impl;
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1800 )
template<template<class...> class L, class... T> struct mp_reverse_impl<L<T...>>
{
static_assert( sizeof...(T) == 0, "T... must be empty" );
using type = L<>;
};
#else
template<template<class...> class L> struct mp_reverse_impl<L<>>
{
using type = L<>;
};
#endif
template<template<class...> class L, class T1> struct mp_reverse_impl<L<T1>>
{
using type = L<T1>;
};
template<template<class...> class L, class T1, class T2> struct mp_reverse_impl<L<T1, T2>>
{
using type = L<T2, T1>;
};
template<template<class...> class L, class T1, class T2, class T3> struct mp_reverse_impl<L<T1, T2, T3>>
{
using type = L<T3, T2, T1>;
};
template<template<class...> class L, class T1, class T2, class T3, class T4> struct mp_reverse_impl<L<T1, T2, T3, T4>>
{
using type = L<T4, T3, T2, T1>;
};
template<template<class...> class L, class T1, class T2, class T3, class T4, class T5> struct mp_reverse_impl<L<T1, T2, T3, T4, T5>>
{
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...>>
{
using type = mp_push_back<typename mp_reverse_impl<L<T...>>::type, T6, T5, T4, T3, T2, T1>;
};
} // namespace detail
template<class L> using mp_reverse = typename detail::mp_reverse_impl<L>::type;
// mp_fold<L, V, F> // mp_fold<L, V, F>
namespace detail
{
template<class L, class V, template<class...> class F> struct mp_fold_impl;
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1800 )
template<template<class...> class L, class... T, class V, template<class...> class F> struct mp_fold_impl<L<T...>, V, F>
{
static_assert( sizeof...(T) == 0, "T... must be empty" );
using type = V;
};
#else
template<template<class...> class L, class V, template<class...> class F> struct mp_fold_impl<L<>, V, F>
{
using type = V;
};
#endif
template<template<class...> class L, class T1, class... T, class V, template<class...> class F> struct mp_fold_impl<L<T1, T...>, V, F>
{
using type = typename mp_fold_impl<L<T...>, F<V, T1>, 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;
// mp_reverse_fold<L, V, F> // mp_reverse_fold<L, V, F>
namespace detail
{
template<class L, class V, template<class...> class F> struct mp_reverse_fold_impl;
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1800 )
template<template<class...> class L, class... T, class V, template<class...> class F> struct mp_reverse_fold_impl<L<T...>, V, F>
{
static_assert( sizeof...(T) == 0, "T... must be empty" );
using type = V;
};
#else
template<template<class...> class L, class V, template<class...> class F> struct mp_reverse_fold_impl<L<>, V, F>
{
using type = V;
};
#endif
template<template<class...> class L, class T1, class... T, class V, template<class...> class F> struct mp_reverse_fold_impl<L<T1, T...>, V, F>
{
using rest = typename mp_reverse_fold_impl<L<T...>, V, F>::type;
using type = F<T1, 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;
// mp_unique<L> // mp_unique<L>
// mp_remove<L, V> namespace detail
{
template<class L> struct mp_unique_impl;
template<template<class...> class L, class... T> struct mp_unique_impl<L<T...>>
{
using type = mp_set_push_back<L<>, T...>;
};
} // namespace detail
template<class L> using mp_unique = typename detail::mp_unique_impl<L>::type;
// mp_all_of<L, P>
// mp_none_of<L, P>
// mp_any_of<L, P>
} // namespace boost } // namespace boost

View File

@@ -8,12 +8,73 @@
// See accompanying file LICENSE_1_0.txt or copy at // See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt // http://www.boost.org/LICENSE_1_0.txt
#include <boost/mp11/utility.hpp>
#include <type_traits>
namespace boost namespace boost
{ {
// mp_set_contains<S, T> // mp_set_contains<S, V>
namespace detail
{
template<class S, class V> struct mp_set_contains_impl;
template<template<class...> class L, class... T, class V> struct mp_set_contains_impl<L<T...>, V>
{
using type = mp_to_bool<std::is_base_of<mp_identity<V>, mp_inherit<mp_identity<T>...>>>;
};
} // namespace detail
template<class S, class V> using mp_set_contains = typename detail::mp_set_contains_impl<S, V>::type;
// mp_set_push_back<S, T...> // mp_set_push_back<S, T...>
namespace detail
{
template<class S, class... T> struct mp_set_push_back_impl;
template<template<class...> class L, class... U> struct mp_set_push_back_impl<L<U...>>
{
using type = L<U...>;
};
template<template<class...> class L, class... U, class T1, class... T> struct mp_set_push_back_impl<L<U...>, T1, T...>
{
using S = mp_if<mp_set_contains<L<U...>, T1>, L<U...>, L<U..., T1>>;
using type = typename mp_set_push_back_impl<S, T...>::type;
};
} // namespace detail
template<class S, class... T> using mp_set_push_back = typename detail::mp_set_push_back_impl<S, T...>::type;
// mp_set_push_front<S, T...> // mp_set_push_front<S, T...>
namespace detail
{
template<class S, class... T> struct mp_set_push_front_impl;
template<template<class...> class L, class... U> struct mp_set_push_front_impl<L<U...>>
{
using type = L<U...>;
};
template<template<class...> class L, class... U, class T1> struct mp_set_push_front_impl<L<U...>, T1>
{
using type = mp_if<mp_set_contains<L<U...>, T1>, L<U...>, L<T1, U...>>;
};
template<template<class...> class L, class... U, class T1, class... T> struct mp_set_push_front_impl<L<U...>, T1, T...>
{
using S = typename mp_set_push_front_impl<L<U...>, T...>::type;
using type = typename mp_set_push_front_impl<S, T1>::type;
};
} // namespace detail
template<class S, class... T> using mp_set_push_front = typename detail::mp_set_push_front_impl<S, T...>::type;
} // namespace boost } // namespace boost

View File

@@ -25,6 +25,8 @@ run mp_push_front.cpp : : : $(REQ) ;
run mp_push_back.cpp : : : $(REQ) ; run mp_push_back.cpp : : : $(REQ) ;
run mp_rename.cpp : : : $(REQ) ; run mp_rename.cpp : : : $(REQ) ;
run mp_append.cpp : : : $(REQ) ; run mp_append.cpp : : : $(REQ) ;
# algorithm
run mp_assign.cpp : : : $(REQ) ; run mp_assign.cpp : : : $(REQ) ;
run mp_clear.cpp : : : $(REQ) ; run mp_clear.cpp : : : $(REQ) ;
run mp_transform.cpp : : : $(REQ) ; run mp_transform.cpp : : : $(REQ) ;
@@ -41,6 +43,7 @@ run mp_take.cpp : : : $(REQ) ;
run mp_replace.cpp : : : $(REQ) ; run mp_replace.cpp : : : $(REQ) ;
run mp_replace_if.cpp : : : $(REQ) ; run mp_replace_if.cpp : : : $(REQ) ;
run mp_copy_if.cpp : : : $(REQ) ; run mp_copy_if.cpp : : : $(REQ) ;
run mp_remove.cpp : : : $(REQ) ;
run mp_remove_if.cpp : : : $(REQ) ; run mp_remove_if.cpp : : : $(REQ) ;
run mp_partition.cpp : : : $(REQ) ; run mp_partition.cpp : : : $(REQ) ;
run mp_sort.cpp : : : $(REQ) ; run mp_sort.cpp : : : $(REQ) ;
@@ -48,6 +51,10 @@ run mp_find_index.cpp : : : $(REQ) ;
run mp_find_index_if.cpp : : : $(REQ) ; run mp_find_index_if.cpp : : : $(REQ) ;
run mp_find.cpp : : : $(REQ) ; run mp_find.cpp : : : $(REQ) ;
run mp_find_if.cpp : : : $(REQ) ; run mp_find_if.cpp : : : $(REQ) ;
run mp_reverse.cpp : : : $(REQ) ;
run mp_fold.cpp : : : $(REQ) ;
run mp_reverse_fold.cpp : : : $(REQ) ;
run mp_unique.cpp : : : $(REQ) ;
# integral # integral
run integral.cpp : : : $(REQ) ; run integral.cpp : : : $(REQ) ;
@@ -67,3 +74,8 @@ run integer_sequence.cpp : : : $(REQ) ;
# tuple_for_each # tuple_for_each
run tuple_for_each.cpp : : : $(REQ) ; run tuple_for_each.cpp : : : $(REQ) ;
run tuple_for_each_cx.cpp : : : $(REQ) ; run tuple_for_each_cx.cpp : : : $(REQ) ;
# set
run mp_set_contains.cpp : : : $(REQ) ;
run mp_set_push_back.cpp : : : $(REQ) ;
run mp_set_push_front.cpp : : : $(REQ) ;

57
test/mp_fold.cpp Normal file
View File

@@ -0,0 +1,57 @@
// Copyright 2015 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
#include <boost/mp11/algorithm.hpp>
#include <boost/mp11/list.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <type_traits>
#include <tuple>
struct X1 {};
struct X2 {};
struct X3 {};
struct X4 {};
template<class T1, class T2> struct F {};
int main()
{
using boost::mp_list;
using boost::mp_fold;
{
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold<mp_list<>, void, F>, void>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold<mp_list<X1>, void, F>, F<void, X1>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold<mp_list<X1, X2>, void, F>, F<F<void, X1>, X2>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold<mp_list<X1, X2, X3>, void, F>, F<F<F<void, X1>, X2>, X3>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold<mp_list<X1, X2, X3, X4>, void, F>, F<F<F<F<void, X1>, X2>, X3>, X4>>));
}
{
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold<std::tuple<>, void, F>, void>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold<std::tuple<X1>, void, F>, F<void, X1>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold<std::tuple<X1, X2>, void, F>, F<F<void, X1>, X2>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold<std::tuple<X1, X2, X3>, void, F>, F<F<F<void, X1>, X2>, X3>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold<std::tuple<X1, X2, X3, X4>, void, F>, F<F<F<F<void, X1>, X2>, X3>, X4>>));
}
using boost::mp_push_back;
{
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold<std::tuple<X1, X2, X3, X4>, mp_list<>, mp_push_back>, mp_list<X1, X2, X3, X4>>));
}
using boost::mp_push_front;
{
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>>));
}
return boost::report_errors();
}

52
test/mp_remove.cpp Normal file
View File

@@ -0,0 +1,52 @@
// Copyright 2015 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
#include <boost/mp11/algorithm.hpp>
#include <boost/mp11/list.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <type_traits>
#include <tuple>
struct X1 {};
struct X2 {};
struct X3 {};
int main()
{
using boost::mp_list;
using boost::mp_remove;
{
using L1 = mp_list<>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L1, void>, L1>));
using L2 = mp_list<X1, X2, X3, X2, X3, X3>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L2, void>, L2>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L2, X1>, mp_list<X2, X3, X2, X3, X3>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L2, X2>, mp_list<X1, X3, X3, X3>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L2, X3>, mp_list<X1, X2, X2>>));
}
{
using L1 = std::tuple<>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L1, void>, L1>));
using L2 = std::tuple<X1, X2, X3, X2, X3, X3>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L2, void>, L2>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L2, X1>, std::tuple<X2, X3, X2, X3, X3>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L2, X2>, std::tuple<X1, X3, X3, X3>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L2, X3>, std::tuple<X1, X2, X2>>));
}
return boost::report_errors();
}

62
test/mp_reverse.cpp Normal file
View File

@@ -0,0 +1,62 @@
// Copyright 2015 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
#include <boost/mp11/algorithm.hpp>
#include <boost/mp11/list.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <type_traits>
#include <tuple>
struct X1 {};
struct X2 {};
struct X3 {};
struct X4 {};
struct X5 {};
struct X6 {};
struct X7 {};
struct X8 {};
struct X9 {};
int main()
{
using boost::mp_list;
using boost::mp_reverse;
{
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<mp_list<>>, mp_list<>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<mp_list<X1>>, mp_list<X1>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<mp_list<X1, X2>>, mp_list<X2, X1>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<mp_list<X1, X2, X3>>, mp_list<X3, X2, X1>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<mp_list<X1, X2, X3, X4>>, mp_list<X4, X3, X2, X1>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<mp_list<X1, X2, X3, X4, X5>>, mp_list<X5, X4, X3, X2, X1>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<mp_list<X1, X2, X3, X4, X5, X6>>, mp_list<X6, X5, X4, X3, X2, X1>>));
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<std::tuple<>>, std::tuple<>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<std::tuple<X1>>, std::tuple<X1>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<std::tuple<X1, X2>>, std::tuple<X2, X1>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<std::tuple<X1, X2, X3>>, std::tuple<X3, X2, X1>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<std::tuple<X1, X2, X3, X4>>, std::tuple<X4, X3, X2, X1>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<std::tuple<X1, X2, X3, X4, X5>>, std::tuple<X5, X4, X3, X2, X1>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<std::tuple<X1, X2, X3, X4, X5, X6>>, std::tuple<X6, X5, X4, X3, X2, X1>>));
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::pair<X1, X2>>, std::pair<X2, X1>>));
}
return boost::report_errors();
}

56
test/mp_reverse_fold.cpp Normal file
View File

@@ -0,0 +1,56 @@
// Copyright 2015 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
#include <boost/mp11/algorithm.hpp>
#include <boost/mp11/list.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <type_traits>
#include <tuple>
struct X1 {};
struct X2 {};
struct X3 {};
struct X4 {};
template<class T1, class T2> struct F {};
template<class T, class L> using rev_push_back = boost::mp_push_back<L, T>;
template<class T, class L> using rev_push_front = boost::mp_push_front<L, T>;
int main()
{
using boost::mp_list;
using boost::mp_reverse_fold;
{
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold<mp_list<>, void, F>, void>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold<mp_list<X1>, void, F>, F<X1, void>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold<mp_list<X1, X2>, void, F>, F<X1, F<X2, void>>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold<mp_list<X1, X2, X3>, void, F>, F<X1, F<X2, F<X3, void>>>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold<mp_list<X1, X2, X3, X4>, void, F>, F<X1, F<X2, F<X3, F<X4, void>>>>>));
}
{
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold<std::tuple<>, void, F>, void>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold<std::tuple<X1>, void, F>, F<X1, void>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold<std::tuple<X1, X2>, void, F>, F<X1, F<X2, void>>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold<std::tuple<X1, X2, X3>, void, F>, F<X1, F<X2, F<X3, void>>>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold<std::tuple<X1, X2, X3, X4>, void, F>, F<X1, F<X2, F<X3, F<X4, void>>>>>));
}
{
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold<std::tuple<X1, X2, X3, X4>, mp_list<>, rev_push_back>, mp_list<X4, X3, X2, X1>>));
}
{
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>>));
}
return boost::report_errors();
}

83
test/mp_set_contains.cpp Normal file
View File

@@ -0,0 +1,83 @@
// Copyright 2015 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
#include <boost/mp11/set.hpp>
#include <boost/mp11/list.hpp>
#include <boost/mp11/integral.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <type_traits>
#include <tuple>
int main()
{
using boost::mp_list;
using boost::mp_set_contains;
using boost::mp_true;
using boost::mp_false;
{
using L1 = mp_list<>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L1, void>, mp_false>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L1, int>, mp_false>));
using L2 = mp_list<void>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L2, void>, mp_true>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L2, int>, mp_false>));
using L3 = mp_list<void, int>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L3, void>, mp_true>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L3, int>, mp_true>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L3, void const>, mp_false>));
using L4 = mp_list<void, int, char[]>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L4, void>, mp_true>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L4, int>, mp_true>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L4, char[]>, mp_true>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L4, void const>, mp_false>));
}
{
using L1 = std::tuple<>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L1, void>, mp_false>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L1, int>, mp_false>));
using L2 = std::tuple<void>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L2, void>, mp_true>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L2, int>, mp_false>));
using L3 = std::tuple<void, int>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L3, void>, mp_true>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L3, int>, mp_true>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L3, void const>, mp_false>));
using L4 = std::tuple<void, int, char[]>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L4, void>, mp_true>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L4, int>, mp_true>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L4, char[]>, mp_true>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L4, void const>, mp_false>));
}
{
using L3 = std::pair<void, int>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L3, void>, mp_true>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L3, int>, mp_true>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L3, void const>, mp_false>));
}
return boost::report_errors();
}

122
test/mp_set_push_back.cpp Normal file
View File

@@ -0,0 +1,122 @@
// Copyright 2015 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
#include <boost/mp11/set.hpp>
#include <boost/mp11/list.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <type_traits>
#include <tuple>
int main()
{
using boost::mp_list;
using boost::mp_set_push_back;
{
using L1 = mp_list<>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L1>, L1>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L1, void>, mp_list<void>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L1, int>, mp_list<int>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L1, void, int>, mp_list<void, int>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L1, void, int, char[]>, mp_list<void, int, char[]>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L1, void, int, void, int, void, int>, mp_list<void, int>>));
}
{
using L2 = mp_list<void>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L2>, L2>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L2, void>, L2>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L2, int>, mp_list<void, int>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L2, int, void>, mp_list<void, int>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L2, int, int, int, void, void, void>, mp_list<void, int>>));
}
{
using L3 = mp_list<void, int>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L3>, L3>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L3, void>, L3>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L3, int>, L3>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L3, int, int, int, void, void, void>, L3>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L3, void const>, mp_list<void, int, void const>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L3, int, char[], int, char[], void, char[], void, char[]>, mp_list<void, int, char[]>>));
}
{
using L4 = mp_list<void, int, char[]>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4>, L4>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, void>, L4>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, int>, L4>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, char[]>, L4>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, void, int, char[], void, int, char[]>, L4>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, void const>, mp_list<void, int, char[], void const>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, void const, int const, char const[]>, mp_list<void, int, char[], void const, int const, char const[]>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, void, void const, int, int const, char[], char const[]>, mp_list<void, int, char[], void const, int const, char const[]>>));
}
//
{
using L1 = std::tuple<>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L1>, L1>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L1, void>, std::tuple<void>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L1, int>, std::tuple<int>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L1, void, int>, std::tuple<void, int>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L1, void, int, char[]>, std::tuple<void, int, char[]>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L1, void, int, void, int, void, int>, std::tuple<void, int>>));
}
{
using L2 = std::tuple<void>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L2>, L2>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L2, void>, L2>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L2, int>, std::tuple<void, int>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L2, int, void>, std::tuple<void, int>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L2, int, int, int, void, void, void>, std::tuple<void, int>>));
}
{
using L3 = std::tuple<void, int>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L3>, L3>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L3, void>, L3>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L3, int>, L3>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L3, int, int, int, void, void, void>, L3>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L3, void const>, std::tuple<void, int, void const>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L3, int, char[], int, char[], void, char[], void, char[]>, std::tuple<void, int, char[]>>));
}
{
using L4 = std::tuple<void, int, char[]>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4>, L4>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, void>, L4>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, int>, L4>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, char[]>, L4>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, void, int, char[], void, int, char[]>, L4>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, void const>, std::tuple<void, int, char[], void const>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, void const, int const, char const[]>, std::tuple<void, int, char[], void const, int const, char const[]>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, void, void const, int, int const, char[], char const[]>, std::tuple<void, int, char[], void const, int const, char const[]>>));
}
return boost::report_errors();
}

124
test/mp_set_push_front.cpp Normal file
View File

@@ -0,0 +1,124 @@
// Copyright 2015 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
#include <boost/mp11/set.hpp>
#include <boost/mp11/list.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <type_traits>
#include <tuple>
int main()
{
using boost::mp_list;
using boost::mp_set_push_front;
{
using L1 = mp_list<>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L1>, L1>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L1, void>, mp_list<void>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L1, int>, mp_list<int>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L1, void, int>, mp_list<void, int>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L1, void, int, char[]>, mp_list<void, int, char[]>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L1, void, int, void, int, void, int>, mp_list<void, int>>));
}
{
using L2 = mp_list<void>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L2>, L2>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L2, void>, L2>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L2, int>, mp_list<int, void>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L2, void, int>, mp_list<int, void>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L2, void, void, void, int, int, int>, mp_list<int, void>>));
}
{
using L3 = mp_list<void, int>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3>, L3>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3, void>, L3>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3, int>, L3>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3, int, int, int, void, void, void>, L3>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3, void const>, mp_list<void const, void, int>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3, void const, int const>, mp_list<void const, int const, void, int>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3, int, char[], int, char[], void, char[], void, char[]>, mp_list<char[], void, int>>));
}
{
using L4 = mp_list<void, int, char[]>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4>, L4>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, void>, L4>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, int>, L4>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, char[]>, L4>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, void, int, char[], void, int, char[]>, L4>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, void const>, mp_list<void const, void, int, char[]>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, void const, int const, char const[]>, mp_list<void const, int const, char const[], void, int, char[]>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, void, void const, int, int const, char[], char const[]>, mp_list<void const, int const, char const[], void, int, char[]>>));
}
//
{
using L1 = std::tuple<>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L1>, L1>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L1, void>, std::tuple<void>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L1, int>, std::tuple<int>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L1, void, int>, std::tuple<void, int>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L1, void, int, char[]>, std::tuple<void, int, char[]>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L1, void, int, void, int, void, int>, std::tuple<void, int>>));
}
{
using L2 = std::tuple<void>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L2>, L2>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L2, void>, L2>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L2, int>, std::tuple<int, void>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L2, void, int>, std::tuple<int, void>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L2, void, void, void, int, int, int>, std::tuple<int, void>>));
}
{
using L3 = std::tuple<void, int>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3>, L3>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3, void>, L3>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3, int>, L3>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3, int, int, int, void, void, void>, L3>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3, void const>, std::tuple<void const, void, int>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3, void const, int const>, std::tuple<void const, int const, void, int>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3, int, char[], int, char[], void, char[], void, char[]>, std::tuple<char[], void, int>>));
}
{
using L4 = std::tuple<void, int, char[]>;
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4>, L4>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, void>, L4>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, int>, L4>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, char[]>, L4>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, void, int, char[], void, int, char[]>, L4>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, void const>, std::tuple<void const, void, int, char[]>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, void const, int const, char const[]>, std::tuple<void const, int const, char const[], void, int, char[]>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, void, void const, int, int const, char[], char const[]>, std::tuple<void const, int const, char const[], void, int, char[]>>));
}
return boost::report_errors();
}

54
test/mp_unique.cpp Normal file
View File

@@ -0,0 +1,54 @@
// Copyright 2015 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
#include <boost/mp11/algorithm.hpp>
#include <boost/mp11/list.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <type_traits>
#include <tuple>
int main()
{
using boost::mp_list;
using boost::mp_unique;
{
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<mp_list<>>, mp_list<>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<mp_list<void>>, mp_list<void>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<mp_list<void, void>>, mp_list<void>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<mp_list<void, void, void>>, mp_list<void>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<mp_list<void, void, void, void>>, mp_list<void>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<mp_list<void, int>>, mp_list<void, int>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<mp_list<void, void, void, int, int, int>>, mp_list<void, int>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<mp_list<void, int, void, int, int, void, int, int, int>>, mp_list<void, int>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<mp_list<void, int, char[]>>, mp_list<void, int, char[]>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<mp_list<void, int, char[], void, int, char[], void, int, char[]>>, mp_list<void, int, char[]>>));
}
{
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<std::tuple<>>, std::tuple<>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<std::tuple<void>>, std::tuple<void>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<std::tuple<void, void>>, std::tuple<void>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<std::tuple<void, void, void>>, std::tuple<void>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<std::tuple<void, void, void, void>>, std::tuple<void>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<std::tuple<void, int>>, std::tuple<void, int>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<std::tuple<void, void, void, int, int, int>>, std::tuple<void, int>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<std::tuple<void, int, void, int, int, void, int, int, int>>, std::tuple<void, int>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<std::tuple<void, int, char[]>>, std::tuple<void, int, char[]>>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<std::tuple<void, int, char[], void, int, char[], void, int, char[]>>, std::tuple<void, int, char[]>>));
}
return boost::report_errors();
}