31 template <
typename L,
typename R>
32 constexpr requires_t<bool, is_equality_comparable<L, R>> operator()(L&& l, R&& r)
const noexcept(
noexcept(l == r)) {
39class equality_operators {
40 template <
typename L,
typename R>
41 constexpr static auto impl(rank<1>, L& l, R& r) BSONCXX_PRIVATE_RETURNS(tag_invoke(equal_to{}, l, r));
43 template <
typename L,
typename R>
44 constexpr static auto impl(rank<0>, L& l, R& r) BSONCXX_PRIVATE_RETURNS(tag_invoke(equal_to{}, r, l));
47 template <
typename Left,
typename Other>
48 constexpr friend auto operator==(Left
const& self, Other
const& other)
49 BSONCXX_PRIVATE_RETURNS(equality_operators::impl(rank<1>{}, self, other));
53 template <
typename Left,
typename Other>
54 constexpr friend auto operator!=(Left
const& self, Other
const& other)
55 BSONCXX_PRIVATE_RETURNS(!equality_operators::impl(rank<1>{}, self, other));
62class strong_ordering {
66 constexpr strong_ordering(_construct,
signed char c) noexcept : _c(c) {}
69 static strong_ordering
const less;
70 static strong_ordering
const greater;
71 static strong_ordering
const equivalent;
72 static strong_ordering
const equal;
74 constexpr strong_ordering(std::nullptr_t) noexcept : strong_ordering(_construct{}, 0) {}
76 constexpr bool operator==(strong_ordering o)
const noexcept {
79 constexpr bool operator!=(strong_ordering o)
const noexcept {
82#pragma push_macro("DEFOP")
85 constexpr bool operator Op(std::nullptr_t) const noexcept { \
88 static_assert(true, "")
93#pragma pop_macro("DEFOP")
96 constexpr strong_ordering inverted() const noexcept {
97 return *this < nullptr ? greater : *this >
nullptr ? less : *
this;
101#pragma push_macro("INLINE_VAR")
104 BSONCXX_PRIVATE_IF_GNU_LIKE([[gnu::weak]]) \
105 BSONCXX_PRIVATE_IF_MSVC(__declspec(selectany))
107INLINE_VAR
const strong_ordering strong_ordering::less = strong_ordering(strong_ordering::_construct{}, -1);
108INLINE_VAR
const strong_ordering strong_ordering::greater = strong_ordering(strong_ordering::_construct{}, 1);
109INLINE_VAR
const strong_ordering strong_ordering::equivalent = strong_ordering(strong_ordering::_construct{}, 0);
110INLINE_VAR
const strong_ordering strong_ordering::equal = strong_ordering(strong_ordering::_construct{}, 0);
112#pragma pop_macro("INLINE_VAR")
117struct compare_three_way {
118 BSONCXX_PRIVATE_WARNINGS_PUSH();
119 BSONCXX_PRIVATE_WARNINGS_DISABLE(GNU(
"-Wfloat-equal"));
123 typename =
decltype(std::declval<L>() < std::declval<R>()),
124 typename =
decltype(std::declval<L>() == std::declval<R>())>
125 constexpr static strong_ordering impl(L
const& l, R
const& r, rank<1>) {
126 return (l < r) ? strong_ordering::less : (l == r ? strong_ordering::equal : strong_ordering::greater);
128 BSONCXX_PRIVATE_WARNINGS_POP();
133 typename =
decltype(tag_invoke(std::declval<compare_three_way>(), std::declval<L>(), std::declval<R>()))>
134 constexpr static strong_ordering impl(L
const& l, R
const& r, rank<2>) {
135 return tag_invoke(compare_three_way{}, l, r);
138 template <
typename L,
typename R>
139 constexpr auto operator()(L
const& l, R
const& r)
const BSONCXX_PRIVATE_RETURNS((impl)(l, r, rank<2>{}));
144struct ordering_operators {
145 template <
typename L,
typename R>
146 constexpr static auto impl(L
const& l, R
const& r, rank<1>)
147 BSONCXX_PRIVATE_RETURNS(tag_invoke(compare_three_way{}, l, r));
149 template <
typename L,
typename R>
150 constexpr static auto impl(L
const& l, R
const& r, rank<0>)
151 BSONCXX_PRIVATE_RETURNS(tag_invoke(compare_three_way{}, r, l).inverted());
153#pragma push_macro("DEFOP")
156 template <typename L, typename R> \
157 constexpr friend auto operator Oper(L const& l, R const& r) \
158 BSONCXX_PRIVATE_RETURNS(ordering_operators::impl(l, r, rank<1>{}) Oper nullptr)
163#pragma pop_macro("DEFOP")
The bsoncxx v1 macro guard postlude header.
The bsoncxx v1 macro guard prelude header.
bool operator!=(element const &elem, types::bson_value::view const &v)
Convenience methods to compare for equality against a bson_value.
The top-level namespace within which all bsoncxx library entities are declared.
bool operator==(view_or_value< View, Value > const &lhs, view_or_value< View, Value > const &rhs)
Compare view_or_value objects for (in)equality.
Definition view_or_value.hpp:151