Ice 3.8
C++ API Reference
Loading...
Searching...
No Matches
TupleCompare.h
1// Copyright (c) ZeroC, Inc.
2
3#ifndef ICE_TUPLE_COMPARE_H
4#define ICE_TUPLE_COMPARE_H
5
6#include <tuple>
7#include <type_traits>
8
9/// Relational operators for generated structs.
10namespace Ice::Tuple
11{
12 /// Operator less-than for generated structs.
13 /// @tparam T The type of the generated struct.
14 /// @param lhs The left-hand side.
15 /// @param rhs The right-hand side.
16 /// @return `true` if @p lhs is less than @p rhs, `false` otherwise.
17 template<
18 class T,
19 std::enable_if_t<
20 std::is_member_function_pointer_v<decltype(&T::ice_tuple)> && !std::is_polymorphic_v<T>,
21 bool> = true>
22 inline bool operator<(const T& lhs, const T& rhs)
23 {
24 return lhs.ice_tuple() < rhs.ice_tuple();
25 }
26
27 /// Operator less-than or equal to for generated structs.
28 /// @tparam T The type of the generated struct.
29 /// @param lhs The left-hand side.
30 /// @param rhs The right-hand side.
31 /// @return `true` if @p lhs is less than or equal to @p rhs, `false` otherwise.
32 template<
33 class T,
34 std::enable_if_t<
35 std::is_member_function_pointer_v<decltype(&T::ice_tuple)> && !std::is_polymorphic_v<T>,
36 bool> = true>
37 inline bool operator<=(const T& lhs, const T& rhs)
38 {
39 return lhs.ice_tuple() <= rhs.ice_tuple();
40 }
41
42 /// Operator greater-than for generated structs.
43 /// @tparam T The type of the generated struct.
44 /// @param lhs The left-hand side.
45 /// @param rhs The right-hand side.
46 /// @return `true` if @p lhs is greater than @p rhs, `false` otherwise.
47 template<
48 class T,
49 std::enable_if_t<
50 std::is_member_function_pointer_v<decltype(&T::ice_tuple)> && !std::is_polymorphic_v<T>,
51 bool> = true>
52 inline bool operator>(const T& lhs, const T& rhs)
53 {
54 return lhs.ice_tuple() > rhs.ice_tuple();
55 }
56
57 /// Operator greater-than or equal to for generated structs.
58 /// @tparam T The type of the generated struct.
59 /// @param lhs The left-hand side.
60 /// @param rhs The right-hand side.
61 /// @return `true` if @p lhs is greater than or equal to @p rhs, `false` otherwise.
62 template<
63 class T,
64 std::enable_if_t<
65 std::is_member_function_pointer_v<decltype(&T::ice_tuple)> && !std::is_polymorphic_v<T>,
66 bool> = true>
67 inline bool operator>=(const T& lhs, const T& rhs)
68 {
69 return lhs.ice_tuple() >= rhs.ice_tuple();
70 }
71
72 /// Operator equal to for generated structs.
73 /// @tparam T The type of the generated struct.
74 /// @param lhs The left-hand side.
75 /// @param rhs The right-hand side.
76 /// @return `true` if @p lhs is equal to @p rhs, `false` otherwise.
77 template<
78 class T,
79 std::enable_if_t<
80 std::is_member_function_pointer_v<decltype(&T::ice_tuple)> && !std::is_polymorphic_v<T>,
81 bool> = true>
82 inline bool operator==(const T& lhs, const T& rhs)
83 {
84 return lhs.ice_tuple() == rhs.ice_tuple();
85 }
86
87 /// Operator not equal to for generated structs.
88 /// @tparam T The type of the generated struct.
89 /// @param lhs The left-hand side.
90 /// @param rhs The right-hand side.
91 /// @return `true` if @p lhs is not equal to @p rhs, `false` otherwise.
92 template<
93 class T,
94 std::enable_if_t<
95 std::is_member_function_pointer_v<decltype(&T::ice_tuple)> && !std::is_polymorphic_v<T>,
96 bool> = true>
97 inline bool operator!=(const T& lhs, const T& rhs)
98 {
99 return lhs.ice_tuple() != rhs.ice_tuple();
100 }
101}
102
103#endif
Relational operators for generated structs.