mp_all_of_q.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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_all_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_all_of_q<L1, mp_quote<std::is_const>>, mp_true>));
  26. using L2 = mp_list<X1 const, X1 const, X1 const volatile, X1 const, X1 const volatile>;
  27. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of_q<L2, mp_quote<std::is_volatile>>, mp_false>));
  28. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of_q<L2, mp_quote<std::is_const>>, mp_true>));
  29. }
  30. {
  31. using L1 = std::tuple<>;
  32. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of_q<L1, mp_quote<std::is_const>>, mp_true>));
  33. using L2 = std::tuple<X1 const, X1 const, X1 const volatile, X1 const, X1 const volatile>;
  34. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of_q<L2, mp_quote<std::is_volatile>>, mp_false>));
  35. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of_q<L2, mp_quote<std::is_const>>, mp_true>));
  36. }
  37. {
  38. using L2 = std::pair<X1 const, X1 const volatile>;
  39. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of_q<L2, mp_quote<std::is_volatile>>, mp_false>));
  40. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of_q<L2, mp_quote<std::is_const>>, mp_true>));
  41. }
  42. return boost::report_errors();
  43. }