create.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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/config.hpp>
  5. #include <boost/hana/detail/create.hpp>
  6. #include <utility>
  7. #include <tuple>
  8. namespace hana = boost::hana;
  9. constexpr hana::detail::create<std::tuple> make_tuple{};
  10. constexpr hana::detail::create<std::pair> make_pair{};
  11. template <typename ...>
  12. struct empty { };
  13. template <typename T>
  14. struct single_holder { T x; };
  15. template <typename T>
  16. struct identity { using type = T; };
  17. template <typename ...T>
  18. using identity_t = typename identity<T...>::type;
  19. int main() {
  20. static_assert(make_tuple(1, '2', 3.3) == std::make_tuple(1, '2', 3.3), "");
  21. static_assert(make_pair(1, '2') == std::make_pair(1, '2'), "");
  22. // should work
  23. hana::detail::create<empty>{}();
  24. hana::detail::create<single_holder>{}(1);
  25. hana::detail::create<single_holder>{}([]{});
  26. hana::detail::create<identity_t>{}(1);
  27. hana::detail::create<identity_t>{}([]{});
  28. }