diff --git a/doc/90_dependencies.qbk b/doc/90_dependencies.qbk index 0dab296..d033b08 100644 --- a/doc/90_dependencies.qbk +++ b/doc/90_dependencies.qbk @@ -18,11 +18,10 @@ The implementation uses the following other Boost modules: # config # core # move -# mpl +# predef # static_assert # throw_exception # type_traits -# utility [endsect] diff --git a/doc/91_relnotes.qbk b/doc/91_relnotes.qbk index 781d406..9307a24 100644 --- a/doc/91_relnotes.qbk +++ b/doc/91_relnotes.qbk @@ -14,6 +14,8 @@ [heading Boost Release 1.87] * *Breaking change.* Dropped support for C++03. C++11 is now the required minimum. +* Dropped dependency on Boost.Utility. +* A bit faster implementation of some relational operations. [heading Boost Release 1.85] diff --git a/include/boost/optional/detail/optional_relops.hpp b/include/boost/optional/detail/optional_relops.hpp index 1c15578..c7766fc 100644 --- a/include/boost/optional/detail/optional_relops.hpp +++ b/include/boost/optional/detail/optional_relops.hpp @@ -1,5 +1,5 @@ // Copyright (C) 2003, 2008 Fernando Luis Cacciola Carballal. -// Copyright (C) 2015 Andrzej Krzemienski. +// Copyright (C) 2015, 2024 Andrzej Krzemienski. // // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -16,7 +16,8 @@ namespace boost { // optional's relational operators ( ==, !=, <, >, <=, >= ) have deep-semantics (compare values). -// WARNING: This is UNLIKE pointers. Use equal_pointees()/less_pointees() in generic code instead. +// WARNING: This is UNLIKE pointers. Use equal_pointees()/less_pointees() in generic code instead, +// to obtain the same semantic for pointers. // @@ -31,7 +32,7 @@ bool operator == ( optional const& x, optional const& y ) template inline bool operator < ( optional const& x, optional const& y ) -{ return less_pointees(x,y); } +{ return !y ? false : (!x ? true : (*x) < (*y)); } template inline @@ -60,12 +61,12 @@ bool operator >= ( optional const& x, optional const& y ) template inline bool operator == ( optional const& x, T const& y ) -{ return equal_pointees(x, optional(y)); } +{ return x && (*x == y); } template inline bool operator < ( optional const& x, T const& y ) -{ return less_pointees(x, optional(y)); } +{ return (!x) || (*x < y); } template inline @@ -94,12 +95,12 @@ bool operator >= ( optional const& x, T const& y ) template inline bool operator == ( T const& x, optional const& y ) -{ return equal_pointees( optional(x), y ); } +{ return y && (x == *y); } template inline bool operator < ( T const& x, optional const& y ) -{ return less_pointees( optional(x), y ); } +{ return y && (x < *y); } template inline @@ -134,7 +135,7 @@ bool operator == ( optional const& x, none_t ) BOOST_NOEXCEPT template inline bool operator < ( optional const& x, none_t ) -{ return less_pointees(x,optional() ); } +{ return false; } template inline @@ -168,7 +169,7 @@ bool operator == ( none_t , optional const& y ) BOOST_NOEXCEPT template inline bool operator < ( none_t , optional const& y ) -{ return less_pointees(optional() ,y); } +{ return bool(y); } template inline @@ -193,4 +194,3 @@ bool operator >= ( none_t x, optional const& y ) } // namespace boost #endif // header guard - diff --git a/include/boost/optional/optional.hpp b/include/boost/optional/optional.hpp index 22221d2..57ff8ef 100644 --- a/include/boost/optional/optional.hpp +++ b/include/boost/optional/optional.hpp @@ -59,7 +59,6 @@ #include #include #include -#include #include #include