开发者

Template specialization within template definition: is this supported for all compilers or standard usage?

开发者 https://www.devze.com 2022-12-31 12:38 出处:网络
This compiled on VS 2008, but it seems like non-standard usage of templates. template <class T> class Foo

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

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

  // more code ...
};

Is there an issue since the template specialization Foo<int> is contained within the def开发者_如何学Pythoninition of its own template class?


It's not really specialisation - you are just saying that function takes a parameter of type Foo <int> - the fact that the function is itself a member of the Foo class isn't really important. And yes, it's legal.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号