This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/59165] gcc looks up begin(), end() for for-range loops for ints in namespace std
- From: "daniel.kruegler at googlemail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 20 Nov 2013 09:48:06 +0000
- Subject: [Bug c++/59165] gcc looks up begin(), end() for for-range loops for ints in namespace std
- Auto-submitted: auto-generated
- References: <bug-59165-4 at http dot gcc dot gnu dot org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59165
Daniel KrÃgler <daniel.kruegler at googlemail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |daniel.kruegler@googlemail.
| |com
--- Comment #4 from Daniel KrÃgler <daniel.kruegler at googlemail dot com> ---
(In reply to Jonathan Wakely from comment #3)
> I think I remember the rationale now: std::begin and std::end only work if
> c.begin() and c.end() xist, in which case range-based for will use those
> members directly anyway.
This is not really the *reason* for the language change. The actual reason
becomes a bit clearer when looking at the dup of CWG 1442:
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#1445
I remember that this dup was actually inspired by the observation that
BOOST_FOR_EACH behaved subtly different to the language for-each lookup rules,
albeit both constructs are intended to perform the same thing. CWG 1442 just
ensured that the lookup rule in for each corresponds to existing lookup rules
in other places and is thus easier to understand.