Let’s Talk about std::optional<T&> and optional references
This should have been part 2 of my comparison series, and I have almost finished it, but due to university stuff I just haven’t found the time to polish it.
But the optional discussion started again, so I just wanted to really quickly share my raw thoughts on the topic.
In case you are lucky and don’t know what I mean:
std::optional<T&>
doesn’t compile right now, because the behavior of assignment wasn’t clear (even though it actually is).
There are basically four questions in the discussion I want to answer:
- Is
std::optional<T&>
the same as a pointer? - Do we need
std::optional<T&>
? - Should the assignment operator rebind or assign through?
- Should it even have an assignment operator?
tl;dr: no, I don’t, rebind, no.
» read more »