Template <> for explicit specialization of element enumeration

In accordance with paragraph 17.7.3 [temp.expl.spec] ( N4659 ),

... Members of an explicitly specialized class template are defined in the same way as members of ordinary classes, and do not use syntax template<>. The same is true when defining a member of an explicitly specialized member class. However, it is template<>used when defining a member of an explicitly specialized member class template that specializes as a class template.

The explicit specialization is Edefinitely not in the thick case, and it still needs to template<>. Why is this?

template<class T> struct A {
    enum E : T;
};

template<> enum A<int>::E : int { eint };
+4
1

, . , :

template<class T> struct A {
    enum E : T;
};

template<> struct A<int> {
    enum E : int;
};

enum A<int>::E : int { eint }; // no template<> here

, template<>, .

1 :

...

(1.7) -

...

, < > ; : : < >

, 5, , , , , , .

+5

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


All Articles