Topic: ADL begin/end for ranges, is that really ok?


Author: Mathias Gaunard <loufoque@gmail.com>
Date: Sun, 21 Mar 2010 18:28:16 CST
Raw View
Making begin/end found through ADL for ranges basically means that the
names begin/end should not be used for anything else than to define a
mean to extract an iterator from a range.
Indeed, the rules to associate a namespace through ADL are too easily
triggered when considering template parameters of template classes,
and the only reasonable way to avoid major problems is to ban those
identifiers altogether for any different meaning.

Is that really ok, though? Begin/end are pretty common and broad
identifiers, and are already used a lot. This isn't really that
different from making them keywords, and it does break a lot of
existing code (I ran into such an issue the other day).
Using range_begin and range_end should be enough to avoid most
problems since they have much more specialized and descriptive names.
std::begin could call range_begin with ADL for example.

--
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]