5 ms·
Does that prevent the usage shown in the blog post? std::optional<unsigned> opt = firstEvenNumberIn(text); if (opt)
by hoppelhase 8y ago
Does that prevent the usage shown in the blog post?
std::optional<unsigned> opt = firstEvenNumberIn(text);
if (opt)
- geezerjay 8y agoThat usage means "was the optional value set?" That's the whole point of an optional type, and there is absolutely no reason to prevent it.
- hoppelhase 8y agoThere is. See: https://news.ycombinator.com/item?id=17275784 https://news.ycombinator.com/item?id=17275784
- geezerjay 8y agoI've already explained why that argument makes no sense https://news.ycombinator.com/item?id=17276845 https://news.ycombinator.com/item?id=17276845
- hoppelhase 8y agoCould you elaborate more on why having the compiler tell us that we forgot to change something wouldn't be a good thing?