Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Mixed relational comparisons

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 

PrevUpHomeNext