Boost logo

Boost Users :

Subject: Re: [Boost-users] implementing a new Range
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2009-08-26 18:26:34


Steven Watanabe wrote:

>> boost::begin could still be used fully qualified and defer to ADL or
>> the basic implemenation, similarly to boost::swap, no?
>
> If there is no overload of begin, the result may be
> infinite recursion in some cases instead of a compiler
> error. (although some compilers will emit a warning)

How so?

namespace boost
{
namespace range_detail
{
     template<typename T>
     ... begin(const T& t) { return t.begin(); }
}

template<typename T>
... begin(const T& t)
{
     using range_detail::begin;
     return begin(t);
}

}

(Needs to replace ... with range_iterator<T> variants, add non-const
overloads, handle the old range_begin customization point)
I don't see how that kind of thing can cause infinite recursion. If
there is no overload of begin picked up by ADL, it uses range_detail::begin.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net