special.transform.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright Louis Dionne 2013-2017
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  4. #include <boost/hana/assert.hpp>
  5. #include <boost/hana/equal.hpp>
  6. #include <boost/hana/transform.hpp>
  7. #include <boost/hana/tuple.hpp>
  8. #include <boost/hana/type.hpp>
  9. namespace hana = boost::hana;
  10. template <typename ...>
  11. struct F { struct type; };
  12. struct x1;
  13. struct x2;
  14. struct x3;
  15. struct x4;
  16. int main() {
  17. // transform with tuple_t and a metafunction
  18. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  19. hana::transform(hana::tuple_t<>, hana::metafunction<F>),
  20. hana::tuple_t<>
  21. ));
  22. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  23. hana::transform(hana::tuple_t<x1>, hana::metafunction<F>),
  24. hana::tuple_t<F<x1>::type>
  25. ));
  26. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  27. hana::transform(hana::tuple_t<x1, x2>, hana::metafunction<F>),
  28. hana::tuple_t<F<x1>::type, F<x2>::type>
  29. ));
  30. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  31. hana::transform(hana::tuple_t<x1, x2, x3>, hana::metafunction<F>),
  32. hana::tuple_t<F<x1>::type, F<x2>::type, F<x3>::type>
  33. ));
  34. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  35. hana::transform(hana::tuple_t<x1, x2, x3, x4>, hana::metafunction<F>),
  36. hana::tuple_t<F<x1>::type, F<x2>::type, F<x3>::type, F<x4>::type>
  37. ));
  38. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  39. hana::transform(hana::tuple_t<x1, x2, x3, x4>, hana::template_<F>),
  40. hana::tuple_t<F<x1>, F<x2>, F<x3>, F<x4>>
  41. ));
  42. }