// Copyright Louis Dionne 2013-2017 // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) #include #include #include #include #include #include #include #include namespace hana = boost::hana; template struct Template { }; template void check_matches(std::string const& re) { std::string name = hana::to(hana::experimental::type_name()); std::regex regex{re}; if (!std::regex_match(name, regex)) { std::cerr << "type name '" << name << "' does not match regex '" << re << "'" << std::endl; std::abort(); } } int main() { // Make sure this can be obtained at compile-time BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::experimental::type_name(), BOOST_HANA_STRING("void") )); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::experimental::type_name(), BOOST_HANA_STRING("int") )); // Make sure we get something reasonable check_matches("int const|const int"); check_matches(R"(int\s*&)"); check_matches(R"(const\s+int\s*&|int\s+const\s*&)"); check_matches(R"(int\s*\(\s*&\s*\)\s*\[\s*\])"); check_matches(R"(int\s*\(\s*&\s*\)\s*\[\s*10\s*\])"); check_matches>(R"(Template<\s*void\s*,\s*(char const|const char)\s*\*\s*>)"); check_matches(R"(void\s*\(\s*\*\s*\)\s*\(\s*int\s*\))"); }