Boost logo

Boost :

Subject: Re: [boost] [optional] Thoughts on disallowing assignment for wrapped references.
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2011-08-31 04:07:36


On Tue, Aug 30, 2011 at 10:23 PM, Mostafa <mostafa_working_away_at_[hidden]>wrote:

> Boost.Optional seems to really have a lot of potential for what I want to
> do, but one thing about it has been nagging me, specifically it's assignment
> semantics for wrapped references being different from the semantics of bare
> C++ references (see http://tinyurl.com/4yna643).
>

So...you don't agree with the rationale?

> Has/have the author(s) of the library or anyone considered disallowing
> assignment for Boost.Optional types that wrap references, and if so, what
> would the consequences of this entail? I rather disallow assignment in this
> case, then have what's basically a wrapper class behave partially
> differently than the type it's supposed to emulate.
>

Given that there's an entire section of the documentation devoted to the
semantics of assignment, I'd infer the author(s) consider the various
possibilities for assignment, including disallowing it. If you disallowed
assignment for optional<T&>, then surely you would likewise need to disallow
default constructability, and then how would an optional<T&> really be any
different from a T& other than the syntactic clutter?

Perhaps you can elaborate on why the current assignment semantics are
troubling to you...?

- Jeff


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