mp_assign.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright 2015, 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/list.hpp>
  8. #include <boost/core/lightweight_test_trait.hpp>
  9. #include <type_traits>
  10. #include <tuple>
  11. #include <utility>
  12. struct X1 {};
  13. struct X2 {};
  14. struct X3 {};
  15. int main()
  16. {
  17. using boost::mp11::mp_list;
  18. using boost::mp11::mp_assign;
  19. using L1 = mp_list<int, void(), float[]>;
  20. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L1, mp_list<>>, mp_list<>>));
  21. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L1, mp_list<X1>>, mp_list<X1>>));
  22. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L1, mp_list<X1, X2>>, mp_list<X1, X2>>));
  23. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L1, mp_list<X1, X2, X3>>, mp_list<X1, X2, X3>>));
  24. //
  25. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L1, std::tuple<>>, mp_list<>>));
  26. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L1, std::tuple<X1>>, mp_list<X1>>));
  27. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L1, std::tuple<X1, X2>>, mp_list<X1, X2>>));
  28. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L1, std::tuple<X1, X2, X3>>, mp_list<X1, X2, X3>>));
  29. //
  30. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L1, std::pair<X1, X2>>, mp_list<X1, X2>>));
  31. //
  32. using L2 = std::tuple<int, char, float>;
  33. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L2, mp_list<>>, std::tuple<>>));
  34. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L2, mp_list<X1>>, std::tuple<X1>>));
  35. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L2, mp_list<X1, X2>>, std::tuple<X1, X2>>));
  36. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L2, mp_list<X1, X2, X3>>, std::tuple<X1, X2, X3>>));
  37. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L2, std::pair<X1, X2>>, std::tuple<X1, X2>>));
  38. //
  39. using L3 = std::pair<int, char>;
  40. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L3, mp_list<X1, X2>>, std::pair<X1, X2>>));
  41. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L3, std::pair<X1, X2>>, std::pair<X1, X2>>));
  42. //
  43. return boost::report_errors();
  44. }