metafunction.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright Jason Rice 2016
  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/experimental/printable.hpp>
  6. #include <boost/hana/integral_constant.hpp>
  7. #include <boost/hana/type.hpp>
  8. #include <regex>
  9. #include <sstream>
  10. namespace hana = boost::hana;
  11. namespace foo {
  12. template <typename T> struct my_template { };
  13. template <typename ...> struct my_mf { struct type; };
  14. struct my_mf_class { template <typename ...> struct apply { struct type; }; };
  15. }
  16. int main() {
  17. {
  18. std::ostringstream ss;
  19. ss << hana::experimental::print(
  20. hana::template_<foo::my_template>
  21. );
  22. BOOST_HANA_RUNTIME_CHECK(std::regex_match(ss.str(),
  23. std::regex("template<(?:struct )?foo::my_template>")));
  24. }
  25. {
  26. std::ostringstream ss;
  27. ss << hana::experimental::print(
  28. hana::metafunction<foo::my_mf>
  29. );
  30. BOOST_HANA_RUNTIME_CHECK(std::regex_match(ss.str(),
  31. std::regex("metafunction<(?:struct )?foo::my_mf>")));
  32. }
  33. {
  34. std::ostringstream ss;
  35. ss << hana::experimental::print(
  36. hana::metafunction_class<foo::my_mf_class>
  37. );
  38. BOOST_HANA_RUNTIME_CHECK(std::regex_match(ss.str(),
  39. std::regex("metafunction_class<(?:struct )?foo::my_mf_class>")));
  40. }
  41. }