Problem with above, is that it's not so straightforward. I run into issue when developer initialized optional with = std::optional<...>() and were thinking that optional is actually set.
In std::optional we got very nice methods called reset and emplace. I would argue that they should be used instead of above examples. Even std::nullopt is better.
I'm adding this here so, i wouldn't forget. Check name to negotiation.
```
std::optional<int> opt;
...
opt = {};
opt = std::optional<int>();
```
Problem with above, is that it's not so straightforward. I run into issue when developer initialized optional with `= std::optional<...>()` and were thinking that optional is actually set.
In std::optional we got very nice methods called `reset` and `emplace`. I would argue that they should be used instead of above examples. Even `std::nullopt` is better.
I'm adding this here so, i wouldn't forget. Check name to negotiation.
Problem with above, is that it's not so straightforward. I run into issue when developer initialized optional with
= std::optional<...>()
and were thinking that optional is actually set.In std::optional we got very nice methods called
reset
andemplace
. I would argue that they should be used instead of above examples. Evenstd::nullopt
is better.