|
Boost Users : |
Subject: Re: [Boost-users] ambiguity between std::begin/end and boost::begin/end in gcc 4.6
From: Michel MORIN (mimomorin_at_[hidden])
Date: 2010-12-27 15:10:15
Neil Groves wrote:
> However in this case I have yet to understand the nature of the underlying
> problem, because there isn't an obvious unqualified call to begin/end. The
> reverse adaptor uses qualified calls that can't possibly be ambiguous with
> std::begin/end. I haven't yet checked to see if unqualified calls to
> begin/end are intended to be used as an extension mechanism for the next C++
> standard.
Here is the standard:
Range-Based For Loop Wording (Without Concepts)
http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2930.html
Its summary is:
A range-based for
for (auto x : range_expr) {
// do something
}
is equivalent to
{
// Special rule: namespace std is added to rng's associated namespaces
auto&& rng = range_expr;
for (
// Note: unqualified begin/end function call
auto it = begin(rng),
it_end = end(rng);
it != it_end;
++it
) {
auto x = *it;
// do something
}
}
Note that rng has namespace std as its associated namespaces
and the unqualified begin/end function call triggers ADL.
> I shall put begin and end in an ADL barrier namespace anyhow, since these
> are explicitly designed to be qualified when called.
That would be Great, Neil! This is an important issue.
Regards,
Michel
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net