1
0
forked from boostorg/mp11

Merge branch 'develop'

This commit is contained in:
Peter Dimov
2017-05-31 19:10:55 +03:00
3 changed files with 36 additions and 5 deletions

View File

@@ -87,9 +87,9 @@ template<class... T> using mp_and = typename detail::mp_and_impl<mp_list<T...>>:
#endif
// mp_all<T...>
#if BOOST_WORKAROUND( BOOST_MSVC, <= 1910 ) || BOOST_WORKAROUND( BOOST_GCC, < 40800 )
#if BOOST_WORKAROUND( BOOST_MSVC, <= 1910 ) || BOOST_WORKAROUND( BOOST_GCC, < 70200 )
template<class... T> using mp_all = mp_bool< mp_count_if< mp_list<T...>, mp_to_bool >::value == sizeof...(T) >;
template<class... T> using mp_all = mp_bool< mp_count_if< mp_list<T...>, mp_not >::value == 0 >;
#elif defined( BOOST_MP11_HAS_FOLD_EXPRESSIONS )
@@ -132,7 +132,7 @@ template<class T1, class... T> struct mp_or_impl<T1, T...>
} // namespace detail
// mp_any<T...>
#if defined( BOOST_MP11_HAS_FOLD_EXPRESSIONS )
#if defined( BOOST_MP11_HAS_FOLD_EXPRESSIONS ) && !BOOST_WORKAROUND( BOOST_GCC, < 70200 )
template<class... T> using mp_any = mp_bool<(static_cast<bool>(T::value) || ...)>;

View File

@@ -12,9 +12,13 @@
#include <boost/core/lightweight_test_trait.hpp>
#include <type_traits>
using boost::mp11::mp_all;
template<class V, class... T> using check1 = mp_all<std::is_same<V, void>, std::is_copy_constructible<T>..., std::is_copy_assignable<T>...>;
template<class V, class... T> using check2 = mp_all<std::is_same<V, void>, mp_all<std::is_copy_constructible<T>..., mp_all<std::is_copy_assignable<T>...>>>;
int main()
{
using boost::mp11::mp_all;
using boost::mp11::mp_true;
using boost::mp11::mp_false;
using boost::mp11::mp_int;
@@ -53,5 +57,13 @@ int main()
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_size_t<1>, mp_size_t<2>, mp_size_t<114>, mp_size_t<8>, mp_size_t<94>>, mp_true>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_size_t<1>, mp_size_t<2>, mp_size_t<114>, mp_size_t<0>, mp_size_t<94>>, mp_false>));
BOOST_TEST_TRAIT_TRUE((std::is_same<check1<void, int, float>, mp_true>));
#if !BOOST_WORKAROUND( BOOST_GCC, < 40900 )
BOOST_TEST_TRAIT_TRUE((std::is_same<check2<void, int, float>, mp_true>));
#endif
return boost::report_errors();
}

View File

@@ -12,9 +12,22 @@
#include <boost/core/lightweight_test_trait.hpp>
#include <type_traits>
using boost::mp11::mp_any;
using boost::mp11::mp_all;
template<class... T> using check1 = mp_any<std::is_nothrow_copy_constructible<T>..., mp_any<std::is_nothrow_move_constructible<T>...>>;
template<class... T> using check2 = mp_any<mp_any<std::is_nothrow_copy_constructible<T>...>, std::is_nothrow_move_constructible<T>...>;
template<class... T> using check3 = mp_any<mp_all<std::is_nothrow_copy_constructible<T>...>, std::is_nothrow_default_constructible<T>...>;
template<bool is_trivially_destructible, bool is_single_buffered, class... T> struct variant_base_impl {};
#if BOOST_WORKAROUND( BOOST_GCC, < 40800 )
template<class... T> using variant_base = variant_base_impl<mp_all<std::has_trivial_destructor<T>...>::value, mp_any<mp_all<std::is_nothrow_move_constructible<T>...>, std::is_nothrow_default_constructible<T>...>::value, T...>;
#else
template<class... T> using variant_base = variant_base_impl<mp_all<std::is_trivially_destructible<T>...>::value, mp_any<mp_all<std::is_nothrow_move_constructible<T>...>, std::is_nothrow_default_constructible<T>...>::value, T...>;
#endif
int main()
{
using boost::mp11::mp_any;
using boost::mp11::mp_true;
using boost::mp11::mp_false;
using boost::mp11::mp_int;
@@ -58,5 +71,11 @@ int main()
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_size_t<0>, mp_int<0>, mp_false, mp_size_t<141>>, mp_true>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_size_t<0>, mp_int<0>, mp_false>, mp_false>));
BOOST_TEST_TRAIT_TRUE((std::is_same<check1<void, int, float>, mp_true>));
BOOST_TEST_TRAIT_TRUE((std::is_same<check2<void, int, float>, mp_true>));
BOOST_TEST_TRAIT_TRUE((std::is_same<check3<void, int, float>, mp_true>));
variant_base<void, int, float>();
return boost::report_errors();
}