mp_back.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright 2015, 2019 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/core/lightweight_test_trait.hpp>
  8. #include <boost/mp11/algorithm.hpp>
  9. #include <boost/mp11/list.hpp>
  10. #include <boost/mp11/utility.hpp>
  11. #include <type_traits>
  12. #include <tuple>
  13. #include <utility>
  14. int main()
  15. {
  16. using boost::mp11::mp_list;
  17. using boost::mp11::mp_back;
  18. using L1 = mp_list<void>;
  19. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_back<L1>, void>));
  20. using L2 = mp_list<float, void, int[]>;
  21. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_back<L2>, int[]>));
  22. using L3 = std::tuple<int>;
  23. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_back<L3>, int>));
  24. using L4 = std::pair<char, double>;
  25. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_back<L4>, double>));
  26. using L5 = std::add_const<void()>;
  27. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_back<L5>, void()>));
  28. using boost::mp11::mp_iota_c;
  29. using boost::mp11::mp_size_t;
  30. int const N = 137;
  31. using L6 = mp_iota_c<N>;
  32. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_back<L6>, mp_size_t<N-1>>));
  33. using boost::mp11::mp_valid;
  34. using L7 = mp_list<>;
  35. BOOST_TEST_TRAIT_FALSE((mp_valid<mp_back, L7>));
  36. return boost::report_errors();
  37. }