mp_any_of_q.cpp 2.5 KB

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