June 2025
Intermediate to advanced
1093 pages
33h 24m
English
In C++, optional<T> has a slightly different meaning than in Java. There, the “generic” Optional<T> is part of the streaming API and thus represents a “container of size one or zero.” It is recommended not to use it as a parameter for optional values there.
This is different in C++: First, it is not a container that works with algorithms. Second, optional<T> is specifically designed to indicate, as a parameter and return value or in containers, that a value may or may not be present.
The documentation states the intended use: “It is recommended to use optional<T> in situations where there is exactly one clear reason not to have a value of type T, and where the absence of the value seems as natural ...
Read now
Unlock full access