C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

core issue 147 and mem-initializer-id, qualified-id, injecte

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards
View previous topic :: View next topic  
Author Message
msalters
Guest





PostPosted: Sat Feb 05, 2005 4:02 am    Post subject: core issue 147 and mem-initializer-id, qualified-id, injecte Reply with quote



Hi,

3.4.3.1 had been changed a lot since 1998, to deal with
repetitions of class names like

struct B {
B();
}

B::B() { ; }
B::B b;

The problem with the second form is that the class-name B is
injected in its own scope. So, B::B looked up B in its own
scope and indeed found a class B. This was fixed by making
the injected name B formally an injected-class-name, and
modifying 3.4.3.1 so that B::B names the ctor. N1655 modifies
it again, to restrict it to places where "the constructor is
an acceptable lookup result".

Now, one of the advantages of the pre-N1655 form was that
it also outlawed funny stuff like

struct D_notok {
D_notok() : B::B::B() { }
};
while it probably does allow

struct D_ok {
int B;
D_ok() : B(1), B::B() { }
};

The reason is that I think that B::B( ) is a member-initializer-id
which isn't a qualified-id, but in B::B::B( ) the nested-name-specifier
is B::B:: and that is a qualified-id. It's illegal, of course because
it names the constructor in a nested-name-specifier.

Now, with N1655 the wording in 3.4.3.1 no longer applies to such
cases and B::B::B( ) is again legal. B::B:: is just a nested name
specifier, where the second B is the injected-class-name.

Do I read it correctly? Is it intended?

Regards,
Michiel Salters

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.