Boost logo

Boost :

From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2002-08-27 14:02:01


----- Original Message -----
From: "Darin Adler" <darin_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Tuesday, August 27, 2002 3:26 PM
Subject: Re: [boost] value_initialized<> uploaded to be Files Section.

>
> On Tuesday, August 27, 2002, at 10:50 AM, Fernando Cacciola wrote:
>
> > As for the mutable problem: the only solution I can think of is to
> > resort to
> > 'is_const<>' to select how the data member 'x' is defined in the
> > wrapper.
> > I've been trying not to do that in order to avoid a dependency with
> > type
> > traits, for it seems that I can't do without it, after all.
>
> It seems to me that you can make a version for the better quality
> compilers that uses the overloaded functions. And then a version for
> the compilers that don't have a problem that depends on type traits.
>
The problem is that the single-operator version has a slightly different
semantic.
The following is legal with the current implementation, while it wouldn't be
legal if both operators were provided:

value_initialized<int> const x_c ;
static_cast<int&>(x_c) = 2 ;

In order to avoid such subtle behavior, the Docs recommend using get()
instead, which provides deep-constantness, but I can't forbid the usage
above, though.

value_initialized<int> x ;
value_initialized<int const> cx ;
value_initialized<int const> const cx_c ;

get(x) = 2 ; // OK
get(x_c) = 2 ; // ERROR
get(cx) = 2 ; // ERROR
get(cx_c) = 2 ; // ERROR

Fernando Cacciola
Sierra s.r.l.
fcacciola_at_[hidden]
www.gosierra.com


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