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

[class.mem] 9.2p1 should talk about member names instead of members? Members can be added later, names not. #1074

Open
RealLitb opened this issue Nov 19, 2016 · 3 comments
Labels
cwg Issue must be reviewed by CWG.

Comments

@RealLitb
Copy link

The spec says at 9.2p1

"The member-specification in a class definition declares the full set
of members of the class; no member can be added elsewhere."

However in the same paragraph it contradicts this

"Members of a class are data members, member functions ([class.mfct]),
nested types, enumerators, and member templates ([temp.mem]) and
specializations thereof."

Specializations are added elsewhere as in the following example

class A { template<typename T> class X; };

template<> class A::X<int> {};

Here, a specialization of A::X is declared ouztside of the
member-specification and according to the same paragraph, the
specialization is a member. Another example with partial
specializations

class A { template<typename T> class X; };

template<typename T> class A::X<T*> { };

Here, a partial specialization is declared outside of the class, which
for partial specializations is valud. Because it's a member template,
and member templates according to that paragraph are members, here a
member is introduced outside of the member-specification aswell and
contradicts the paragraph directly.

Another rule at 9.2 that seems to be in error is 9.2p2 which says "...For any other member-declaration, each declared entity that is not an unnamed bit-field ([class.bit]) is a member of the class, and each such member-declaration shall either declare at least one member name of the class or declare at least one unnamed bit-field."

This indeed does not apply to partial specializations either. They do not introduce a member name. Albeit template-ids are names, they do not seem to be "introduced" by declarations the way other names are, since they are not found by name lookup.

@jensmaurer jensmaurer changed the title 9.2p1 should talk about member names instead of members? Members can be added later, names not. [class.mem] 9.2p1 should talk about member names instead of members? Members can be added later, names not. Nov 22, 2016
@jensmaurer
Copy link
Member

This interacts with core issue 727 as far as in-class declarations of explicit specializations of member templates are concerned.

The path with the least fallout might be to say that explicit and partial specializations are not members.

@zygoloid
Copy link
Member

Making specializations non-members would cause problems for the access control rules at least. I think 9.2/1 is really about member names, not members.

@jensmaurer jensmaurer added the cwg Issue must be reviewed by CWG. label Dec 14, 2016
@jensmaurer
Copy link
Member

This should end up in a core issue: http://lists.isocpp.org/core/2016/12/1370.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cwg Issue must be reviewed by CWG.
Projects
None yet
Development

No branches or pull requests

3 participants