diff --git a/include/boost/core/type_name.hpp b/include/boost/core/type_name.hpp index 9a82dd3..dfdedd3 100644 --- a/include/boost/core/type_name.hpp +++ b/include/boost/core/type_name.hpp @@ -14,6 +14,7 @@ // https://www.boost.org/LICENSE_1_0.txt #include +#include #include #include #include @@ -73,6 +74,24 @@ template struct tn_is_reference #endif +// tn_remove_const + +template struct tn_remove_const +{ + typedef T type; +}; + +template struct tn_remove_const +{ + typedef T type; +}; + +// tn_is_function (also catches references but that's OK) + +template::type> struct tn_is_function: core::is_same +{ +}; + #if !defined(BOOST_NO_TYPEID) // typeid_name @@ -261,21 +280,21 @@ template std::string type_name( tn_identity ) #else template -typename tn_enable_if::value, std::string>::type +typename tn_enable_if::value, std::string>::type type_name( tn_identity ) { return type_name( tn_identity() ) + " const"; } template -typename tn_enable_if::value, std::string>::type +typename tn_enable_if::value, std::string>::type type_name( tn_identity ) { return type_name( tn_identity() ) + " volatile"; } template -typename tn_enable_if::value, std::string>::type +typename tn_enable_if::value, std::string>::type type_name( tn_identity ) { return type_name( tn_identity() ) + " const volatile"; @@ -332,6 +351,22 @@ template std::string type_name( tn_identity ) #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +// function references + +template std::string type_name( tn_identity ) +{ + return type_name( tn_identity() ) + "(&)(" + tn_add_each() + ')'; +} + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + +template std::string type_name( tn_identity ) +{ + return type_name( tn_identity() ) + "(&&)(" + tn_add_each() + ')'; +} + +#endif + // function pointers template std::string type_name( tn_identity ) diff --git a/test/type_name_test.cpp b/test/type_name_test.cpp index 6ab08f5..b3439c1 100644 --- a/test/type_name_test.cpp +++ b/test/type_name_test.cpp @@ -105,6 +105,21 @@ int main() TEST(void*); TEST(void const* volatile*); +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + + TEST(void()); + TEST(int(float, A, B*)); + + TEST(void(*)()); + TEST(void(&)()); + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + + TEST(void(&&)()); + +#endif +#endif + TEST(A[]); TEST(A const[]); TEST(A volatile[]);