1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
struct AType
{
double SomeFunc(int,long *,double &) { double ret(0); return ret; }
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 TTest1
{
typedef char Bad;
struct Good { char x[2]; };
template<T> struct helper;
template<class U> static Good check(helper<&U::SomeFunc> *);
template<class U> static Bad check(...);
static const bool value=sizeof(check<C>(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;
}
|