std:optional
a view containing at most one element. (C++26) - HN
the idea of “an optional type is a list with zero or one items in it” is much more normal in functional places
The original design (N3527 over a decade ago) for std::optional specifically says it’s not the container with exactly zero or one items
Scala has it like this since day one. Tried to convince D to adopt it, but was unsuccessful.
Written on November 23, 2025, Last update on
c++
optional
rust
scala
dlang