Heya -
The following works with MSVC:
template< bool Boolean >
struct Foo
{
template< class T2 >
void bar( T2 arg )
{
std::cout << arg << std::endl;
}
template<>
void bar( bool arg )
{
if ( Boolean )
std::cout << arg << std::endl;
}
};
Of course, g++ complains about "explicit specialization in non-namespace
scope" - this is usually no big deal, just move the specialization
outside of th class, right? For this example, I'm unable to figure out
how to move the specialization outside of the class definition without
generating a raft of errors, with either compiler. Basically I think
this is some type of partial specialization, but the wrench is the
'bool' as the template parameter of the class.
The closest I've been able to come up with is:
template<>
template< bool Boolean >
inline void Foo<bool>::bar( bool arg )
{
}
but it doesn't seem to work.
Any help would be greatly appreciated. :)
- John