Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why are the words "that is not a cv-qualifier" mentioned in [class.mem]/12? #2675

Closed
Ayrosa opened this issue Feb 21, 2019 · 2 comments
Closed

Comments

@Ayrosa
Copy link

Ayrosa commented Feb 21, 2019

[class.mem]/12:

The decl-specifier-seq may be omitted in constructor, destructor, and conversion function declarations only; when declaring another kind of member the decl-specifier-seq shall contain a type-specifier that is not a cv-qualifier. The member-declarator-list can be omitted only after a class-specifier or an enum-specifier or in a friend declaration. A pure-specifier shall be used only in the declaration of a virtual function that is not a friend declaration.

The code below is accepted by C++ compilers since time immemorial:

struct A{
    const int i;
    A():i(1) {}
};
@jwakely
Copy link
Member

jwakely commented Feb 22, 2019

It means it must have at least one type-specifier that is not a cv-qualifier. It can also have cv-qualifiers.

i.e. const i; is not valid, but const int i; is valid and const unsigned long long int; is valid

@jwakely
Copy link
Member

jwakely commented Feb 22, 2019

In other words, it doesn't say "shall not contain cv-qualifiers".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants