The established idiom for invoking swap
is:
using std::swap
swap(foo, bar);
This way, swap
can be overloaded for user
the documentation of swap
specifies that the idiom you refer to is common practice in the stl library
Many components of the standard library (within std) call swap in an unqualified manner to allow custom overloads for non-fundamental types to be called instead of this generic version: Custom overloads of swap declared in the same namespace as the type for which they are provided get selected through argument-dependent lookup over this generic version.
No such thing is present in the documentation for begin
and end
.
For this reason, you can definitely use the
using std::begin;
using std::end;
some_algorithm(begin(some_container), end(some_container));
calling convention, but you must be aware that this is a convention which doesn't apply to e.g. standard algorithms but to your code only.