meta_transform.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "simple/support/meta/transform.hpp"
  2. #include "simple/support/meta/list.hpp"
  3. #include <type_traits>
  4. using namespace simple::support;
  5. template <typename T>
  6. using int_to_void_t = std::conditional_t<std::is_same_v<T, int>, void, T>;
  7. template <typename X, typename T>
  8. struct x_to_void { using type = std::conditional_t<std::is_same_v<T, X>, void, T>; };
  9. int main()
  10. {
  11. static_assert(std::is_same_v<
  12. meta::transform_t<meta::list<long, int, short, signed char>,
  13. std::make_unsigned_t>,
  14. meta::list<unsigned long, unsigned int, unsigned short, unsigned char>
  15. >);
  16. static_assert(std::is_same_v<
  17. meta::transform_t<meta::list<long, int, short, signed char>, int_to_void_t>,
  18. meta::list<long, void, short, signed char>
  19. >);
  20. static_assert(std::is_same_v<
  21. meta::transform_t<meta::list<long, int, short, signed char>, meta::bind_t<x_to_void, short>::template bound>,
  22. meta::list<long, int, void, signed char>
  23. >);
  24. static_assert(std::is_same_v<
  25. meta::transform_t<meta::list<long, int, short, signed char>, meta::bind_t<x_to_void, signed char>::template bound>,
  26. meta::list<long, int, short, void>
  27. >);
  28. return 0;
  29. }