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