Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:43:20

0001 // Copyright (C) 2003, 2008 Fernando Luis Cacciola Carballal.
0002 // Copyright (C) 2015 Andrzej Krzemienski.
0003 //
0004 // Use, modification, and distribution is subject to the Boost Software
0005 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt)
0007 //
0008 // See http://www.boost.org/libs/optional for documentation.
0009 //
0010 // You are welcome to contact the author at:
0011 //  akrzemi1@gmail.com
0012 
0013 #ifndef BOOST_OPTIONAL_DETAIL_OPTIONAL_RELOPS_AJK_03OCT2015_HPP
0014 #define BOOST_OPTIONAL_DETAIL_OPTIONAL_RELOPS_AJK_03OCT2015_HPP
0015 
0016 namespace boost {
0017 
0018 // optional's relational operators ( ==, !=, <, >, <=, >= ) have deep-semantics (compare values).
0019 // WARNING: This is UNLIKE pointers. Use equal_pointees()/less_pointees() in generic code instead.
0020 
0021 
0022 //
0023 // optional<T> vs optional<T> cases
0024 //
0025 
0026 template<class T>
0027 inline
0028 bool operator == ( optional<T> const& x, optional<T> const& y )
0029 { return bool(x) && bool(y) ? *x == *y : bool(x) == bool(y); }
0030 
0031 template<class T>
0032 inline
0033 bool operator < ( optional<T> const& x, optional<T> const& y )
0034 { return less_pointees(x,y); }
0035 
0036 template<class T>
0037 inline
0038 bool operator != ( optional<T> const& x, optional<T> const& y )
0039 { return !( x == y ) ; }
0040 
0041 template<class T>
0042 inline
0043 bool operator > ( optional<T> const& x, optional<T> const& y )
0044 { return y < x ; }
0045 
0046 template<class T>
0047 inline
0048 bool operator <= ( optional<T> const& x, optional<T> const& y )
0049 { return !( y < x ) ; }
0050 
0051 template<class T>
0052 inline
0053 bool operator >= ( optional<T> const& x, optional<T> const& y )
0054 { return !( x < y ) ; }
0055 
0056 
0057 //
0058 // optional<T> vs T cases
0059 //
0060 template<class T>
0061 inline
0062 bool operator == ( optional<T> const& x, T const& y )
0063 { return equal_pointees(x, optional<T>(y)); }
0064 
0065 template<class T>
0066 inline
0067 bool operator < ( optional<T> const& x, T const& y )
0068 { return less_pointees(x, optional<T>(y)); }
0069 
0070 template<class T>
0071 inline
0072 bool operator != ( optional<T> const& x, T const& y )
0073 { return !( x == y ) ; }
0074 
0075 template<class T>
0076 inline
0077 bool operator > ( optional<T> const& x, T const& y )
0078 { return y < x ; }
0079 
0080 template<class T>
0081 inline
0082 bool operator <= ( optional<T> const& x, T const& y )
0083 { return !( y < x ) ; }
0084 
0085 template<class T>
0086 inline
0087 bool operator >= ( optional<T> const& x, T const& y )
0088 { return !( x < y ) ; }
0089 
0090 //
0091 // T vs optional<T> cases
0092 //
0093 
0094 template<class T>
0095 inline
0096 bool operator == ( T const& x, optional<T> const& y )
0097 { return equal_pointees( optional<T>(x), y ); }
0098 
0099 template<class T>
0100 inline
0101 bool operator < ( T const& x, optional<T> const& y )
0102 { return less_pointees( optional<T>(x), y ); }
0103 
0104 template<class T>
0105 inline
0106 bool operator != ( T const& x, optional<T> const& y )
0107 { return !( x == y ) ; }
0108 
0109 template<class T>
0110 inline
0111 bool operator > ( T const& x, optional<T> const& y )
0112 { return y < x ; }
0113 
0114 template<class T>
0115 inline
0116 bool operator <= ( T const& x, optional<T> const& y )
0117 { return !( y < x ) ; }
0118 
0119 template<class T>
0120 inline
0121 bool operator >= ( T const& x, optional<T> const& y )
0122 { return !( x < y ) ; }
0123 
0124 
0125 //
0126 // optional<T> vs none cases
0127 //
0128 
0129 template<class T>
0130 inline
0131 bool operator == ( optional<T> const& x, none_t ) BOOST_NOEXCEPT
0132 { return !x; }
0133 
0134 template<class T>
0135 inline
0136 bool operator < ( optional<T> const& x, none_t )
0137 { return less_pointees(x,optional<T>() ); }
0138 
0139 template<class T>
0140 inline
0141 bool operator != ( optional<T> const& x, none_t ) BOOST_NOEXCEPT
0142 { return bool(x); }
0143 
0144 template<class T>
0145 inline
0146 bool operator > ( optional<T> const& x, none_t y )
0147 { return y < x ; }
0148 
0149 template<class T>
0150 inline
0151 bool operator <= ( optional<T> const& x, none_t y )
0152 { return !( y < x ) ; }
0153 
0154 template<class T>
0155 inline
0156 bool operator >= ( optional<T> const& x, none_t y )
0157 { return !( x < y ) ; }
0158 
0159 //
0160 // none vs optional<T> cases
0161 //
0162 
0163 template<class T>
0164 inline
0165 bool operator == ( none_t , optional<T> const& y ) BOOST_NOEXCEPT
0166 { return !y; }
0167 
0168 template<class T>
0169 inline
0170 bool operator < ( none_t , optional<T> const& y )
0171 { return less_pointees(optional<T>() ,y); }
0172 
0173 template<class T>
0174 inline
0175 bool operator != ( none_t, optional<T> const& y ) BOOST_NOEXCEPT
0176 { return bool(y); }
0177 
0178 template<class T>
0179 inline
0180 bool operator > ( none_t x, optional<T> const& y )
0181 { return y < x ; }
0182 
0183 template<class T>
0184 inline
0185 bool operator <= ( none_t x, optional<T> const& y )
0186 { return !( y < x ) ; }
0187 
0188 template<class T>
0189 inline
0190 bool operator >= ( none_t x, optional<T> const& y )
0191 { return !( x < y ) ; }
0192 
0193 } // namespace boost
0194 
0195 #endif // header guard
0196