mp_all_of.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2015, 2016 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/algorithm.hpp>
  8. #include <boost/mp11/list.hpp>
  9. #include <boost/mp11/integral.hpp>
  10. #include <boost/core/lightweight_test_trait.hpp>
  11. #include <type_traits>
  12. #include <tuple>
  13. #include <utility>
  14. struct X1 {};
  15. int main()
  16. {
  17. using boost::mp11::mp_list;
  18. using boost::mp11::mp_all_of;
  19. using boost::mp11::mp_true;
  20. using boost::mp11::mp_false;
  21. {
  22. using L1 = mp_list<>;
  23. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of<L1, std::is_const>, mp_true>));
  24. using L2 = mp_list<X1 const, X1 const, X1 const volatile, X1 const, X1 const volatile>;
  25. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of<L2, std::is_volatile>, mp_false>));
  26. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of<L2, std::is_const>, mp_true>));
  27. }
  28. {
  29. using L1 = std::tuple<>;
  30. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of<L1, std::is_const>, mp_true>));
  31. using L2 = std::tuple<X1 const, X1 const, X1 const volatile, X1 const, X1 const volatile>;
  32. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of<L2, std::is_volatile>, mp_false>));
  33. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of<L2, std::is_const>, mp_true>));
  34. }
  35. {
  36. using L2 = std::pair<X1 const, X1 const volatile>;
  37. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of<L2, std::is_volatile>, mp_false>));
  38. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of<L2, std::is_const>, mp_true>));
  39. }
  40. return boost::report_errors();
  41. }