[RESOLVED] static member functions in class templates
Hi,
Can anybody help me why this code does not compile (gcc 4.2.4)
what does the error "invalid operands of types ‘<unresolved overloaded function type>’ and ‘int’ to binary ‘operator<’" means?
--------------------------------------------------------------------------------------------------
struct foo {
template< int N >
static void increase( int& i );
};
template< int N >
void foo::increase( int& i )
{i += N;}
template< class T >
void f(){
int i=0;
T::increase<1>(i);
}
int main(){
f<foo>();
}
--------------------------------------------------------------------------------------------------
Regards
Re: static member functions in class templates
the line "T::increase<1>(i);" should be "T::template increase<1>(i);".
being T::increase a dependent name the compiler thinks that the '<''s in "<1> " are < operators, thus the cryptic error. The template keyword is used to disambiguate these situations.
Re: static member functions in class templates