Boost logo

Boost :

From: Brock Peabody (brock.peabody_at_[hidden])
Date: 2005-03-04 15:50:58

> On Behalf Of Fernando Cacciola
> Sent: Tuesday, March 01, 2005 10:39 AM
> To: boost_at_[hidden]
> Subject: [boost] Re: [optional] new assignmet semantic and references

> So I think I will fix it unless users speak up...
> Though I will post this issue in the users list as well.

First I'd like to say that I love optional<>. When I first read about it I
didn't think I'd use it much, but now I find myself using it all over the
place. It's useful for so many things, but to me the most important is how
it improves my ability to make code self-documenting.
Personally, I like it the way it is. I've used optional quite a bit and it
makes sense to me that operator= changes what an optional holds. I don't
think it is a good idea to give operator= special semantics for references.

I think it odd, for instance, that given the following optionals:

    int a = 5, b = 6;

    boost::optional<int&> ra = a, rb = b;


    ra = rb;

would have different behavior than:


    ra = rb;

I can understand the desire to mimic the semantics of built in C++
references in boost::optional, but one uses boost::optional precisely in
cases where one does not want those semantics - in cases where a reference
may not be present, and where you may want to change which object is
referred too.

My humble .02.


Boost list run by bdawes at, gregod at, cpdaniel at, john at