A
Alex Pavloff
Hi folks,
Here's a piece of example code describing the issue I'm having:
struct Foo
{
template<int N>
int Blah()
{
return 1;
}
template<>
int Blah<0>()
{
return 0;
}
};
Microsoft Visual C++ 7.1 compiles and runs this as expected.
Foo f;
int i = f.Blah<1>(); // i == 1
int j = f.Blah<0>(); // j == 0
gcc 3.3.1 however, doesn't like compiling it, giving...
error: explicit specialization in non-namespace scope `struct Foo'
....in addition to numerous other errors resulting because the compiler is
now confused.
Googling for this finds various discussions of what's legal and what's not
when it comes to member function specialization, but I've got a little more
practical question. What sort of workaround can I use to make this code do
pretty much the same thing and run on gcc 3.3.1?
Thanks,
Alex Pavloff
Here's a piece of example code describing the issue I'm having:
struct Foo
{
template<int N>
int Blah()
{
return 1;
}
template<>
int Blah<0>()
{
return 0;
}
};
Microsoft Visual C++ 7.1 compiles and runs this as expected.
Foo f;
int i = f.Blah<1>(); // i == 1
int j = f.Blah<0>(); // j == 0
gcc 3.3.1 however, doesn't like compiling it, giving...
error: explicit specialization in non-namespace scope `struct Foo'
....in addition to numerous other errors resulting because the compiler is
now confused.
Googling for this finds various discussions of what's legal and what's not
when it comes to member function specialization, but I've got a little more
practical question. What sort of workaround can I use to make this code do
pretty much the same thing and run on gcc 3.3.1?
Thanks,
Alex Pavloff