I have some template code which compiles fine in VC9 (Microsoft Visual C++ 2008) but won't compile in GCC 4.2 (on Mac). I'm wondering if there's some syntactical magic that I'm missing.
Below I have a stripped-down example which demonstrates my error. Sorry if this example seems meaningless, I removed as much as I could to isolate this error.
In particular I have a template class S which has an inner class R which is also a template class. From a top-level template function foo, I am trying to call R::append which is a static member function of R:
template< typename C >
struct S {
template< typename T >
S<C> & append( const T & ) { return *this; }
template< int B >
struct R {
template< typename N >
static S<C> & append( S<C> & s, const N ) {
return s.append( 42 );
}
};
};
template< typename C >
S<C> & foo( S<C> & s, const int n ) {
S<C>::R<16>::append( s, n ); // error: '::append' has not been declared
return s;
}
Anyone out there know what I'm doing wrong?