Assignment for optional--Barry Revzin
Highly non trivial.
Assignment for optional<T>
by Barry Revzin
From the article:
Let’s talk about assignment for optional<T>. I realize this is a fraught topic, but I want to try to build up proper intuition about how assignment has to work, especially since the debate around this topic has been fairly underwhelming. This post will almost exclusively discuss copy assignment (i.e. the one that takes an optional<T> const&), since everything just follows from that...