Does the C ++ standard provide a template constructor for a class without templates?

I want to create a class with a template constructor:

class foo { template <class T> foo(T var) {} }; 

This compiles in VS2008, but I have no idea if this is a non-standard extension or a C ++ standard.

+6
source share
1 answer

In [temp.mem]:

A template can be declared in a class or class template; such a template is called a member template.

Constructors are members and are not explicitly allowed to create templates.

For example, std::shared_ptr has many template constructors .

+6
source

Source: https://habr.com/ru/post/958694/


All Articles