I found this interesting bit in Boost.Range:
When providing free-standing functions range_begin/end()
, the docs state that:
...
range_begin()
andrange_end()
must be overloaded for bothconst
andmutable
reference arguments.
And indeed, looking at their defaults in end.hpp
, we see:
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template< typename Iterator >
inline Iterator range_end( const std::pair<Iterator,Iterator>& p )
{
return p.second;
}
template< typename Iterator >
inline Iterator range_end( std::pair<Iterator,Iterator>& p )
{
return p.second;
}
You will note (and the example given in the docs also does this) that both versions return the same Iterator
type.
Why do we need both overload in the first place? Is it to make ADL work?