Boost logo

Boost :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2004-09-15 22:19:54


"David Abrahams" <dave_at_[hidden]> wrote in message
news:u3c1jhvz5.fsf_at_boost-consulting.com...
> "Jonathan Turkanis" <technews_at_[hidden]> writes:

> >
> > template<typename Range>
> > typename range_const_iterator<X>::type
> > const_begin(Range& rng)
> > {
> > return begin(static_cast<const Range&>(rng));
> > }
>
> For one thing you can't use static_cast to change constness.

Are you sure? The expression

     const Range& r(rng)

is well formed, I believe, so static_cast<const Range&>(rng) should be okay.

> I can't imagine why you'd want this first overload.

You're right that it's superflous, given the second overload. But you should
still be able to imagine why I wrote it. ;-) I forgot that X::iterator must be
convertible to X::const_iterator, and that you can take advantage of more
implicit conversions when you switch from member functions to non-member
functions.

Jonathan


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