Date: Mon, 2 Aug 2021 23:31:22 +0200
On Mon, Aug 2, 2021 at 5:18 PM Barry Revzin via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> optional<T&> simply treats T& as a *value *rather than a *reference*.
> Once you accept that, you'll see that it's the same semantic.
>
To try to bring it a bit more to the original topic...
I do not know how much library writers would be upset at this compromise,
but could we get the std::optional<T&> with disabled operator = in C++?
In my experience most of the usecases for this proposed map function is:
if (/*...found ...*/){
// do something nonmutable with valu
else {
// nothing or something that does not involve value.
}
Notice that does not require me to be able to assign to returned
optional<mapped_type&>.
Obviously I observe a tiny part of C++ universe so IDK what are general
patterns of map usage among millions of developers.
Also some could argue that allowing references as optional template
arguments but then deleting one operator is confusing to beginners.
std-proposals_at_[hidden]> wrote:
> optional<T&> simply treats T& as a *value *rather than a *reference*.
> Once you accept that, you'll see that it's the same semantic.
>
To try to bring it a bit more to the original topic...
I do not know how much library writers would be upset at this compromise,
but could we get the std::optional<T&> with disabled operator = in C++?
In my experience most of the usecases for this proposed map function is:
if (/*...found ...*/){
// do something nonmutable with valu
else {
// nothing or something that does not involve value.
}
Notice that does not require me to be able to assign to returned
optional<mapped_type&>.
Obviously I observe a tiny part of C++ universe so IDK what are general
patterns of map usage among millions of developers.
Also some could argue that allowing references as optional template
arguments but then deleting one operator is confusing to beginners.
Received on 2021-08-02 16:31:35