forked from boostorg/mp11
Add mp_all, mp_and, mp_any, mp_or; move mp_not to integral.hpp.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
#ifndef BOOST_MP11_ALGORITHM_HPP_INCLUDED
|
#ifndef BOOST_MP11_ALGORITHM_HPP_INCLUDED
|
||||||
#define BOOST_MP11_ALGORITHM_HPP_INCLUDED
|
#define BOOST_MP11_ALGORITHM_HPP_INCLUDED
|
||||||
|
|
||||||
// Copyright 2015 Peter Dimov.
|
// Copyright 2015, 2016 Peter Dimov.
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
//
|
//
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
#include <boost/mp11/set.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_count.hpp>
|
||||||
#include <boost/mp11/detail/mp_plus.hpp>
|
#include <boost/mp11/detail/mp_plus.hpp>
|
||||||
#include <boost/mp11/detail/mp_map_find.hpp>
|
#include <boost/mp11/detail/mp_map_find.hpp>
|
||||||
#include <boost/mp11/detail/config.hpp>
|
#include <boost/mp11/detail/config.hpp>
|
||||||
@@ -95,77 +96,6 @@ template<template<class...> class L, class... T, class V> struct mp_fill_impl<L<
|
|||||||
|
|
||||||
template<class L, class V> using mp_fill = typename detail::mp_fill_impl<L, V>::type;
|
template<class L, class V> using mp_fill = typename detail::mp_fill_impl<L, V>::type;
|
||||||
|
|
||||||
// mp_count<L, V>
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
|
|
||||||
template<class L, class V> struct mp_count_impl;
|
|
||||||
|
|
||||||
#if !defined( BOOST_MP11_NO_CONSTEXPR )
|
|
||||||
|
|
||||||
constexpr std::size_t cx_plus()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T1, class... T> constexpr std::size_t cx_plus(T1 t1, T... t)
|
|
||||||
{
|
|
||||||
return t1 + cx_plus(t...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<template<class...> class L, class... T, class V> struct mp_count_impl<L<T...>, V>
|
|
||||||
{
|
|
||||||
using type = mp_size_t<cx_plus(std::is_same<T, V>::value...)>;
|
|
||||||
};
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
template<template<class...> class L, class... T, class V> struct mp_count_impl<L<T...>, V>
|
|
||||||
{
|
|
||||||
using type = mp_size_t<mp_plus<std::is_same<T, V>...>::value>;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
template<class L, class V> using mp_count = typename detail::mp_count_impl<L, V>::type;
|
|
||||||
|
|
||||||
// mp_count_if<L, P>
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
|
|
||||||
template<class L, template<class...> class P> struct mp_count_if_impl;
|
|
||||||
|
|
||||||
#if !defined( BOOST_MP11_NO_CONSTEXPR )
|
|
||||||
|
|
||||||
template<template<class...> class L, class... T, template<class...> class P> struct mp_count_if_impl<L<T...>, P>
|
|
||||||
{
|
|
||||||
using type = mp_size_t<cx_plus(mp_to_bool<P<T>>::value...)>;
|
|
||||||
};
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
template<template<class...> class L, class... T, template<class...> class P> struct mp_count_if_impl<L<T...>, P>
|
|
||||||
{
|
|
||||||
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1900 )
|
|
||||||
|
|
||||||
template<class T> struct _f { using type = mp_to_bool<P<T>>; };
|
|
||||||
using type = mp_size_t<mp_plus<typename _f<T>::type...>::value>;
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
using type = mp_size_t<mp_plus<mp_to_bool<P<T>>...>::value>;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
template<class L, template<class...> class P> using mp_count_if = typename detail::mp_count_if_impl<L, P>::type;
|
|
||||||
|
|
||||||
// mp_contains<L, V>
|
// mp_contains<L, V>
|
||||||
template<class L, class V> using mp_contains = mp_to_bool<mp_count<L, V>>;
|
template<class L, class V> using mp_contains = mp_to_bool<mp_count<L, V>>;
|
||||||
|
|
||||||
|
92
include/boost/mp11/detail/mp_count.hpp
Normal file
92
include/boost/mp11/detail/mp_count.hpp
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
#ifndef BOOST_MP11_DETAIL_MP_COUNT_HPP_INCLUDED
|
||||||
|
#define BOOST_MP11_DETAIL_MP_COUNT_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Copyright 2015, 2016 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/integral.hpp>
|
||||||
|
#include <boost/mp11/detail/mp_plus.hpp>
|
||||||
|
#include <boost/mp11/detail/config.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
// mp_count<L, V>
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
template<class L, class V> struct mp_count_impl;
|
||||||
|
|
||||||
|
#if !defined( BOOST_MP11_NO_CONSTEXPR )
|
||||||
|
|
||||||
|
constexpr std::size_t cx_plus()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T1, class... T> constexpr std::size_t cx_plus(T1 t1, T... t)
|
||||||
|
{
|
||||||
|
return t1 + cx_plus(t...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<template<class...> class L, class... T, class V> struct mp_count_impl<L<T...>, V>
|
||||||
|
{
|
||||||
|
using type = mp_size_t<cx_plus(std::is_same<T, V>::value...)>;
|
||||||
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
template<template<class...> class L, class... T, class V> struct mp_count_impl<L<T...>, V>
|
||||||
|
{
|
||||||
|
using type = mp_size_t<mp_plus<std::is_same<T, V>...>::value>;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
template<class L, class V> using mp_count = typename detail::mp_count_impl<L, V>::type;
|
||||||
|
|
||||||
|
// mp_count_if<L, P>
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
template<class L, template<class...> class P> struct mp_count_if_impl;
|
||||||
|
|
||||||
|
#if !defined( BOOST_MP11_NO_CONSTEXPR )
|
||||||
|
|
||||||
|
template<template<class...> class L, class... T, template<class...> class P> struct mp_count_if_impl<L<T...>, P>
|
||||||
|
{
|
||||||
|
using type = mp_size_t<cx_plus(mp_to_bool<P<T>>::value...)>;
|
||||||
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
template<template<class...> class L, class... T, template<class...> class P> struct mp_count_if_impl<L<T...>, P>
|
||||||
|
{
|
||||||
|
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1900 )
|
||||||
|
|
||||||
|
template<class T> struct _f { using type = mp_to_bool<P<T>>; };
|
||||||
|
using type = mp_size_t<mp_plus<typename _f<T>::type...>::value>;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
using type = mp_size_t<mp_plus<mp_to_bool<P<T>>...>::value>;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
template<class L, template<class...> class P> using mp_count_if = typename detail::mp_count_if_impl<L, P>::type;
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_MP11_DETAIL_MP_COUNT_HPP_INCLUDED
|
21
include/boost/mp11/detail/mp_list.hpp
Normal file
21
include/boost/mp11/detail/mp_list.hpp
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#ifndef BOOST_MP11_DETAIL_MP_LIST_HPP_INCLUDED
|
||||||
|
#define BOOST_MP11_DETAIL_MP_LIST_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Copyright 2015, 2016 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
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
// mp_list<T...>
|
||||||
|
template<class... T> struct mp_list
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_MP11_DETAIL_MP_LIST_HPP_INCLUDED
|
@@ -1,7 +1,7 @@
|
|||||||
#ifndef BOOST_MP11_FUNCTION_HPP_INCLUDED
|
#ifndef BOOST_MP11_FUNCTION_HPP_INCLUDED
|
||||||
#define BOOST_MP11_FUNCTION_HPP_INCLUDED
|
#define BOOST_MP11_FUNCTION_HPP_INCLUDED
|
||||||
|
|
||||||
// Copyright 2015 Peter Dimov.
|
// Copyright 2015, 2016 Peter Dimov.
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
//
|
//
|
||||||
@@ -9,21 +9,71 @@
|
|||||||
// http://www.boost.org/LICENSE_1_0.txt
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
#include <boost/mp11/integral.hpp>
|
#include <boost/mp11/integral.hpp>
|
||||||
#include <boost/mp11/detail/mp_plus.hpp>
|
#include <boost/mp11/utility.hpp>
|
||||||
|
#include <boost/mp11/detail/mp_list.hpp>
|
||||||
|
#include <boost/mp11/detail/mp_count.hpp>
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
|
|
||||||
// mp_not<T>
|
|
||||||
template<class T> using mp_not = mp_bool< !T::value >;
|
|
||||||
|
|
||||||
// mp_equal_to<T1, T2>
|
// mp_equal_to<T1, T2>
|
||||||
template<class T1, class T2> using mp_equal_to = mp_bool< T1::value == T2::value >;
|
template<class T1, class T2> using mp_equal_to = mp_bool< T1::value == T2::value >;
|
||||||
|
|
||||||
// mp_all<T...>
|
// mp_all<T...>
|
||||||
|
template<class... T> using mp_all = mp_bool< mp_count_if< mp_list<T...>, mp_to_bool >::value == sizeof...(T) >;
|
||||||
|
|
||||||
// mp_and<T...>
|
// mp_and<T...>
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
template<class... T> struct mp_and_impl;
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
template<class... T> using mp_and = typename detail::mp_and_impl<T...>::type;
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
template<> struct mp_and_impl<>
|
||||||
|
{
|
||||||
|
using type = mp_true;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T1, class... T> struct mp_and_impl<T1, T...>
|
||||||
|
{
|
||||||
|
using type = mp_eval_if< mp_not<T1>, mp_false, mp_and, T... >;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
// mp_any<T...>
|
// mp_any<T...>
|
||||||
|
template<class... T> using mp_any = mp_bool< mp_count_if< mp_list<T...>, mp_to_bool >::value != 0 >;
|
||||||
|
|
||||||
// mp_or<T...>
|
// mp_or<T...>
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
template<class... T> struct mp_or_impl;
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
template<class... T> using mp_or = typename detail::mp_or_impl<T...>::type;
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
template<> struct mp_or_impl<>
|
||||||
|
{
|
||||||
|
using type = mp_false;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T1, class... T> struct mp_or_impl<T1, T...>
|
||||||
|
{
|
||||||
|
using type = mp_eval_if< T1, mp_true, mp_or, T... >;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
|
@@ -23,6 +23,9 @@ using mp_false = mp_bool<false>;
|
|||||||
// mp_to_bool
|
// mp_to_bool
|
||||||
template<class T> using mp_to_bool = mp_bool<static_cast<bool>( T::value )>;
|
template<class T> using mp_to_bool = mp_bool<static_cast<bool>( T::value )>;
|
||||||
|
|
||||||
|
// mp_not<T>
|
||||||
|
template<class T> using mp_not = mp_bool< !T::value >;
|
||||||
|
|
||||||
// mp_int
|
// mp_int
|
||||||
template<int I> using mp_int = std::integral_constant<int, I>;
|
template<int I> using mp_int = std::integral_constant<int, I>;
|
||||||
|
|
||||||
|
@@ -9,15 +9,11 @@
|
|||||||
// http://www.boost.org/LICENSE_1_0.txt
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
#include <boost/mp11/integral.hpp>
|
#include <boost/mp11/integral.hpp>
|
||||||
|
#include <boost/mp11/detail/mp_list.hpp>
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
|
|
||||||
// mp_list<T...>
|
|
||||||
template<class... T> struct mp_list
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
// mp_size<L>
|
// mp_size<L>
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
@@ -82,3 +82,9 @@ run tuple_for_each_cx.cpp : : : $(REQ) ;
|
|||||||
run mp_set_contains.cpp : : : $(REQ) ;
|
run mp_set_contains.cpp : : : $(REQ) ;
|
||||||
run mp_set_push_back.cpp : : : $(REQ) ;
|
run mp_set_push_back.cpp : : : $(REQ) ;
|
||||||
run mp_set_push_front.cpp : : : $(REQ) ;
|
run mp_set_push_front.cpp : : : $(REQ) ;
|
||||||
|
|
||||||
|
# function
|
||||||
|
run mp_all.cpp : : : $(REQ) ;
|
||||||
|
run mp_and.cpp : : : $(REQ) ;
|
||||||
|
run mp_any.cpp : : : $(REQ) ;
|
||||||
|
run mp_or.cpp : : : $(REQ) ;
|
||||||
|
@@ -51,5 +51,20 @@ int main()
|
|||||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_to_bool<mp_size_t<1>>, mp_true>));
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_to_bool<mp_size_t<1>>, mp_true>));
|
||||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_to_bool<mp_size_t<442>>, mp_true>));
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_to_bool<mp_size_t<442>>, mp_true>));
|
||||||
|
|
||||||
|
using boost::mp_not;
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_not<mp_false>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_not<mp_true>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_not<mp_int<0>>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_not<mp_int<1>>, mp_false>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_not<mp_int<107>>, mp_false>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_not<mp_int<-1>>, mp_false>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_not<mp_int<-91>>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_not<mp_size_t<0>>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_not<mp_size_t<1>>, mp_false>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_not<mp_size_t<442>>, mp_false>));
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
57
test/mp_all.cpp
Normal file
57
test/mp_all.cpp
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
|
||||||
|
// Copyright 2015, 2016 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/function.hpp>
|
||||||
|
#include <boost/mp11/integral.hpp>
|
||||||
|
#include <boost/core/lightweight_test_trait.hpp>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
using boost::mp_all;
|
||||||
|
using boost::mp_true;
|
||||||
|
using boost::mp_false;
|
||||||
|
using boost::mp_int;
|
||||||
|
using boost::mp_size_t;
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<>, mp_true>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_true>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_false>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_int<-7>>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_int<0>>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_size_t<7>>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_size_t<0>>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_true, mp_true>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_false, mp_true>, mp_false>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_true, mp_false>, mp_false>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_false, mp_false>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_int<-7>, mp_int<7>>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_size_t<(size_t)-1>, mp_size_t<1>>, mp_true>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_true, mp_true, mp_true>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_true, mp_false, mp_true>, mp_false>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_false, mp_false, mp_false>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_true, mp_true, mp_true, mp_true>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_true, mp_false, mp_true, mp_true>, mp_false>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_false, mp_false, mp_false, mp_false>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_int<1>, mp_int<2>, mp_int<-11>, mp_int<14>>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_int<1>, mp_int<0>, mp_int<-11>, mp_int<14>>, mp_false>));
|
||||||
|
|
||||||
|
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>));
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
64
test/mp_and.cpp
Normal file
64
test/mp_and.cpp
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
|
||||||
|
// Copyright 2015, 2016 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/function.hpp>
|
||||||
|
#include <boost/mp11/integral.hpp>
|
||||||
|
#include <boost/core/lightweight_test_trait.hpp>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
using boost::mp_and;
|
||||||
|
using boost::mp_true;
|
||||||
|
using boost::mp_false;
|
||||||
|
using boost::mp_int;
|
||||||
|
using boost::mp_size_t;
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<>, mp_true>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_true>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_false>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_int<-7>>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_int<0>>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_size_t<7>>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_size_t<0>>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_true, mp_true>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_true, mp_false>, mp_false>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_false, void>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_int<-4>, mp_int<5>>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_int<-4>, mp_int<0>>, mp_false>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_int<0>, void>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_size_t<7>, mp_size_t<8>>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_size_t<7>, mp_size_t<0>>, mp_false>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_size_t<0>, void>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_true, mp_true, mp_true>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_true, mp_true, mp_false>, mp_false>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_true, mp_false, void>, mp_false>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_false, void, void>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_true, mp_true, mp_true, mp_true>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_true, mp_true, mp_true, mp_false>, mp_false>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_true, mp_true, mp_false, void>, mp_false>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_true, mp_false, void, void>, mp_false>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_false, void, void, void>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_int<1>, mp_int<2>, mp_int<-11>, mp_int<14>>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_int<1>, mp_int<0>, void, void>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<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_and<mp_size_t<1>, mp_size_t<2>, mp_size_t<0>, void, void>, mp_false>));
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
62
test/mp_any.cpp
Normal file
62
test/mp_any.cpp
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
|
||||||
|
// Copyright 2015, 2016 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/function.hpp>
|
||||||
|
#include <boost/mp11/integral.hpp>
|
||||||
|
#include <boost/core/lightweight_test_trait.hpp>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
using boost::mp_any;
|
||||||
|
using boost::mp_true;
|
||||||
|
using boost::mp_false;
|
||||||
|
using boost::mp_int;
|
||||||
|
using boost::mp_size_t;
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_true>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_false>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_int<-7>>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_int<0>>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_size_t<7>>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_size_t<0>>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_true, mp_true>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_false, mp_true>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_true, mp_false>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_false, mp_false>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_int<-7>, mp_int<7>>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_size_t<(size_t)-1>, mp_size_t<1>>, mp_true>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_true, mp_true, mp_true>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_false, mp_false, mp_true>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_false, mp_false, mp_false>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_true, mp_true, mp_true, mp_true>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_false, mp_false, mp_true, mp_false>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_false, mp_false, mp_false, mp_false>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_int<1>, mp_int<2>, mp_int<-11>, mp_int<14>>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_int<0>, mp_int<0>, mp_int<-11>, mp_int<0>>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_int<0>, mp_int<0>, mp_int<0>, mp_int<0>>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<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_any<mp_size_t<0>, mp_size_t<0>, mp_size_t<114>, mp_size_t<0>, mp_size_t<0>>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_size_t<0>, mp_size_t<0>, mp_size_t<0>, mp_size_t<0>, mp_size_t<0>>, mp_false>));
|
||||||
|
|
||||||
|
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>));
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
73
test/mp_or.cpp
Normal file
73
test/mp_or.cpp
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
|
||||||
|
// Copyright 2015, 2016 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/function.hpp>
|
||||||
|
#include <boost/mp11/integral.hpp>
|
||||||
|
#include <boost/core/lightweight_test_trait.hpp>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
using boost::mp_or;
|
||||||
|
using boost::mp_true;
|
||||||
|
using boost::mp_false;
|
||||||
|
using boost::mp_int;
|
||||||
|
using boost::mp_size_t;
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_true>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_false>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_int<-7>>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_int<0>>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_size_t<7>>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_size_t<0>>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_true, void>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_false, mp_true>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_false, mp_false>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_int<0>, mp_int<0>>, mp_false>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_int<0>, mp_int<5>>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_int<-4>, void>, mp_true>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_size_t<7>, void>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_size_t<0>, mp_size_t<4>>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_size_t<0>, mp_size_t<0>>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_true, void, void>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_false, mp_true, void>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_false, mp_false, mp_true>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_false, mp_false, mp_false>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_true, void, void, void>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_false, mp_true, void, void>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_false, mp_false, mp_true, void>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_false, mp_false, mp_false, mp_true>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_false, mp_false, mp_false, mp_false>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_int<1>, void, void, void>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_int<0>, mp_int<2>, void, void, void>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_int<0>, mp_int<0>, mp_int<3>, void, void, void>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_int<0>, mp_int<0>, mp_int<0>, mp_int<4>, void, void, void>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_int<0>, mp_int<0>, mp_int<0>, mp_int<0>, mp_int<0>>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_size_t<1>, void, void, void>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_size_t<0>, mp_size_t<2>, void, void, void>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_size_t<0>, mp_size_t<0>, mp_size_t<3>, void, void, void>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_size_t<0>, mp_size_t<0>, mp_size_t<0>, mp_size_t<4>, void, void, void>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_size_t<0>, mp_size_t<0>, mp_size_t<0>, mp_size_t<0>, mp_size_t<0>>, mp_false>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_size_t<0>, mp_int<0>, mp_false, mp_size_t<141>, void, void, void>, mp_true>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_size_t<0>, mp_int<0>, mp_false>, mp_false>));
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
Reference in New Issue
Block a user