mp_any_of.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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_any_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_any_of<L1, std::is_const>, mp_false>));
  24. using L2 = mp_list<X1, X1 const, X1, X1, X1>;
  25. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of<L2, std::is_volatile>, mp_false>));
  26. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of<L2, std::is_const>, mp_true>));
  27. using L3 = mp_list<X1 const, X1 const, X1, X1 const, X1>;
  28. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of<L3, std::is_volatile>, mp_false>));
  29. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of<L3, std::is_const>, mp_true>));
  30. }
  31. {
  32. using L1 = std::tuple<>;
  33. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of<L1, std::is_const>, mp_false>));
  34. using L2 = std::tuple<X1, X1 const, X1, X1, X1>;
  35. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of<L2, std::is_volatile>, mp_false>));
  36. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of<L2, std::is_const>, mp_true>));
  37. using L3 = std::tuple<X1 const, X1 const, X1, X1 const, X1>;
  38. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of<L3, std::is_volatile>, mp_false>));
  39. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of<L3, std::is_const>, mp_true>));
  40. }
  41. {
  42. using L2 = std::pair<X1 const, X1>;
  43. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of<L2, std::is_volatile>, mp_false>));
  44. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of<L2, std::is_const>, mp_true>));
  45. using L3 = std::pair<X1 const, X1 const>;
  46. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of<L3, std::is_volatile>, mp_false>));
  47. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of<L3, std::is_const>, mp_true>));
  48. }
  49. return boost::report_errors();
  50. }