
"Rob Stewart" <stewart@sig.com> wrote in message:
From: "Jonathan Turkanis" <technews@kangaroologic.com>
"David Abrahams" <dave@boost-consulting.com> wrote:
"Jonathan Turkanis" <technews@kangaroologic.com> 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)? Jonathan