On 11/20/2014 08:22 AM, Vladimir Batov wrote:
On 11/19/2014 07:37 PM, Andrzej Krzemienski wrote:
... optional<double> Aircraft::weight() { if (Impl* impl = get_impl()) return impl->compute_weight(); else return none; }
double Aircraft::max_weight() { return 10000.0; }
bool too_heavy(Aircraft& ac) { return ac.weight() > ac.max_weight(); // in "safe" optional compiler would spot the bug }
There is no bug here! Not from the human perspectives. You are comparing two extremely closely related types! As long as we agree on how "none" is treated, then all kosher. We do compare "ints" with "doubles", don't we? No "safety" concerns.
On the second thought I might probably agree that op<() might be questionable... Can we address that differently then? Say, bool operator<(T const&, optional<T> const&) { BOOST_STATIC_ASSERT(); }