What is a member enumeration in context of templates?

Viewed 97

The C++20 standard (N4892) states:

The declaration in a template-declaration (if any) shall [...] (2.2) — define [...] a member enumeration, [...]

(13.1.2)

What is meant by a member enumeration in this context? I looked through the standard but could not find a definition of this term, only usages of it. In 13.9.2.3.(1/2) both scoped and unscoped member enumerations are mentioned. So I assume enums are meant by it. However, I was unable to create a member enum template in MSVC:

struct S
{
    template<typename T>
    enum class e
    {
        i = 0,
    };
};

C3113: an 'enum' cannot be a template

I also have never seen an enum template in the wild, so I assume this isn't possible. So what is meant by a "member enumeration" in context of templates?

1 Answers

However, I was unable to create a member enum template in MSVC:

Because this was not meant. There are no enum templates in the now existing C++ standards. Think instead of a forward-declared scoped-member-enum of a class template:

template <typename T>
class Foo { enum class bar; };

template <typename T>
enum class Foo<T>::bar { baz };

This is a case of a declaration in a template-declaration which is a definition of an enum, which is an example for a use case covered by [temp.pre] 2.2.

Related