/usr/include/boost/optional/detail
Edit: /usr/include/boost/optional/detail/optional_relops.hpp (4331B)
// 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
vs optional cases
//
template
inline
bool operator == ( optional const& x, optional const& y )
{ return bool(x) && bool(y) ? *x == *y : bool(x) == bool(y); }
template
inline
bool operator < ( optional const& x, optional const& y )
{ return less_pointees(x,y); }
template
inline
bool operator != ( optional const& x, optional const& y )
{ return !( x == y ) ; }
template
inline
bool operator > ( optional const& x, optional const& y )
{ return y < x ; }
template
inline
bool operator <= ( optional const& x, optional const& y )
{ return !( y < x ) ; }
template
inline
bool operator >= ( optional const& x, optional const& y )
{ return !( x < y ) ; }
//
// optional vs T cases
//
template
inline
bool operator == ( optional const& x, T const& y )
{ return equal_pointees(x, optional(y)); }
template
inline
bool operator < ( optional const& x, T const& y )
{ return less_pointees(x, optional(y)); }
template
inline
bool operator != ( optional const& x, T const& y )
{ return !( x == y ) ; }
template
inline
bool operator > ( optional const& x, T const& y )
{ return y < x ; }
template
inline
bool operator <= ( optional const& x, T const& y )
{ return !( y < x ) ; }
template
inline
bool operator >= ( optional const& x, T const& y )
{ return !( x < y ) ; }
//
// T vs optional cases
//
template
inline
bool operator == ( T const& x, optional const& y )
{ return equal_pointees( optional(x), y ); }
template
inline
bool operator < ( T const& x, optional const& y )
{ return less_pointees( optional(x), y ); }
template
inline
bool operator != ( T const& x, optional const& y )
{ return !( x == y ) ; }
template
inline
bool operator > ( T const& x, optional const& y )
{ return y < x ; }
template
inline
bool operator <= ( T const& x, optional const& y )
{ return !( y < x ) ; }
template
inline
bool operator >= ( T const& x, optional const& y )
{ return !( x < y ) ; }
//
// optional vs none cases
//
template
inline
bool operator == ( optional const& x, none_t ) BOOST_NOEXCEPT
{ return !x; }
template
inline
bool operator < ( optional const& x, none_t )
{ return less_pointees(x,optional() ); }
template
inline
bool operator != ( optional const& x, none_t ) BOOST_NOEXCEPT
{ return bool(x); }
template
inline
bool operator > ( optional const& x, none_t y )
{ return y < x ; }
template
inline
bool operator <= ( optional const& x, none_t y )
{ return !( y < x ) ; }
template
inline
bool operator >= ( optional const& x, none_t y )
{ return !( x < y ) ; }
//
// none vs optional cases
//
template
inline
bool operator == ( none_t , optional const& y ) BOOST_NOEXCEPT
{ return !y; }
template
inline
bool operator < ( none_t , optional const& y )
{ return less_pointees(optional() ,y); }
template
inline
bool operator != ( none_t, optional const& y ) BOOST_NOEXCEPT
{ return bool(y); }
template
inline
bool operator > ( none_t x, optional const& y )
{ return y < x ; }
template
inline
bool operator <= ( none_t x, optional const& y )
{ return !( y < x ) ; }
template
inline
bool operator >= ( none_t x, optional const& y )
{ return !( x < y ) ; }
} // namespace boost
#endif // header guard