dpiponi, Let me tell you about my embarrassingly stupid C++ mistake so you don't have to make it:
If X is of type std::optional<T> and Y is of type T you can assign Y to X like so:
X = Y
I sort of don't like that because X and Y are different types.
You can also write
*X = Y
which works because *X is of type T&. Now the types match.
But woe is me! Don't do the latter. If X is an empty optional then *X = Y fails silently.
It's obvious when you think about it for a moment. But when you're thinking about the bigger picture you can forget about the little things.