In one of his latest talks, Herb Sutter recommended to prefer the free begin(container)
end(container)
functions templates over container.beg
I would let ADL do its work. While you are allowed to add specializations in the std
namespace, there is no strong reason I can think of for doing so when a plain free function in your namespace suffices.
In particular for the range for loops, the standard states:
§6.5.4/1 (definition of begin-expr and end-expr):
- otherwise, begin-expr and end-expr are
begin(__range)
andend(__range)
, respectively, where begin and end are looked up with argument-dependent lookup (3.4.2). For the purposes of this name lookup, namespace std is an associated namespace.