Type of template member functions.
Hello, the following program when compiled with GCC gives the output
that follows the listing:
#include <iostream>
#include <typeinfo>
struct A {
template< unsigned n >
void member( const double& );
};
int main()
{
std::cout << typeid( void (A::*) ( const double& ) ).name() << '\n';
std::cout << typeid( &A::member< 0 > ).name() << '\n';
std::cout << typeid( &A::member< 1 > ).name() << '\n';
return( 0 );
}
Output:
M1AFvRKdE
PFvRKdE
PFvRKdE
Is that a GCC bug or the types of template member function and member
functions are not the same?
The reason I ask is because the following test always returns false:
template< class T >
class has_apply {
typedef char yes[1];
typedef char no[2];
template< class U, U u >
struct coerce {};
template< class U, unsigned n >
static yes& test( U*, coerce< void (U::*) ( const double& ) ,
&U::template apply< n > >* = 0 );
template< class U, unsigned n >
static no& test( ... );
public:
static const bool result = ( sizeof( yes ) == sizeof( test< T, 0
( (T*)(0) ) ) );
};