Skip to content

Commit ef748c7

Browse files
committed
Split operator<=> into two layers
1 parent 6f46e42 commit ef748c7

3 files changed

Lines changed: 33 additions & 5 deletions

File tree

include/iris/compare.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct synth_three_way_result_impl
2222
using type = std::weak_ordering;
2323
};
2424

25-
template<class T, class U> requires std::three_way_comparable<T, U>
25+
template<class T, class U> requires std::three_way_comparable_with<T, U>
2626
struct synth_three_way_result_impl<T, U>
2727
{
2828
using type = std::invoke_result_t<std::compare_three_way, T const&, U const&>;

include/iris/indirect.hpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,13 @@ constexpr bool operator==(indirect<T, Allocator> const& lhs, U const& rhs)
422422
}
423423
}
424424

425-
template<class T, class Allocator, class U> requires (!is_ttp_specialization_of_v<U, indirect>)
426-
constexpr auto operator<=>(indirect<T, Allocator> const& lhs, U const& rhs)
427-
noexcept(synth_three_way_noexcept<T, U>) -> synth_three_way_result_t<T, U>
425+
426+
namespace detail {
427+
428+
template<class T, class A, class U>
429+
constexpr auto three_way_compare_impl(indirect<T, A> const& lhs, U const& rhs)
430+
noexcept(synth_three_way_noexcept<T, U>)
431+
-> synth_three_way_result_t<T, U>
428432
{
429433
if (lhs.valueless_after_move()) [[unlikely]] {
430434
return std::strong_ordering::less;
@@ -433,6 +437,16 @@ constexpr auto operator<=>(indirect<T, Allocator> const& lhs, U const& rhs)
433437
}
434438
}
435439

440+
} // detail
441+
442+
template<class T, class A, class U>
443+
constexpr auto operator<=>(indirect<T, A> const& lhs, U const& rhs)
444+
noexcept(synth_three_way_noexcept<T, U>)
445+
// no explicit return type
446+
{
447+
return detail::three_way_compare_impl(lhs, rhs);
448+
}
449+
436450
} // iris
437451

438452

include/iris/rvariant/recursive_wrapper.hpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,12 @@ constexpr bool operator==(recursive_wrapper<T, A> const& lhs, U const& rhs)
199199
}
200200
}
201201

202+
namespace detail {
203+
202204
template<class T, class A, class U>
203-
constexpr auto operator<=>(recursive_wrapper<T, A> const& lhs, U const& rhs) noexcept(synth_three_way_noexcept<T, U>) -> synth_three_way_result_t<T, U>
205+
constexpr auto three_way_compare_impl(recursive_wrapper<T, A> const& lhs, U const& rhs)
206+
noexcept(synth_three_way_noexcept<T, U>)
207+
-> synth_three_way_result_t<T, U>
204208
{
205209
if (lhs.valueless_after_move()) [[unlikely]] {
206210
return std::strong_ordering::less;
@@ -209,6 +213,16 @@ constexpr auto operator<=>(recursive_wrapper<T, A> const& lhs, U const& rhs) noe
209213
}
210214
}
211215

216+
} // detail
217+
218+
template<class T, class A, class U>
219+
constexpr auto operator<=>(recursive_wrapper<T, A> const& lhs, U const& rhs)
220+
noexcept(synth_three_way_noexcept<T, U>)
221+
// no explicit return type
222+
{
223+
return detail::three_way_compare_impl(lhs, rhs);
224+
}
225+
212226
} // iris
213227

214228
namespace std {

0 commit comments

Comments
 (0)