On 8 nov, 20:39, "Johannes Schaub (litb)"<schaub-johan...@web.de>
wrote:
Elias Salom??o Helou Neto wrote:
It will be a pointer to member. Only "A::member_function" - not preceeded
by& - will have the type of the member function, but that expression
must either be immediately followed by "()", or must unambiguously refer
to a static member function. In both cases, that expression would have
the type "void(const double&)", for the function type in your example.
Ok, now you've got the hole code:
#include<iostream>
template< class T>
class has_apply {
typedef char yes[1];
typedef char no[2];
template< class U, U u>
struct binder {};
template< class U, unsigned n>
static yes& test( U*,
binder< void (U::*) ( const double& ),
&U::template apply< n>
>* = 0
);
template< class U, unsigned n>
static yes& test( U*,
binder< void (U::*) ( const double& ) const,
&U::template apply< n>
>* = 0
);
template< class U, unsigned n>
static yes& test( U*,
binder< void (*) ( const double& ),
&U::template apply< n>
>* = 0
);
template< class U, unsigned n>
static yes& test( U*,
binder< void (U::*) ( double ),
&U::template apply< n>
>* = 0
);
template< class U, unsigned n>
static yes& test( U*,
binder< void (U::*) ( double ) const,
&U::template apply< n>
>* = 0
);
template< class U, unsigned n>
static yes& test( U*,
binder< void (*) ( double ),
&U::template apply< n>
>* = 0
);
template< class U, unsigned n>
static no& test( ... );
public:
static const bool result = ( sizeof( yes ) == sizeof( test< T, 0u
( (T*)(0) ) ) );
};
class A {
public:
template< unsigned n>
void apply( const double& );
};
int main()
{
std::cout<< std::boolalpha<< has_apply< A>::result<< '\n';
return( 0 );
}
Run:
$g++ -Wall -o test test.cpp&& ./test
false
As it appears you have a static member function, it's clear why this
fails. So double check everything.
Your assumption is wrong, I do not have a static member function. Even
if I had, shouldn't the code above return true?
I tested your code and can't find any bug. Hmm, I suspect it's a GCC
problem.