Template specialization in template definition: is this supported across all compilers or standard usage?

This is compiled in VS 2008, but it seems like a non-standard usage of templates.

template <class T>
class Foo
{
public:
  void bar(Foo<int> arg)
  {
    // do some stuff here
  }

  // more code ...
};

      

Is there a problem since the template specification is Foo<int>

contained in the template's own class definition?

+2


a source to share


1 answer


This is not a specialization - you are just saying that the function takes a type parameter Foo <int>

- the fact that the function itself is a member of the Foo class is not very important. And yes, it is legal.



+4


a source







All Articles