Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-09-17 08:08:26


"Jonathan Turkanis" <technews_at_[hidden]> writes:

> "Rob Stewart" <stewart_at_[hidden]> wrote in message:
>> From: "Jonathan Turkanis" <technews_at_[hidden]>
>> > "David Abrahams" <dave_at_[hidden]> wrote:
>> > > "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
>>
>> Yep. See 5.2.9. You'll see what static_cast can do, and then
>> 5.2.9/3 specifically excludes any other conversions.
>
> The above cast seems to be permitted under 5.2.9/2, for the reason you snipped,
> namely that
>
> const Range& r(rng)
>
> is well formed.
>
>> Modifying
>> cv qualification is not among the things static_cast can do.
>
> Then why use the language "The static_cast operator shall not cast away
> constness" (5.2.9/1)?

I was wrong. Sorry.

-- 
Dave Abrahams
Boost Consulting
http://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