Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2005-09-03 12:13:19


David Abrahams wrote:
> Thorsten Ottosen <nesotto_at_[hidden]> writes:
>
>
>>>You also seem to be forgetting the Range concepts that you yourself
>>>documented here: http://boost.org/libs/range/doc/range.html. In the
>>>concepts, the calls to begin()/end() are REQUIRED to be qualified.
>
>
> Let me clarify. Eric, you seem to be saying that it's inconsistent
> for the "begin" extension mechanism to be "add a begin to be found via
> ADL in the same namespace as the Range type" and for the interface for
> calling those begin to be "boost::begin(x)." There's no inherent
> inconsistency there. It's possible to implement such a mechanism.

*blink* It is? If boost::begin() makes an unqualified call to begin(),
then wouldn't it just end up recursing forever? You must have some
subtlety in mind that is eluding me.

<thinking...>

Oh, wait. Are you referring to something like this:

namespace super_private {
     template<typename T>
     some-return-type begin_impl(T &t) {
         return begin(t);
     }
}

namespace boost {
     template<typename T>
     some-return-type begin(T &t) {
         return super_private::begin_impl(t);
     }
}

The unqualified call to begin() in namespace super_private will not find
the one in namespace boost, hence no infinite recursion. But this
doesn't quite work because if type T has boost as an associated
namespace, it *will* consider the begin() in namespace boost, and we're
back to infinite recursion.

Regardless, it was gcc's interpretation of name-lookup that put the
kibosh on unqualified calls to begin() and end().

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk