Boost logo

Boost :

From: rwgk (rwgk_at_[hidden])
Date: 2002-03-15 15:12:33


--- In boost_at_y..., "David Abrahams" <david.abrahams_at_r...> wrote:
> This is a familiar issue. I have two proposals for you:
>
> 1. specialize for T const and cast away const-ness in the general
> template:
>
> template <class T>
> struct ref : ref<T const>
> {
> T* begin() { const_cast<T*>(this->ref<T const>::begin()); }
> };
>
> template <class T>
> struct ref<T const>
> {
> ...
> };

Wow, I didn't think you could inherit from a partial
specialization of yourself ... ("inherit" does not even
sound appropriate, this is more "preherit")

> 2. Check out how const/non-const iterator interactions are handled
> (differently) in the iterator adaptors lib. You can read about it
> in the paper at www.boost.org/libs/utility/iterator_adaptors.pdf

Does this approach also involve partial specialization (or any
other language feature not supported by the most beloved VC6
compiler)?

I am still curious: have there been discussions about
introducing direct support for something like "transitive_const"
into the language? -- When I first saw types like "const_iterator"
I was very puzzled. And then, what is "const const_iterator?"
Wouldn't transitive_const make strange looking types like this
obsolete?

Thanks,
        Ralf


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