Skip to content

Commit 3eb557b

Browse files
committed
feat(compare): comform_to func and odering_like concept
Closes #20
1 parent d16c550 commit 3eb557b

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

include/stdsharp/compare/compare.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,22 @@
66

77
namespace stdsharp
88
{
9+
template<typename Cat>
10+
concept ordering_like =
11+
same_as_any<Cat, std::partial_ordering, std::weak_ordering, std::strong_ordering>;
12+
913
constexpr bool is_ud(const std::partial_ordering c) noexcept
1014
{
1115
return c == std::partial_ordering::unordered;
1216
}
1317

18+
constexpr bool comform_to(const std::partial_ordering l, decltype(l) r) noexcept
19+
{
20+
return is_eq(l) || l == r;
21+
}
22+
1423
template<typename Fn, typename T, typename U, typename Cat = std::partial_ordering>
15-
concept ordering_predicate =
16-
std::convertible_to<Cat, std::partial_ordering> && invocable_r<Fn, Cat, T, U>;
24+
concept ordering_predicate = ordering_like<Cat> && invocable_r<Fn, Cat, T, U>;
1725

1826
template<typename Fn, typename T, typename U, typename Cat = std::partial_ordering>
1927
concept nothrow_ordering_predicate =

0 commit comments

Comments
 (0)