|
Boost : |
From: Jim Apple (japple_at_[hidden])
Date: 2004-02-02 11:45:19
Fernando Cacciola wrote:
> A deep-const wrapper with preserving-const will be such that:
>
> W<T> w;
> W<T> const wc;
> W<T const> cw;
> W<T const> const cwc;
>
> test(w);
> test(wc);
> test(cw);
> test(cwc);
>
> outputs:
>
> mutable
> const
> const
> const
>
>
> value_initialized<> is a shallow-preserving-const wrapper:
>
>
> value_initialized<T> w;
> value_initialized<T> const wc;
>
> value_initialized<T const> cw;
> value_initialized<T const> const cwc;
>
> test(w);
> test(wc);
> test(cw);
> test(cwc);
>
> outputs:
>
> mutable
> mutable
> const
> const
>
> Is this the behaviour you want?
On second thought, I think I like the first better - a user who has
written const should expect const - no matter where it was written.
There are some notes on the isea of value wrapping, as well as a
prototype for can_init at http://japple.freeshell.org/value_wrap.html
Jim
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk