Skip to content

CWG2862 [temp.pre] Is it a class template with a declarator, or is it a variable template that defines a class? #506

@eisenwave

Description

@eisenwave

Full name of submitter (unless configured in github; will be published with the issue):

Reference (section label): [temp.pre] p5

Issue description

It is unclear whether the following construct is permitted (rejected by all compilers):

template <int>
struct S {} v;

This could be

  • a class template with a declarator, which is forbidden by [temp.pre] p5, or
  • a variable template which defines a class, which is not forbidden by any wording explicitly,
  • both, simultaneously, in which case it is forbidden.

Suggestion resolution

If this construct is intended to be ill-formed, modify [temp.pre] p3 as follows:

 A template-declaration is a declaration.
 A declaration introduced by a template declaration of a variable is a variable template
-.
+, unless the decl-specifier-seq of the declaration contains a class-specifier.
 A variable template at class scope is a static data member template.

If this construct is intended to be well-formed, modify [temp.pre] p5 as follows:

 In a template-declaration, explicit specialization, or explicit instantiation
 the init-declarator-list in the declaration shall contain at most one declarator.
-When such a declaration is used to declare a class template, no declarator is permitted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions