You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 regels
1.3 KiB

  1. #include <cpputils/mp/core/const.h>
  2. #include <cpputils/mp/container/basic_tuple.h>
  3. using namespace ::utl::mp;
  4. namespace test_mp_container_basic_tuple
  5. {
  6. struct op_unpack
  7. {
  8. constexpr auto operator()(const c_bool_t<false>&, const c_size_t<5>&)
  9. { return true; }
  10. };
  11. template<typename T>
  12. struct Wrapper { };
  13. struct op_transform
  14. {
  15. template<typename T>
  16. constexpr auto operator()(T&& t)
  17. { return Wrapper<clean_type<T>> { }; }
  18. };
  19. constexpr auto my_tuple = make_basic_tuple(c_bool_t<false> { }, c_size_t<5> { });
  20. constexpr c_size_t<0> index0;
  21. constexpr c_size_t<1> index1;
  22. static_assert(unpack(my_tuple, op_unpack { }), "");
  23. static_assert(my_tuple.unpack(op_unpack { }), "");
  24. static_assert(decltype(at(my_tuple, index0))::value == false, "");
  25. static_assert(decltype(at(my_tuple, index1))::value == 5, "");
  26. static_assert(decltype(my_tuple.at(index0))::value == false, "");
  27. static_assert(decltype(my_tuple.at(index1))::value == 5, "");
  28. constexpr auto transformed = my_tuple.transform(op_transform { });
  29. using transformed_type = clean_type<decltype(transformed)>;
  30. using transformed_expected = basic_tuple<Wrapper<c_bool_t<false>>, Wrapper<c_size_t<5>>>;
  31. static_assert(is_same<transformed_type, transformed_expected>::value, "");
  32. }