Support pointers to members

This commit is contained in:
Peter Dimov
2021-10-05 07:25:35 +03:00
parent b0b48c5783
commit cd1a8fd238
2 changed files with 41 additions and 1 deletions

View File

@ -350,7 +350,18 @@ template<class R, class... A> std::string function_type_name( tn_identity<R(A...
if( !suffix.empty() )
{
r += '(' + suffix + ')';
r += '(';
if( suffix.front() == ' ' )
{
r += suffix.substr( 1 );
}
else
{
r += suffix;
}
r += ')';
}
r += '(' + tn_add_each<A...>() + ')';
@ -580,6 +591,13 @@ template<class T, std::size_t N> std::string type_name( tn_identity<T const vola
return array_type_name( tn_identity<T const volatile[N]>(), suffix );
}
// pointers to members
template<class R, class T> std::string type_name( tn_identity<R T::*>, std::string const& suffix )
{
return type_name( tn_identity<R>(), ' ' + type_name( tn_identity<T>(), "" ) + "::*" + suffix );
}
// nullptr_t
#if !defined(BOOST_NO_CXX11_NULLPTR)

View File

@ -192,6 +192,28 @@ int main()
TEST(B(&)[1][2][3]);
TEST(B const volatile(***)[1][2][3]);
TEST(int A::*);
TEST(int const B::*);
TEST(void(A::*)());
TEST(void(A::*)() const);
TEST(void(A::*)() volatile);
TEST(void(A::*)() const volatile);
#if !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
TEST(void(A::*)() &);
TEST(void(A::*)() const &&);
#endif
#if defined( __cpp_noexcept_function_type ) || defined( _NOEXCEPT_TYPES_SUPPORTED )
TEST(void(A::*)() volatile & noexcept);
TEST(void(A::*)() const volatile && noexcept);
#endif
#if !defined(BOOST_NO_CXX11_NULLPTR)
TEST(std::nullptr_t);