forked from boostorg/mp11
Add mp_same.
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include <boost/mp11/utility.hpp>
|
||||
#include <boost/mp11/detail/mp_list.hpp>
|
||||
#include <boost/mp11/detail/mp_count.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -84,6 +85,26 @@ template<class T1, class... T> struct mp_or_impl<T1, T...>
|
||||
|
||||
} // namespace detail
|
||||
|
||||
// mp_same<T...>
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class... T> struct mp_same_impl;
|
||||
|
||||
template<> struct mp_same_impl<>
|
||||
{
|
||||
using type = mp_true;
|
||||
};
|
||||
|
||||
template<class T1, class... T> struct mp_same_impl<T1, T...>
|
||||
{
|
||||
using type = mp_all<std::is_same<T1, T>...>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class... T> using mp_same = typename detail::mp_same_impl<T...>::type;
|
||||
|
||||
} // namespace mp11
|
||||
} // namespace boost
|
||||
|
||||
|
@@ -94,6 +94,7 @@ run mp_all.cpp : : : $(REQ) ;
|
||||
run mp_and.cpp : : : $(REQ) ;
|
||||
run mp_any.cpp : : : $(REQ) ;
|
||||
run mp_or.cpp : : : $(REQ) ;
|
||||
run mp_same.cpp : : : $(REQ) ;
|
||||
|
||||
# map
|
||||
run mp_map_find.cpp : : : $(REQ) ;
|
||||
|
33
test/mp_same.cpp
Normal file
33
test/mp_same.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
// Copyright 2017 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/core/lightweight_test_trait.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::mp11::mp_same;
|
||||
using boost::mp11::mp_true;
|
||||
using boost::mp11::mp_false;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<>, mp_true>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<void>, mp_true>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<void, void>, mp_true>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<void, void, void>, mp_true>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<void, void, void, void>, mp_true>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<void, void, void, void, void>, mp_true>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<void, int>, mp_false>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<void, void, int>, mp_false>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<void, void, void, int>, mp_false>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<void, void, void, void, int>, mp_false>));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
Reference in New Issue
Block a user