Skip to content

Commit

Permalink
Support iterators that aren't three-way comparable
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickroberts committed Feb 8, 2025
1 parent ea32afb commit 722664f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion include/beman/any_view/detail/iterator_adaptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,15 @@ class iterator_adaptor : public iterator_interface<ElementT, RefT, RValueRefT, D
[[nodiscard]] constexpr auto operator<=>(const iterator_interface& other) const -> std::partial_ordering override {
if constexpr (random_access) {
if (const auto adaptor = down_cast(other)) {
return iterator <=> adaptor->iterator;
// std::__wrap_iter is not three-way comparable in Apple Clang
if constexpr (std::three_way_comparable<IteratorT>) {
return iterator <=> adaptor->iterator;
} else {
return iterator < adaptor->iterator ? std::partial_ordering::less
: iterator > adaptor->iterator ? std::partial_ordering::greater
: iterator == adaptor->iterator ? std::partial_ordering::equivalent
: std::partial_ordering::unordered;
}
}
}

Expand Down

0 comments on commit 722664f

Please sign in to comment.