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 

names _1, _2, etc. in global namespace (unreserve?)

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





PostPosted: Fri May 27, 2005 5:23 pm    Post subject: names _1, _2, etc. in global namespace (unreserve?) Reply with quote



Considering the placeholders _1, _2, etc. from Boost.Bind and
Boost.Lambda (and std::placeholders from N1455) there is an issue
with reserved names:

17.4.3.1.2/1 2nd bullet:
Each name that begins with an underscore is reserved to the
implementation for use as a name in the global namespace.

This makes the use of placeholders through a using-directive or
using-declaration little dangerous. Though I've never heard of an
implementation that would use global names _1, _2, etc. these names
are officialy reserved and the following snippet may be ill-formed:

namespace test{
struct arg1 { } _1;
}

using namespace test;

int main(){
_1; // may be ambigous if the implementation defines _1 in global
// namespace
}

I suspect that many users actualy use the placeholders in a similar
way. So it may be reasonable to explicitly remove these identifiers
from reserved names. This would "legalize" the existing practice.

But which names should be unreserved then? All names with a leading
underscore followed by a digit or just names composed exclusively
of a leading underscore and a number?

Regards,
Vladimir Marko

---
[ 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.