28template <
typename L,
typename R>
29auto is_equality_comparable_f(...) -> std::false_type;
31BSONCXX_PUSH_WARNINGS();
32BSONCXX_DISABLE_WARNING(GNU(
"-Wfloat-equal"));
33template <
typename L,
typename R>
34auto is_equality_comparable_f(
int,
bool b =
false)
35 -> true_t<decltype((std::declval<const L&>() == std::declval<const R&>()) ? 0 : 0,
36 (
std::declval<const R&>() ==
std::declval<const L&>()) ? 0 : 0,
37 (
std::declval<const L&>() !=
std::declval<const R&>()) ? 0 : 0,
38 (
std::declval<const R&>() !=
std::declval<const L&>()) ? 0 : 0)>;
39BSONCXX_POP_WARNINGS();
44template <
typename L,
typename R = L>
45struct is_equality_comparable : decltype(is_equality_comparable_f<L, R>(0)) {};
49 template <
typename L,
typename R>
50 constexpr requires_t<bool, is_equality_comparable<L, R>>
51 operator()(L&& l, R&& r)
const noexcept(
noexcept(l == r)) {
58class equality_operators {
59 template <
typename L,
typename R>
60 constexpr static auto impl(rank<1>, L& l, R& r) BSONCXX_RETURNS(tag_invoke(equal_to{}, l, r));
62 template <
typename L,
typename R>
63 constexpr static auto impl(rank<0>, L& l, R& r) BSONCXX_RETURNS(tag_invoke(equal_to{}, r, l));
66 template <
typename Left,
typename Other>
67 constexpr friend auto operator==(
const Left& self,
const Other& other)
68 BSONCXX_RETURNS(equality_operators::impl(rank<1>{}, self, other));
72 template <
typename Left,
typename Other>
73 constexpr friend auto operator!=(
const Left& self,
const Other& other)
74 BSONCXX_RETURNS(!equality_operators::impl(rank<1>{}, self, other));
81class strong_ordering {
85 constexpr strong_ordering(_construct,
signed char c) noexcept : _c(c) {}
88 static const strong_ordering less;
89 static const strong_ordering greater;
90 static const strong_ordering equivalent;
91 static const strong_ordering equal;
93 constexpr strong_ordering(std::nullptr_t) noexcept : strong_ordering(_construct{}, 0) {}
95 constexpr bool operator==(strong_ordering o)
const noexcept {
98 constexpr bool operator!=(strong_ordering o)
const noexcept {
101#pragma push_macro("DEFOP")
104 constexpr bool operator Op(std::nullptr_t) const noexcept { \
107 static_assert(true, "")
112#pragma pop_macro("DEFOP")
115 constexpr strong_ordering inverted() const noexcept {
116 return *this < nullptr ? greater : *this >
nullptr ? less : *
this;
120#pragma push_macro("INLINE_VAR")
122#define INLINE_VAR BSONCXX_IF_GNU_LIKE([[gnu::weak]]) BSONCXX_IF_MSVC(__declspec(selectany))
124INLINE_VAR
const strong_ordering strong_ordering::less =
125 strong_ordering(strong_ordering::_construct{}, -1);
126INLINE_VAR
const strong_ordering strong_ordering::greater =
127 strong_ordering(strong_ordering::_construct{}, 1);
128INLINE_VAR
const strong_ordering strong_ordering::equivalent =
129 strong_ordering(strong_ordering::_construct{}, 0);
130INLINE_VAR
const strong_ordering strong_ordering::equal =
131 strong_ordering(strong_ordering::_construct{}, 0);
133#pragma pop_macro("INLINE_VAR")
138struct compare_three_way {
139 BSONCXX_PUSH_WARNINGS();
140 BSONCXX_DISABLE_WARNING(GNU(
"-Wfloat-equal"));
141 template <
typename L,
143 typename =
decltype(std::declval<L>() < std::declval<R>()),
144 typename =
decltype(std::declval<L>() == std::declval<R>())>
145 constexpr static strong_ordering impl(L
const& l, R
const& r, rank<1>) {
146 return (l < r) ? strong_ordering::less
147 : (l == r ? strong_ordering::equal
148 : strong_ordering::greater);
150 BSONCXX_POP_WARNINGS();
152 template <
typename L,
154 typename =
decltype(tag_invoke(
155 std::declval<compare_three_way>(), std::declval<L>(), std::declval<R>()))>
156 constexpr static strong_ordering impl(L
const& l, R
const& r, rank<2>) {
157 return tag_invoke(compare_three_way{}, l, r);
160 template <
typename L,
typename R>
161 constexpr auto operator()(L
const& l, R
const& r)
const
162 BSONCXX_RETURNS((impl)(l, r, rank<2>{}));
167struct ordering_operators {
168 template <
typename L,
typename R>
169 constexpr static auto impl(
const L& l,
const R& r, rank<1>)
170 BSONCXX_RETURNS(tag_invoke(compare_three_way{}, l, r));
172 template <
typename L,
typename R>
173 constexpr static auto impl(
const L& l,
const R& r, rank<0>)
174 BSONCXX_RETURNS(tag_invoke(compare_three_way{}, r, l).inverted());
176#pragma push_macro("DEFOP")
179 template <typename L, typename R> \
180 constexpr friend auto operator Oper(const L& l, const R& r) \
181 BSONCXX_RETURNS(ordering_operators::impl(l, r, rank<1>{}) Oper nullptr)
186#pragma pop_macro("DEFOP")
189template <
typename L,
typename R>
190std::false_type is_partially_ordered_with_f(rank<0>);
192template <
typename L,
typename R>
193auto is_partially_ordered_with_f(rank<1>)
194 -> true_t<decltype(std::declval<const L&>() > std::declval<const R&>()),
195 decltype(std::declval<const L&>() < std::declval<const R&>()),
196 decltype(std::declval<const L&>() >= std::declval<const R&>()),
197 decltype(std::declval<const L&>() <= std::declval<const R&>()),
198 decltype(std::declval<const R&>() < std::declval<const L&>()),
199 decltype(std::declval<const R&>() > std::declval<const L&>()),
200 decltype(std::declval<const R&>() <= std::declval<const L&>()),
201 decltype(std::declval<const R&>() >= std::declval<const L&>())>;
203template <
typename T,
typename U>
204struct is_partially_ordered_with : decltype(is_partially_ordered_with_f<T, U>(rank<1>{})) {};
207struct is_totally_ordered
208 : conjunction<is_equality_comparable<T>, is_partially_ordered_with<T, T>> {};
210template <
typename T,
typename U>
211struct is_totally_ordered_with : conjunction<is_totally_ordered<T>,
212 is_totally_ordered<U>,
213 is_equality_comparable<T, U>,
214 is_partially_ordered_with<T, U>> {};
The bsoncxx macro guard postlude header.
The bsoncxx macro guard prelude header.
bool operator==(const element &elem, const types::bson_value::view &v)
Convenience methods to compare for equality against a bson_value.
bool operator!=(const element &elem, const types::bson_value::view &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==(const v_noabi::view_or_value< View, Value > &lhs, const v_noabi::view_or_value< View, Value > &rhs)
bsoncxx::v_noabi::operator==(const v_noabi::view_or_value<View, Value>& lhs, const v_noabi::view_or_v...
bool operator!=(const v_noabi::view_or_value< View, Value > &lhs, const v_noabi::view_or_value< View, Value > &rhs)
bsoncxx::v_noabi::operator!=(const v_noabi::view_or_value<View, Value>& lhs, const v_noabi::view_or_v...
The top-level namespace reserved for the C++ standard library.
Provides <type_traits>-related polyfills for internal use.