tags:

views:

671

answers:

2

Does anyone know the syntax for an out-of-declaration template method in a template class.

for instance:

template<class TYPE>
class thing
{
public :
  void do_very_little();

  template<class INNER_TYPE>
  INNER_TYPE do_stuff();
};

The first method is defined:

template<class TYPE>
void thing<TYPE>::do_very_little()
{
}

How do I do the second one, "do_stuff"?

+11  A: 
template<class TYPE>
template<class INNER_TYPE>
INNER_TYPE thing<TYPE>::do_stuff()
{
    return INNER_TYPE();
}

Try this.

CMinus
Beat me by seconds! Well done :-)
Andrew Shepherd
Ha ha, We gave the same code:-)
CMinus
Voted both of u. cheers :)
Johannes Schaub - litb
+11  A: 
template<class TYPE>
template<class INNER_TYPE>
INNER_TYPE thing<TYPE>::do_stuff()
{
    return INNER_TYPE();
}

See this page:

http://msdn.microsoft.com/en-us/library/swta9c6e(VS.80).aspx

Andrew Shepherd