Noah Roberts
2010-05-13 17:58:07 UTC
Is a pointer to a member not a constant expression? I can use it as a
template argument but I can't compare it to 0 in one:
template < typename CONT, typename TYPE, TYPE (CONT::*fun)() const >
struct test_meta
{
enum { has_fun = fun ? true:false };
};
struct test
{
int testing() const { return 5; }
};
typedef test_meta<test, int, &test::testing> try1;
typedef test_meta<test, int, 0> try2;
int main()
{
try1 t1;
try2 t2;
}
VC++ 2010 vomits that up saying that a constant expression is expected
at the read_only definition.
I also had trouble specializing a different template (a metafunction)
for a similar type. I can match a type with member variable pointers
but not one with member function pointers.
Can anyone clarify if this is so or if this compiler is busted?
template argument but I can't compare it to 0 in one:
template < typename CONT, typename TYPE, TYPE (CONT::*fun)() const >
struct test_meta
{
enum { has_fun = fun ? true:false };
};
struct test
{
int testing() const { return 5; }
};
typedef test_meta<test, int, &test::testing> try1;
typedef test_meta<test, int, 0> try2;
int main()
{
try1 t1;
try2 t2;
}
VC++ 2010 vomits that up saying that a constant expression is expected
at the read_only definition.
I also had trouble specializing a different template (a metafunction)
for a similar type. I can match a type with member variable pointers
but not one with member function pointers.
Can anyone clarify if this is so or if this compiler is busted?
--
http://crazyeddiecpp.blogspot.com/
http://crazyeddiecpp.blogspot.com/