Compiling this code:
struct AType
{
template<class X,class Y,class Z,short AA> double SomeFuncTemplate(X,Y *,Z &) { double ret(AA); return ret; }
};
template
<
class T
>
struct TTest
{
typedef char Bad;
struct Good { char x[2]; };
template<T> struct helper;
static Good check(helper<&AType::template SomeFuncTemplate<int,long,double,50> > *);
static Bad check(...);
static const bool value=sizeof(check(0))==sizeof(Good);
};
template
<
class T,
class C
>
struct TTest2
{
typedef char Bad;
struct Good { char x[2]; };
template<T> struct helper;
template<class U> static Good check(helper<&U::template SomeFuncTemplate<int,long,double,50> > *);
template<class U> static Bad check(...);
static const bool value=sizeof(check<C>(0))==sizeof(Good);
};
int main()
{
static_assert(TTest
<
double (AType::*)(int,long *,double &)
>::value,
"failure in TTest"
);
static_assert(TTest1
<
double (AType::*)(int,long *,double &),
AType
>::value,
"failure in TTest1"
);
static_assert(TTest2
<
double (AType::*)(int,long *,double &),
AType
>::value,
"failure in TTest2"
);
return 0;
}
a static_assert will trigger as "failure in TTest2". It should of course not happen.