...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Because T
is convertible
to optional<T>
and because opiotnal<T>
is LessThanComparable
when T
is LessThanComparable
, you can sometimes
get an unexpected runtime result where you would rather expect a compiler
error:
optional<double> Flight_plan::weight(); // sometimes no weight can be returned bool is_aircraft_too_heavy(Flight_plan const& p) { return p.weight() > p.aircraft().max_weight(); // compiles! } // returns false when the optional contains no value