Topic: names _1, _2, etc. in global namespace (unreserve?)
Author: "Vladimir Marko" <swelef@post.sk>
Date: Fri, 27 May 2005 11:23:45 CST Raw View
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 ]