optional_relops.hpp
Go to the documentation of this file.
1 // Copyright (C) 2003, 2008 Fernando Luis Cacciola Carballal.
2 // Copyright (C) 2015 Andrzej Krzemienski.
3 //
4 // Use, modification, and distribution is subject to the Boost Software
5 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //
8 // See http://www.boost.org/libs/optional for documentation.
9 //
10 // You are welcome to contact the author at:
11 // akrzemi1@gmail.com
12 
13 #ifndef BOOST_OPTIONAL_DETAIL_OPTIONAL_RELOPS_AJK_03OCT2015_HPP
14 #define BOOST_OPTIONAL_DETAIL_OPTIONAL_RELOPS_AJK_03OCT2015_HPP
15 
16 namespace boost {
17 
18 // optional's relational operators ( ==, !=, <, >, <=, >= ) have deep-semantics (compare values).
19 // WARNING: This is UNLIKE pointers. Use equal_pointees()/less_pointess() in generic code instead.
20 
21 
22 //
23 // optional<T> vs optional<T> cases
24 //
25 
26 template<class T>
27 inline
28 bool operator == ( optional<T> const& x, optional<T> const& y )
29 { return equal_pointees(x,y); }
30 
31 template<class T>
32 inline
33 bool operator < ( optional<T> const& x, optional<T> const& y )
34 { return less_pointees(x,y); }
35 
36 template<class T>
37 inline
38 bool operator != ( optional<T> const& x, optional<T> const& y )
39 { return !( x == y ) ; }
40 
41 template<class T>
42 inline
43 bool operator > ( optional<T> const& x, optional<T> const& y )
44 { return y < x ; }
45 
46 template<class T>
47 inline
48 bool operator <= ( optional<T> const& x, optional<T> const& y )
49 { return !( y < x ) ; }
50 
51 template<class T>
52 inline
53 bool operator >= ( optional<T> const& x, optional<T> const& y )
54 { return !( x < y ) ; }
55 
56 
57 //
58 // optional<T> vs T cases
59 //
60 template<class T>
61 inline
62 bool operator == ( optional<T> const& x, T const& y )
63 { return equal_pointees(x, optional<T>(y)); }
64 
65 template<class T>
66 inline
67 bool operator < ( optional<T> const& x, T const& y )
68 { return less_pointees(x, optional<T>(y)); }
69 
70 template<class T>
71 inline
72 bool operator != ( optional<T> const& x, T const& y )
73 { return !( x == y ) ; }
74 
75 template<class T>
76 inline
77 bool operator > ( optional<T> const& x, T const& y )
78 { return y < x ; }
79 
80 template<class T>
81 inline
82 bool operator <= ( optional<T> const& x, T const& y )
83 { return !( y < x ) ; }
84 
85 template<class T>
86 inline
87 bool operator >= ( optional<T> const& x, T const& y )
88 { return !( x < y ) ; }
89 
90 //
91 // T vs optional<T> cases
92 //
93 
94 template<class T>
95 inline
96 bool operator == ( T const& x, optional<T> const& y )
97 { return equal_pointees( optional<T>(x), y ); }
98 
99 template<class T>
100 inline
101 bool operator < ( T const& x, optional<T> const& y )
102 { return less_pointees( optional<T>(x), y ); }
103 
104 template<class T>
105 inline
106 bool operator != ( T const& x, optional<T> const& y )
107 { return !( x == y ) ; }
108 
109 template<class T>
110 inline
111 bool operator > ( T const& x, optional<T> const& y )
112 { return y < x ; }
113 
114 template<class T>
115 inline
116 bool operator <= ( T const& x, optional<T> const& y )
117 { return !( y < x ) ; }
118 
119 template<class T>
120 inline
121 bool operator >= ( T const& x, optional<T> const& y )
122 { return !( x < y ) ; }
123 
124 
125 //
126 // optional<T> vs none cases
127 //
128 
129 template<class T>
130 inline
132 { return !x; }
133 
134 template<class T>
135 inline
136 bool operator < ( optional<T> const& x, none_t )
137 { return less_pointees(x,optional<T>() ); }
138 
139 template<class T>
140 inline
142 { return bool(x); }
143 
144 template<class T>
145 inline
146 bool operator > ( optional<T> const& x, none_t y )
147 { return y < x ; }
148 
149 template<class T>
150 inline
151 bool operator <= ( optional<T> const& x, none_t y )
152 { return !( y < x ) ; }
153 
154 template<class T>
155 inline
156 bool operator >= ( optional<T> const& x, none_t y )
157 { return !( x < y ) ; }
158 
159 //
160 // none vs optional<T> cases
161 //
162 
163 template<class T>
164 inline
166 { return !y; }
167 
168 template<class T>
169 inline
170 bool operator < ( none_t , optional<T> const& y )
171 { return less_pointees(optional<T>() ,y); }
172 
173 template<class T>
174 inline
176 { return bool(y); }
177 
178 template<class T>
179 inline
180 bool operator > ( none_t x, optional<T> const& y )
181 { return y < x ; }
182 
183 template<class T>
184 inline
185 bool operator <= ( none_t x, optional<T> const& y )
186 { return !( y < x ) ; }
187 
188 template<class T>
189 inline
190 bool operator >= ( none_t x, optional<T> const& y )
191 { return !( x < y ) ; }
192 
193 } // namespace boost
194 
195 #endif // header guard
196 
boost::operator<
bool operator<(optional< T > const &x, optional< T > const &y)
Definition: optional_relops.hpp:33
T
T
Definition: mem_fn_cc.hpp:25
boost::operator>
bool operator>(optional< T > const &x, optional< T > const &y)
Definition: optional_relops.hpp:43
boost::less_pointees
bool less_pointees(OptionalPointee const &x, OptionalPointee const &y)
Definition: compare_pointees.hpp:53
boost::operator>=
bool operator>=(optional< T > const &x, optional< T > const &y)
Definition: optional_relops.hpp:53
boost::operator<=
bool operator<=(optional< T > const &x, optional< T > const &y)
Definition: optional_relops.hpp:48
boost
BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE.
boost::none_t
Definition: none_t.hpp:29
boost::equal_pointees
bool equal_pointees(OptionalPointee const &x, OptionalPointee const &y)
Definition: compare_pointees.hpp:30
BOOST_NOEXCEPT
#define BOOST_NOEXCEPT
Definition: suffix.hpp:938
boost::operator==
BOOST_CONSTEXPR bool operator==(arg< I > const &, arg< I > const &)
Definition: bind/arg.hpp:41
boost::operator!=
bool operator!=(optional< T > const &x, optional< T > const &y)
Definition: optional_relops.hpp:38
boost::optional
Definition: old_optional_implementation.hpp:646


sick_visionary_ros
Author(s): SICK AG TechSupport 3D Snapshot
autogenerated on Thu Feb 8 2024 03:45:34