Skip to content

Commit 722664f

Browse files
Support iterators that aren't three-way comparable
1 parent ea32afb commit 722664f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

include/beman/any_view/detail/iterator_adaptor.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,15 @@ class iterator_adaptor : public iterator_interface<ElementT, RefT, RValueRefT, D
102102
[[nodiscard]] constexpr auto operator<=>(const iterator_interface& other) const -> std::partial_ordering override {
103103
if constexpr (random_access) {
104104
if (const auto adaptor = down_cast(other)) {
105-
return iterator <=> adaptor->iterator;
105+
// std::__wrap_iter is not three-way comparable in Apple Clang
106+
if constexpr (std::three_way_comparable<IteratorT>) {
107+
return iterator <=> adaptor->iterator;
108+
} else {
109+
return iterator < adaptor->iterator ? std::partial_ordering::less
110+
: iterator > adaptor->iterator ? std::partial_ordering::greater
111+
: iterator == adaptor->iterator ? std::partial_ordering::equivalent
112+
: std::partial_ordering::unordered;
113+
}
106114
}
107115
}
108116

0 commit comments

Comments
 (0)