Manao
11th February 2004, 08:13
This code compiles with gcc, but not with VC++ 7.0.
I wanted to know if it was a bug of VC++ or something else :
typedef bool (*Compare)(int x, int y);
struct A
{
int a;
int b;
template <Compare C>
int c()
{
return C(a,b) ? a : b;
}
};
bool lt(int x, int y)
{ return x < y; }
bool gt(int x, int y)
{ return x > y; }
typedef int (A::*ACompare)();
int main()
{
A untest;
untest.c<lt>();
ACompare f1 = &A::c<lt>;
ACompare f2 = &A::c<gt>;
}
The aim of that code it to test whether it can use pointers on member's function which are templates.
I wanted to know if it was a bug of VC++ or something else :
typedef bool (*Compare)(int x, int y);
struct A
{
int a;
int b;
template <Compare C>
int c()
{
return C(a,b) ? a : b;
}
};
bool lt(int x, int y)
{ return x < y; }
bool gt(int x, int y)
{ return x > y; }
typedef int (A::*ACompare)();
int main()
{
A untest;
untest.c<lt>();
ACompare f1 = &A::c<lt>;
ACompare f2 = &A::c<gt>;
}
The aim of that code it to test whether it can use pointers on member's function which are templates.