Skip to content

Commit 629d262

Browse files
committed
Move comparison-related type traits into type_traits.hpp
1 parent 9f8b738 commit 629d262

File tree

2 files changed

+44
-44
lines changed

2 files changed

+44
-44
lines changed

src/bsoncxx/include/bsoncxx/v1/detail/compare.hpp

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,6 @@
2626
namespace bsoncxx {
2727
namespace detail {
2828

29-
template <typename L, typename R>
30-
auto is_equality_comparable_f(...) -> std::false_type;
31-
32-
BSONCXX_PRIVATE_WARNINGS_PUSH();
33-
BSONCXX_PRIVATE_WARNINGS_DISABLE(GNU("-Wfloat-equal"));
34-
template <typename L, typename R>
35-
auto is_equality_comparable_f(int, bool b = false)
36-
-> true_t<
37-
decltype((std::declval<L const&>() == std::declval<R const&>()) ? 0 : 0, (std::declval<R const&>() == std::declval<L const&>()) ? 0 : 0, (std::declval<L const&>() != std::declval<R const&>()) ? 0 : 0, (std::declval<R const&>() != std::declval<L const&>()) ? 0 : 0)>;
38-
BSONCXX_PRIVATE_WARNINGS_POP();
39-
40-
// Detect whether two types are equality-comparable.
41-
//
42-
// Requires L == R, L != R, R == L, and R != L.
43-
template <typename L, typename R = L>
44-
struct is_equality_comparable : decltype(is_equality_comparable_f<L, R>(0)) {};
45-
4629
// Callable object and tag type for equality comparison.
4730
struct equal_to {
4831
template <typename L, typename R>
@@ -180,33 +163,6 @@ struct ordering_operators {
180163
#pragma pop_macro("DEFOP")
181164
};
182165

183-
template <typename L, typename R>
184-
std::false_type is_partially_ordered_with_f(rank<0>);
185-
186-
template <typename L, typename R>
187-
auto is_partially_ordered_with_f(rank<1>) -> true_t<
188-
decltype(std::declval<L const&>() > std::declval<R const&>()),
189-
decltype(std::declval<L const&>() < std::declval<R const&>()),
190-
decltype(std::declval<L const&>() >= std::declval<R const&>()),
191-
decltype(std::declval<L const&>() <= std::declval<R const&>()),
192-
decltype(std::declval<R const&>() < std::declval<L const&>()),
193-
decltype(std::declval<R const&>() > std::declval<L const&>()),
194-
decltype(std::declval<R const&>() <= std::declval<L const&>()),
195-
decltype(std::declval<R const&>() >= std::declval<L const&>())>;
196-
197-
template <typename T, typename U>
198-
struct is_partially_ordered_with : decltype(is_partially_ordered_with_f<T, U>(rank<1>{})) {};
199-
200-
template <typename T>
201-
struct is_totally_ordered : conjunction<is_equality_comparable<T>, is_partially_ordered_with<T, T>> {};
202-
203-
template <typename T, typename U>
204-
struct is_totally_ordered_with : conjunction<
205-
is_totally_ordered<T>,
206-
is_totally_ordered<U>,
207-
is_equality_comparable<T, U>,
208-
is_partially_ordered_with<T, U>> {};
209-
210166
} // namespace detail
211167
} // namespace bsoncxx
212168

src/bsoncxx/include/bsoncxx/v1/detail/type_traits.hpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,50 @@ struct is_swappable : is_swappable_with<T&, T&> {};
462462
template <typename T>
463463
struct is_nothrow_swappable : is_nothrow_swappable_with<T&, T&> {};
464464

465+
template <typename L, typename R>
466+
auto is_equality_comparable_f(...) -> std::false_type;
467+
468+
BSONCXX_PRIVATE_WARNINGS_PUSH();
469+
BSONCXX_PRIVATE_WARNINGS_DISABLE(GNU("-Wfloat-equal"));
470+
template <typename L, typename R>
471+
auto is_equality_comparable_f(int, bool b = false)
472+
-> true_t<
473+
decltype((std::declval<L const&>() == std::declval<R const&>()) ? 0 : 0, (std::declval<R const&>() == std::declval<L const&>()) ? 0 : 0, (std::declval<L const&>() != std::declval<R const&>()) ? 0 : 0, (std::declval<R const&>() != std::declval<L const&>()) ? 0 : 0)>;
474+
BSONCXX_PRIVATE_WARNINGS_POP();
475+
476+
// Detect whether two types are equality-comparable.
477+
//
478+
// Requires L == R, L != R, R == L, and R != L.
479+
template <typename L, typename R = L>
480+
struct is_equality_comparable : decltype(is_equality_comparable_f<L, R>(0)) {};
481+
482+
template <typename L, typename R>
483+
std::false_type is_partially_ordered_with_f(rank<0>);
484+
485+
template <typename L, typename R>
486+
auto is_partially_ordered_with_f(rank<1>) -> true_t<
487+
decltype(std::declval<L const&>() > std::declval<R const&>()),
488+
decltype(std::declval<L const&>() < std::declval<R const&>()),
489+
decltype(std::declval<L const&>() >= std::declval<R const&>()),
490+
decltype(std::declval<L const&>() <= std::declval<R const&>()),
491+
decltype(std::declval<R const&>() < std::declval<L const&>()),
492+
decltype(std::declval<R const&>() > std::declval<L const&>()),
493+
decltype(std::declval<R const&>() <= std::declval<L const&>()),
494+
decltype(std::declval<R const&>() >= std::declval<L const&>())>;
495+
496+
template <typename T, typename U>
497+
struct is_partially_ordered_with : decltype(is_partially_ordered_with_f<T, U>(rank<1>{})) {};
498+
499+
template <typename T>
500+
struct is_totally_ordered : conjunction<is_equality_comparable<T>, is_partially_ordered_with<T, T>> {};
501+
502+
template <typename T, typename U>
503+
struct is_totally_ordered_with : conjunction<
504+
is_totally_ordered<T>,
505+
is_totally_ordered<U>,
506+
is_equality_comparable<T, U>,
507+
is_partially_ordered_with<T, U>> {};
508+
465509
} // namespace detail
466510
} // namespace bsoncxx
467511

0 commit comments

Comments
 (0)