Boost logo

Boost :

Subject: Re: [boost] [outcome] expected<T&>, result<T&>
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2017-05-25 22:13:39


2017-05-26 0:01 GMT+02:00 Peter Dimov via Boost <boost_at_[hidden]>:

> Gottlob Frege wrote:
>
> Some committee members want references to work one way, some want it to
>> work another, ...
>>
>
> More specifically, some want in
>
> T t1, t2;
> expected<T&> e1( t1 ), e2( t2 );
>
> e1 = e2;
>
> t1 to be assigned t2, whereas others want e1 to start pointing to t2.
> Similarly for e1 = t2.
>

>From what I remember the biggest controversy in boost::optional<T&> was
about the assignment from T:

```
T v1, v2;
optional<T&> ot (v1);
ot = v2;
```

You do not have to solve this prolem in `expected<>`. Also, the Standard
has a precedent for this: std:reference_wrapper: it rebinds on assignment.

> so we should *never* support references.
>>
>
> Sounds like a good plan to me.
>

Then you will have to work aroun with `expected<reference_wrapper<T>>`.

Regards,
&rzej;


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