@@ -127,6 +127,22 @@ class view_or_value {
127
127
View _view;
128
128
};
129
129
130
+ // /
131
+ // / Compare view_or_value objects.
132
+ // /
133
+
134
+ template <typename View, typename Value>
135
+ BSONCXX_INLINE bool operator ==(const view_or_value<View, Value>& lhs,
136
+ const view_or_value<View, Value>& rhs) {
137
+ return lhs.view () == rhs.view ();
138
+ }
139
+
140
+ template <typename View, typename Value>
141
+ BSONCXX_INLINE bool operator !=(const view_or_value<View, Value>& lhs,
142
+ const view_or_value<View, Value>& rhs) {
143
+ return !(lhs == rhs);
144
+ }
145
+
130
146
// /
131
147
// / Equality operators for comparison with plain Views.
132
148
// /
@@ -151,6 +167,30 @@ BSONCXX_INLINE bool operator!=(View lhs, const view_or_value<View, Value>& rhs)
151
167
return !(rhs == lhs);
152
168
}
153
169
170
+ // /
171
+ // / Equality operators for comparison with plain Values.
172
+ // /
173
+
174
+ template <typename View, typename Value>
175
+ BSONCXX_INLINE bool operator ==(const view_or_value<View, Value>& lhs, const Value& rhs) {
176
+ return lhs.view () == View (rhs);
177
+ }
178
+
179
+ template <typename View, typename Value>
180
+ BSONCXX_INLINE bool operator ==(const Value& lhs, const view_or_value<View, Value>& rhs) {
181
+ return rhs == lhs;
182
+ }
183
+
184
+ template <typename View, typename Value>
185
+ BSONCXX_INLINE bool operator !=(const view_or_value<View, Value>& lhs, const Value& rhs) {
186
+ return !(lhs == rhs);
187
+ }
188
+
189
+ template <typename View, typename Value>
190
+ BSONCXX_INLINE bool operator !=(const Value& lhs, const view_or_value<View, Value>& rhs) {
191
+ return !(rhs == lhs);
192
+ }
193
+
154
194
BSONCXX_INLINE_NAMESPACE_END
155
195
} // namespace bsoncxx
156
196
0 commit comments