mp_same.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright 2017 Peter Dimov.
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. //
  5. // See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. #include <boost/mp11/detail/config.hpp>
  8. #if BOOST_MP11_MSVC
  9. # pragma warning( disable: 4503 ) // decorated name length exceeded
  10. #endif
  11. #include <boost/mp11/function.hpp>
  12. #include <boost/mp11/algorithm.hpp>
  13. #include <boost/mp11/list.hpp>
  14. #include <boost/core/lightweight_test_trait.hpp>
  15. #include <type_traits>
  16. int main()
  17. {
  18. using boost::mp11::mp_same;
  19. using boost::mp11::mp_true;
  20. using boost::mp11::mp_false;
  21. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<>, mp_true>));
  22. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<void>, mp_true>));
  23. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<void, void>, mp_true>));
  24. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<void, void, void>, mp_true>));
  25. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<void, void, void, void>, mp_true>));
  26. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<void, void, void, void, void>, mp_true>));
  27. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<void, int>, mp_false>));
  28. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<void, void, int>, mp_false>));
  29. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<void, void, void, int>, mp_false>));
  30. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<void, void, void, void, int>, mp_false>));
  31. using boost::mp11::mp_repeat_c;
  32. using boost::mp11::mp_list;
  33. using boost::mp11::mp_apply;
  34. int const N = 1024;
  35. using L = mp_repeat_c<mp_list<void>, N>;
  36. using R = mp_apply<mp_same, L>;
  37. BOOST_TEST_TRAIT_TRUE((std::is_same<R, mp_true>));
  38. return boost::report_errors();
  39. }