123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- // Copyright (C) 2003, 2008 Fernando Luis Cacciola Carballal.
- // Copyright (C) 2015 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
- // http://www.boost.org/LICENSE_1_0.txt)
- //
- // See http://www.boost.org/libs/optional for documentation.
- //
- // You are welcome to contact the author at:
- // akrzemi1@gmail.com
- #ifndef BOOST_OPTIONAL_DETAIL_OPTIONAL_RELOPS_AJK_03OCT2015_HPP
- #define BOOST_OPTIONAL_DETAIL_OPTIONAL_RELOPS_AJK_03OCT2015_HPP
- namespace boost {
- // optional's relational operators ( ==, !=, <, >, <=, >= ) have deep-semantics (compare values).
- // WARNING: This is UNLIKE pointers. Use equal_pointees()/less_pointess() in generic code instead.
- //
- // optional<T> vs optional<T> cases
- //
- template<class T>
- inline
- bool operator == ( optional<T> const& x, optional<T> const& y )
- { return bool(x) && bool(y) ? *x == *y : bool(x) == bool(y); }
- template<class T>
- inline
- bool operator < ( optional<T> const& x, optional<T> const& y )
- { return less_pointees(x,y); }
- template<class T>
- inline
- bool operator != ( optional<T> const& x, optional<T> const& y )
- { return !( x == y ) ; }
- template<class T>
- inline
- bool operator > ( optional<T> const& x, optional<T> const& y )
- { return y < x ; }
- template<class T>
- inline
- bool operator <= ( optional<T> const& x, optional<T> const& y )
- { return !( y < x ) ; }
- template<class T>
- inline
- bool operator >= ( optional<T> const& x, optional<T> const& y )
- { return !( x < y ) ; }
- //
- // optional<T> vs T cases
- //
- template<class T>
- inline
- bool operator == ( optional<T> const& x, T const& y )
- { return equal_pointees(x, optional<T>(y)); }
- template<class T>
- inline
- bool operator < ( optional<T> const& x, T const& y )
- { return less_pointees(x, optional<T>(y)); }
- template<class T>
- inline
- bool operator != ( optional<T> const& x, T const& y )
- { return !( x == y ) ; }
- template<class T>
- inline
- bool operator > ( optional<T> const& x, T const& y )
- { return y < x ; }
- template<class T>
- inline
- bool operator <= ( optional<T> const& x, T const& y )
- { return !( y < x ) ; }
- template<class T>
- inline
- bool operator >= ( optional<T> const& x, T const& y )
- { return !( x < y ) ; }
- //
- // T vs optional<T> cases
- //
- template<class T>
- inline
- bool operator == ( T const& x, optional<T> const& y )
- { return equal_pointees( optional<T>(x), y ); }
- template<class T>
- inline
- bool operator < ( T const& x, optional<T> const& y )
- { return less_pointees( optional<T>(x), y ); }
- template<class T>
- inline
- bool operator != ( T const& x, optional<T> const& y )
- { return !( x == y ) ; }
- template<class T>
- inline
- bool operator > ( T const& x, optional<T> const& y )
- { return y < x ; }
- template<class T>
- inline
- bool operator <= ( T const& x, optional<T> const& y )
- { return !( y < x ) ; }
- template<class T>
- inline
- bool operator >= ( T const& x, optional<T> const& y )
- { return !( x < y ) ; }
- //
- // optional<T> vs none cases
- //
- template<class T>
- inline
- bool operator == ( optional<T> const& x, none_t ) BOOST_NOEXCEPT
- { return !x; }
- template<class T>
- inline
- bool operator < ( optional<T> const& x, none_t )
- { return less_pointees(x,optional<T>() ); }
- template<class T>
- inline
- bool operator != ( optional<T> const& x, none_t ) BOOST_NOEXCEPT
- { return bool(x); }
- template<class T>
- inline
- bool operator > ( optional<T> const& x, none_t y )
- { return y < x ; }
- template<class T>
- inline
- bool operator <= ( optional<T> const& x, none_t y )
- { return !( y < x ) ; }
- template<class T>
- inline
- bool operator >= ( optional<T> const& x, none_t y )
- { return !( x < y ) ; }
- //
- // none vs optional<T> cases
- //
- template<class T>
- inline
- bool operator == ( none_t , optional<T> const& y ) BOOST_NOEXCEPT
- { return !y; }
- template<class T>
- inline
- bool operator < ( none_t , optional<T> const& y )
- { return less_pointees(optional<T>() ,y); }
- template<class T>
- inline
- bool operator != ( none_t, optional<T> const& y ) BOOST_NOEXCEPT
- { return bool(y); }
- template<class T>
- inline
- bool operator > ( none_t x, optional<T> const& y )
- { return y < x ; }
- template<class T>
- inline
- bool operator <= ( none_t x, optional<T> const& y )
- { return !( y < x ) ; }
- template<class T>
- inline
- bool operator >= ( none_t x, optional<T> const& y )
- { return !( x < y ) ; }
- } // namespace boost
- #endif // header guard
|