Jamba C++ API 7.5.0
Loading...
Searching...
No Matches
Operators.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 pongasoft
3 *
4 * Licensed under the Apache License, Version 2.0 or the MIT license,
5 * at your option. You may not use this file except in compliance with
6 * one of these licenses. You may obtain copies of the licenses at:
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 * https://opensource.org/licenses/MIT
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 *
17 * @author Yan Pujante
18 */
19
20#pragma once
21
23
54template<typename T>
56{
57public:
58 // LHS is reference, RHS is reference
59 friend constexpr bool operator==(T const &lhs, T const &rhs) { return *lhs == *rhs; }
60
61 friend constexpr bool operator!=(T const &lhs, T const &rhs) { return !(lhs == rhs); }
62
63 friend constexpr bool operator<(T const &lhs, T const &rhs) { return *lhs < *rhs; }
64
65 friend constexpr bool operator>(T const &lhs, T const &rhs) { return rhs < lhs; }
66
67 friend constexpr bool operator<=(T const &lhs, T const &rhs) { return !(rhs < lhs); }
68
69 friend constexpr bool operator>=(T const &lhs, T const &rhs) { return !(lhs < rhs); }
70
71 // LHS is reference, RHS is value
72 template<typename V>
73 friend constexpr bool operator==(T const &lhs, V const &rhs) { return *lhs == rhs; }
74
75 template<typename V>
76 friend constexpr bool operator!=(T const &lhs, V const &rhs) { return !(lhs == rhs); }
77
78 template<typename V>
79 friend constexpr bool operator<(T const &lhs, V const &rhs) { return *lhs < rhs; }
80
81 template<typename V>
82 friend constexpr bool operator>(T const &lhs, V const &rhs) { return !(lhs < rhs) && lhs != rhs; }
83
84 template<typename V>
85 friend constexpr bool operator<=(T const &lhs, V const &rhs) { return !(rhs < lhs); }
86
87 template<typename V>
88 friend constexpr bool operator>=(T const &lhs, V const &rhs) { return !(lhs < rhs); }
89
90 // LHS is value, RHS is reference
91 template<typename V>
92 friend constexpr bool operator==(V const &lhs, T const &rhs) { return rhs == lhs; }
93
94 template<typename V>
95 friend constexpr bool operator!=(V const &lhs, T const &rhs) { return !(lhs == rhs); }
96
97 template<typename V>
98 friend constexpr bool operator<(V const &lhs, T const &rhs) { return rhs > lhs; }
99
100 template<typename V>
101 friend constexpr bool operator>(V const &lhs, T const &rhs) { return rhs < lhs; }
102
103 template<typename V>
104 friend constexpr bool operator<=(V const &lhs, T const &rhs) { return !(rhs < lhs); }
105
106 template<typename V>
107 friend constexpr bool operator>=(V const &lhs, T const &rhs) { return !(lhs < rhs); }
108};
109
110}
Implements all the various equality and relational operators for the type T which is assumed to encap...
Definition Operators.h:56
friend constexpr bool operator>=(T const &lhs, T const &rhs)
Definition Operators.h:69
friend constexpr bool operator>(T const &lhs, V const &rhs)
Definition Operators.h:82
friend constexpr bool operator!=(T const &lhs, T const &rhs)
Definition Operators.h:61
friend constexpr bool operator>(T const &lhs, T const &rhs)
Definition Operators.h:65
friend constexpr bool operator>=(V const &lhs, T const &rhs)
Definition Operators.h:107
friend constexpr bool operator>(V const &lhs, T const &rhs)
Definition Operators.h:101
friend constexpr bool operator!=(T const &lhs, V const &rhs)
Definition Operators.h:76
friend constexpr bool operator==(T const &lhs, T const &rhs)
Definition Operators.h:59
friend constexpr bool operator<=(V const &lhs, T const &rhs)
Definition Operators.h:104
friend constexpr bool operator<=(T const &lhs, T const &rhs)
Definition Operators.h:67
friend constexpr bool operator<(T const &lhs, V const &rhs)
Definition Operators.h:79
friend constexpr bool operator==(V const &lhs, T const &rhs)
Definition Operators.h:92
friend constexpr bool operator<(T const &lhs, T const &rhs)
Definition Operators.h:63
friend constexpr bool operator==(T const &lhs, V const &rhs)
Definition Operators.h:73
friend constexpr bool operator>=(T const &lhs, V const &rhs)
Definition Operators.h:88
friend constexpr bool operator<=(T const &lhs, V const &rhs)
Definition Operators.h:85
friend constexpr bool operator!=(V const &lhs, T const &rhs)
Definition Operators.h:95
friend constexpr bool operator<(V const &lhs, T const &rhs)
Definition Operators.h:98
Definition Operators.h:22