forked from boostorg/mp11
Merge branch 'develop'
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#ifndef 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.
|
||||
//
|
||||
@@ -12,7 +12,8 @@
|
||||
#include <boost/mp11/set.hpp>
|
||||
#include <boost/mp11/integral.hpp>
|
||||
#include <boost/mp11/utility.hpp>
|
||||
#include <boost/mp11/function.hpp>
|
||||
#include <boost/mp11/detail/mp_count.hpp>
|
||||
#include <boost/mp11/detail/mp_plus.hpp>
|
||||
#include <boost/mp11/detail/mp_map_find.hpp>
|
||||
#include <boost/mp11/detail/config.hpp>
|
||||
#include <boost/integer_sequence.hpp>
|
||||
@@ -47,8 +48,6 @@ namespace detail
|
||||
|
||||
template<template<class...> class F, class... L> struct mp_transform_impl;
|
||||
|
||||
template<template<class...> class F, class... L> using mp_transform = typename mp_transform_impl<F, L...>::type;
|
||||
|
||||
template<template<class...> class F, template<class...> class L, class... T> struct mp_transform_impl<F, L<T...>>
|
||||
{
|
||||
using type = L<F<T>...>;
|
||||
@@ -95,77 +94,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;
|
||||
|
||||
// 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>
|
||||
template<class L, class V> using mp_contains = mp_to_bool<mp_count<L, V>>;
|
||||
|
||||
@@ -796,13 +724,13 @@ template<template<class...> class L, class... T> struct mp_unique_impl<L<T...>>
|
||||
template<class L> using mp_unique = typename detail::mp_unique_impl<L>::type;
|
||||
|
||||
// mp_all_of<L, P>
|
||||
template<class L, template<class...> class P> using mp_all_of = mp_equal_to< mp_count_if<L, P>, mp_size<L> >;
|
||||
template<class L, template<class...> class P> using mp_all_of = mp_bool< mp_count_if<L, P>::value == mp_size<L>::value >;
|
||||
|
||||
// mp_none_of<L, P>
|
||||
template<class L, template<class...> class P> using mp_none_of = mp_not< mp_count_if<L, P> >;
|
||||
template<class L, template<class...> class P> using mp_none_of = mp_bool< mp_count_if<L, P>::value == 0 >;
|
||||
|
||||
// mp_any_of<L, P>
|
||||
template<class L, template<class...> class P> using mp_any_of = mp_to_bool< mp_count_if<L, P> >;
|
||||
template<class L, template<class...> class P> using mp_any_of = mp_bool< mp_count_if<L, P>::value != 0 >;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
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
|
||||
#define BOOST_MP11_FUNCTION_HPP_INCLUDED
|
||||
|
||||
// Copyright 2015 Peter Dimov.
|
||||
// Copyright 2015, 2016 Peter Dimov.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
@@ -9,21 +9,71 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#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
|
||||
{
|
||||
|
||||
// mp_not<T>
|
||||
template<class T> using mp_not = mp_bool< !T::value >;
|
||||
|
||||
// mp_equal_to<T1, T2>
|
||||
template<class T1, class T2> using mp_equal_to = mp_bool< T1::value == T2::value >;
|
||||
|
||||
// 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...>
|
||||
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...>
|
||||
template<class... T> using mp_any = mp_bool< mp_count_if< mp_list<T...>, mp_to_bool >::value != 0 >;
|
||||
|
||||
// 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
|
||||
|
||||
|
@@ -23,6 +23,9 @@ using mp_false = mp_bool<false>;
|
||||
// mp_to_bool
|
||||
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
|
||||
template<int I> using mp_int = std::integral_constant<int, I>;
|
||||
|
||||
|
@@ -9,15 +9,11 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/mp11/integral.hpp>
|
||||
#include <boost/mp11/detail/mp_list.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
// mp_list<T...>
|
||||
template<class... T> struct mp_list
|
||||
{
|
||||
};
|
||||
|
||||
// mp_size<L>
|
||||
namespace detail
|
||||
{
|
||||
|
@@ -1,21 +1,52 @@
|
||||
#ifndef BOOST_MP11_MAP_HPP_INCLUDED
|
||||
#define BOOST_MP11_MAP_HPP_INCLUDED
|
||||
|
||||
// Copyright 2015 Peter Dimov.
|
||||
// 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/detail/mp_map_find.hpp>
|
||||
#include <boost/mp11/list.hpp>
|
||||
#include <boost/mp11/integral.hpp>
|
||||
#include <boost/mp11/utility.hpp>
|
||||
#include <boost/mp11/algorithm.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
// mp_map_find<M, K>
|
||||
// mp_map_contains<M, K>
|
||||
template<class M, class K> using mp_map_contains = mp_not<std::is_same<mp_map_find<M, K>, void>>;
|
||||
|
||||
// mp_map_insert<M, T>
|
||||
template<class M, class T> using mp_map_insert = mp_if< mp_map_contains<M, mp_first<T>>, M, mp_push_back<M, T> >;
|
||||
|
||||
// mp_map_replace<M, T>
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class M, class T> struct mp_map_replace_impl;
|
||||
|
||||
template<template<class...> class M, class... U, class T> struct mp_map_replace_impl<M<U...>, T>
|
||||
{
|
||||
using K = mp_first<T>;
|
||||
|
||||
// mp_replace_if is inlined here using a struct _f because of msvc-14.0
|
||||
|
||||
template<class V> struct _f { using type = mp_if< std::is_same<mp_first<V>, K>, T, V >; };
|
||||
|
||||
using type = mp_if< mp_map_contains<M<U...>, K>, M<typename _f<U>::type...>, M<U..., T> >;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class M, class T> using mp_map_replace = typename detail::mp_map_replace_impl<M, T>::type;
|
||||
|
||||
// mp_map_update<M, T, F>
|
||||
// mp_map_erase<M, K>
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
@@ -82,3 +82,15 @@ run tuple_for_each_cx.cpp : : : $(REQ) ;
|
||||
run mp_set_contains.cpp : : : $(REQ) ;
|
||||
run mp_set_push_back.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) ;
|
||||
|
||||
# map
|
||||
run mp_map_find.cpp : : : $(REQ) ;
|
||||
run mp_map_contains.cpp : : : $(REQ) ;
|
||||
run mp_map_insert.cpp : : : $(REQ) ;
|
||||
run mp_map_replace.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<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();
|
||||
}
|
||||
|
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();
|
||||
}
|
51
test/mp_map_contains.cpp
Normal file
51
test/mp_map_contains.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
|
||||
// Copyright 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/map.hpp>
|
||||
#include <boost/mp11/list.hpp>
|
||||
#include <boost/mp11/integral.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <type_traits>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::mp_map_contains;
|
||||
using boost::mp_list;
|
||||
using boost::mp_true;
|
||||
using boost::mp_false;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<mp_list<>, char>, mp_false>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<std::tuple<>, int>, mp_false>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<mp_list<std::pair<int, int const>, std::pair<long, long const>>, char>, mp_false>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<mp_list<std::pair<int, int const>, std::pair<long, long const>>, int>, mp_true>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<mp_list<std::pair<int, int const>, std::pair<long, long const>>, long>, mp_true>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<std::tuple<std::pair<int, int const>, std::pair<long, long const>>, char>, mp_false>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<std::tuple<std::pair<int, int const>, std::pair<long, long const>>, int>, mp_true>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<std::tuple<std::pair<int, int const>, std::pair<long, long const>>, long>, mp_true>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<std::pair<std::pair<int, int const>, std::pair<long, long const>>, char>, mp_false>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<std::pair<std::pair<int, int const>, std::pair<long, long const>>, int>, mp_true>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<std::pair<std::pair<int, int const>, std::pair<long, long const>>, long>, mp_true>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>, char>, mp_false>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>, int>, mp_true>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>, long>, mp_true>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>, long long>, mp_true>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<std::tuple<mp_list<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>, char>, mp_false>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<std::tuple<mp_list<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>, int>, mp_true>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<std::tuple<mp_list<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>, long>, mp_true>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<std::tuple<mp_list<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>, long long>, mp_true>));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
48
test/mp_map_find.cpp
Normal file
48
test/mp_map_find.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
|
||||
// Copyright 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/map.hpp>
|
||||
#include <boost/mp11/list.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <type_traits>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::mp_map_find;
|
||||
using boost::mp_list;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<mp_list<>, char>, void>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::tuple<>, int>, void>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<mp_list<std::pair<int, int const>, std::pair<long, long const>>, char>, void>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<mp_list<std::pair<int, int const>, std::pair<long, long const>>, int>, std::pair<int, int const>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<mp_list<std::pair<int, int const>, std::pair<long, long const>>, long>, std::pair<long, long const>>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::tuple<std::pair<int, int const>, std::pair<long, long const>>, char>, void>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::tuple<std::pair<int, int const>, std::pair<long, long const>>, int>, std::pair<int, int const>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::tuple<std::pair<int, int const>, std::pair<long, long const>>, long>, std::pair<long, long const>>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::pair<std::pair<int, int const>, std::pair<long, long const>>, char>, void>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::pair<std::pair<int, int const>, std::pair<long, long const>>, int>, std::pair<int, int const>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::pair<std::pair<int, int const>, std::pair<long, long const>>, long>, std::pair<long, long const>>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>, char>, void>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>, int>, mp_list<int>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>, long>, mp_list<long, long>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>, long long>, mp_list<long long, long long, long long>>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::tuple<mp_list<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>, char>, void>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::tuple<mp_list<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>, int>, mp_list<int>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::tuple<mp_list<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>, long>, std::pair<long, long>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::tuple<mp_list<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>, long long>, std::tuple<long long, long long, long long>>));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
66
test/mp_map_insert.cpp
Normal file
66
test/mp_map_insert.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
|
||||
// Copyright 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/map.hpp>
|
||||
#include <boost/mp11/list.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <type_traits>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::mp_map_insert;
|
||||
using boost::mp_list;
|
||||
using boost::mp_push_back;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<mp_list<>, mp_list<void>>, mp_list<mp_list<void>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<std::tuple<>, std::tuple<int>>, std::tuple<std::tuple<int>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<std::tuple<>, std::pair<int, float>>, std::tuple<std::pair<int, float>>>));
|
||||
|
||||
{
|
||||
using M = mp_list<std::pair<int, int const>, std::pair<long, long const>>;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, mp_list<char>>, mp_push_back<M, mp_list<char>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::pair<char, char const>>, mp_push_back<M, std::pair<char, char const>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, mp_list<int>>, M>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::pair<long, float>>, M>));
|
||||
}
|
||||
|
||||
{
|
||||
using M = std::tuple<std::pair<int, int const>, std::pair<long, long const>>;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, mp_list<char>>, mp_push_back<M, mp_list<char>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::pair<char, char const>>, mp_push_back<M, std::pair<char, char const>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, mp_list<int>>, M>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::pair<long, float>>, M>));
|
||||
}
|
||||
|
||||
{
|
||||
using M = mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, mp_list<char>>, mp_push_back<M, mp_list<char>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::pair<char, char const>>, mp_push_back<M, std::pair<char, char const>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::tuple<int>>, M>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::pair<long, float>>, M>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, mp_list<long long, float, double>>, M>));
|
||||
}
|
||||
|
||||
{
|
||||
using M = std::tuple<mp_list<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, mp_list<char>>, mp_push_back<M, mp_list<char>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::pair<char, char const>>, mp_push_back<M, std::pair<char, char const>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::tuple<int>>, M>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::pair<long, float>>, M>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, mp_list<long long, float, double>>, M>));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
66
test/mp_map_replace.cpp
Normal file
66
test/mp_map_replace.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
|
||||
// Copyright 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/map.hpp>
|
||||
#include <boost/mp11/list.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <type_traits>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::mp_map_replace;
|
||||
using boost::mp_list;
|
||||
using boost::mp_push_back;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<mp_list<>, mp_list<void>>, mp_list<mp_list<void>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<std::tuple<>, std::tuple<int>>, std::tuple<std::tuple<int>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<std::tuple<>, std::pair<int, float>>, std::tuple<std::pair<int, float>>>));
|
||||
|
||||
{
|
||||
using M = mp_list<std::pair<int, int const>, std::pair<long, long const>>;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, mp_list<char>>, mp_push_back<M, mp_list<char>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, std::pair<char, char const>>, mp_push_back<M, std::pair<char, char const>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, mp_list<int>>, mp_list<mp_list<int>, std::pair<long, long const>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, std::pair<long, float>>, mp_list<std::pair<int, int const>, std::pair<long, float>>>));
|
||||
}
|
||||
|
||||
{
|
||||
using M = std::tuple<std::pair<int, int const>, std::pair<long, long const>>;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, mp_list<char>>, mp_push_back<M, mp_list<char>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, std::pair<char, char const>>, mp_push_back<M, std::pair<char, char const>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, mp_list<int>>, std::tuple<mp_list<int>, std::pair<long, long const>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, std::pair<long, float>>, std::tuple<std::pair<int, int const>, std::pair<long, float>>>));
|
||||
}
|
||||
|
||||
{
|
||||
using M = mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, mp_list<char>>, mp_push_back<M, mp_list<char>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, std::pair<char, char const>>, mp_push_back<M, std::pair<char, char const>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, std::tuple<int>>, mp_list<std::tuple<int>, mp_list<long, long>, mp_list<long long, long long, long long>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, std::pair<long, float>>, mp_list<mp_list<int>, std::pair<long, float>, mp_list<long long, long long, long long>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, mp_list<long long, float, double>>, mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, float, double>>>));
|
||||
}
|
||||
|
||||
{
|
||||
using M = std::tuple<mp_list<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, mp_list<char>>, mp_push_back<M, mp_list<char>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, std::pair<char, char const>>, mp_push_back<M, std::pair<char, char const>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, std::tuple<int>>, std::tuple<std::tuple<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, std::pair<long, float>>, std::tuple<mp_list<int>, std::pair<long, float>, std::tuple<long long, long long, long long>>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, mp_list<long long, float, double>>, std::tuple<mp_list<int>, std::pair<long, long>, mp_list<long long, float, double>>>));
|
||||
}
|
||||
|
||||
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