Ice 3.7 C++98 API Reference
Loading...
Searching...
No Matches
Comparable.h
Go to the documentation of this file.
1//
2// Copyright (c) ZeroC, Inc. All rights reserved.
3//
4
5#ifndef ICE_COMPARABLE_H
6#define ICE_COMPARABLE_H
7
8#include <functional>
9
10namespace Ice
11{
12
19template<typename T, typename U>
20inline bool targetEqualTo(const T& lhs, const U& rhs)
21{
22 if(lhs && rhs)
23 {
24 return *lhs == *rhs;
25 }
26 else
27 {
28 return !lhs && !rhs;
29 }
30}
31
38template<typename T, typename U>
39inline bool targetLess(const T& lhs, const U& rhs)
40{
41 if(lhs && rhs)
42 {
43 return *lhs < *rhs;
44 }
45 else
46 {
47 return !lhs && rhs;
48 }
49}
50
57template<typename T, typename U>
58inline bool targetGreater(const T& lhs, const U& rhs)
59{
60 return targetLess(rhs, lhs);
61}
62
69template<typename T, typename U>
70inline bool targetLessEqual(const T& lhs, const U& rhs)
71{
72 return !targetGreater(lhs, rhs);
73}
74
81template<typename T, typename U>
82inline bool targetGreaterEqual(const T& lhs, const U& rhs)
83{
84 return !targetLess(lhs, rhs);
85}
86
93template<typename T, typename U>
94inline bool targetNotEqualTo(const T& lhs, const U& rhs)
95{
96 return !targetEqualTo(lhs, rhs);
97}
98
99#ifdef ICE_CPP11_MAPPING
100
105template<typename T, template<typename> class Compare>
106struct TargetCompare
107{
112 bool operator()(const T& lhs, const T& rhs) const
113 {
114 if(lhs && rhs)
115 {
116 return Compare<typename T::element_type>()(*lhs, *rhs);
117 }
118 else
119 {
120 return Compare<bool>()(static_cast<const bool>(lhs), static_cast<const bool>(rhs));
121 }
122 }
123};
124
125//
126// Relational operators for generated structs and classes
127//
128
135template<class C, typename = std::enable_if<std::is_member_function_pointer<decltype(&C::ice_tuple)>::value>>
136bool operator<(const C& lhs, const C& rhs)
137{
138 return lhs.ice_tuple() < rhs.ice_tuple();
139}
140
147template<class C, typename = std::enable_if<std::is_member_function_pointer<decltype(&C::ice_tuple)>::value>>
148bool operator<=(const C& lhs, const C& rhs)
149{
150 return lhs.ice_tuple() <= rhs.ice_tuple();
151}
152
159template<class C, typename = std::enable_if<std::is_member_function_pointer<decltype(&C::ice_tuple)>::value>>
160bool operator>(const C& lhs, const C& rhs)
161{
162 return lhs.ice_tuple() > rhs.ice_tuple();
163}
164
171template<class C, typename = std::enable_if<std::is_member_function_pointer<decltype(&C::ice_tuple)>::value>>
172bool operator>=(const C& lhs, const C& rhs)
173{
174 return lhs.ice_tuple() >= rhs.ice_tuple();
175}
176
183template<class C, typename = std::enable_if<std::is_member_function_pointer<decltype(&C::ice_tuple)>::value>>
184bool operator==(const C& lhs, const C& rhs)
185{
186 return lhs.ice_tuple() == rhs.ice_tuple();
187}
188
195template<class C, typename = std::enable_if<std::is_member_function_pointer<decltype(&C::ice_tuple)>::value>>
196bool operator!=(const C& lhs, const C& rhs)
197{
198 return lhs.ice_tuple() != rhs.ice_tuple();
199}
200
201#endif
202
203}
204
205#endif
Definition BuiltinSequences.h:113
bool targetNotEqualTo(const T &lhs, const U &rhs)
Compares the contents of two smart pointers.
Definition Comparable.h:94
bool targetEqualTo(const T &lhs, const U &rhs)
Compares the contents of two smart pointers.
Definition Comparable.h:20
bool targetGreater(const T &lhs, const U &rhs)
Compares the contents of two smart pointers.
Definition Comparable.h:58
bool targetLess(const T &lhs, const U &rhs)
Compares the contents of two smart pointers.
Definition Comparable.h:39
bool targetGreaterEqual(const T &lhs, const U &rhs)
Compares the contents of two smart pointers.
Definition Comparable.h:82
bool targetLessEqual(const T &lhs, const U &rhs)
Compares the contents of two smart pointers.
Definition Comparable.h:70