Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix friend's friend #64

Merged
merged 1 commit into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions include/preview/__ranges/views/concat_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ struct concat_view : view_interface<concat_view<Rngs...>> {
preview::detail::variant_raw_get(to.its_._base().storage(), in_place_index<N>));
}

constexpr bool equal_with(const sentinel<IsConst>& pos) const {
return its_.index() == cranges - 1 && std::get<cranges - 1>(its_) == pos.end_;
}

public:
iterator() = default;

Expand Down Expand Up @@ -281,7 +285,7 @@ struct concat_view : view_interface<concat_view<Rngs...>> {
}

friend constexpr bool operator==(const iterator& x, const sentinel<IsConst>& y) {
return x.equal(y);
return x.equal_with(y);
}

friend constexpr bool operator!=(const iterator& x, const sentinel<IsConst>& y) {
Expand All @@ -296,10 +300,6 @@ struct concat_view : view_interface<concat_view<Rngs...>> {
return !(x == y);
}

constexpr bool equal(const sentinel<IsConst>& pos) const {
return its_.index() == cranges - 1 && std::get<cranges - 1>(its_) == pos.end_;
}

constexpr iterator& operator++() {
preview::detail::variant_raw_visit(its_.index(), its_._base().storage(), next_raw_visitor{this});
return *this;
Expand Down
6 changes: 5 additions & 1 deletion include/preview/__ranges/views/join_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ class join_view : public detail::join_view_inner_base<join_view<V>, V> {
sentinel_for<sentinel_t<Base>, iterator_t<maybe_const<OtherConst, V>>>
::value, int> = 0>
friend constexpr bool operator==(const iterator<OtherConst>& x, const sentinel& y) {
return x.outer() == y.end_;
return y.equal_with(x);
}

template<bool OtherConst, std::enable_if_t<
Expand All @@ -454,6 +454,10 @@ class join_view : public detail::join_view_inner_base<join_view<V>, V> {
}

private:
constexpr bool equal_with(const iterator<Const>& x) const {
return x.outer() == end_;
}

sentinel_t<Base> end_{};
};

Expand Down
6 changes: 3 additions & 3 deletions include/preview/__ranges/views/join_with_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -484,15 +484,15 @@ class join_with_view : public detail::join_with_view_base<V, Pattern, join_with_
: end_(std::move(i.end_)) {}

friend constexpr bool operator==(const iterator<Const>& x, const sentinel& y) {
return y.equal(x);
return y.equal_with(x);
}

friend constexpr bool operator!=(const iterator<Const>& x, const sentinel& y) {
return !(x == y);
}

friend constexpr bool operator==(const sentinel& y, const iterator<Const>& x) {
return y.equal(x);
return y.equal_with(x);
}

friend constexpr bool operator!=(const sentinel& y, const iterator<Const>& x) {
Expand All @@ -503,7 +503,7 @@ class join_with_view : public detail::join_with_view_base<V, Pattern, join_with_
constexpr explicit sentinel(Parent& parent)
: end_(ranges::end(parent.base_)) {}

constexpr bool equal(const iterator<Const>& x) const {
constexpr bool equal_with(const iterator<Const>& x) const {
using namespace preview::rel_ops;
return x.get_outer() == end_;
}
Expand Down
4 changes: 2 additions & 2 deletions include/preview/__ranges/views/split_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class split_view : public view_interface<split_view<V, Pattern>> {
: end_(ranges::end(parent.base_)) {}

friend constexpr bool operator==(const iterator& x, const sentinel& y) {
return y.compare_with_iterator(x);
return y.equal_with(x);
}

friend constexpr bool operator!=(const iterator& x, const sentinel& y) {
Expand All @@ -169,7 +169,7 @@ class split_view : public view_interface<split_view<V, Pattern>> {
}

private:
constexpr bool compare_with_iterator(const iterator& x) const {
constexpr bool equal_with(const iterator& x) const {
using namespace preview::rel_ops;
return x.cur_ == end_ && !x.trailing_empty_;
}
Expand Down
8 changes: 6 additions & 2 deletions include/preview/__ranges/views/transform_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,7 @@ class transform_view : public view_interface<transform_view<V, F>> {
}

friend constexpr bool operator==(const transform_view::iterator<Const>& x, const sentinel& y) {
using namespace preview::rel_ops;
return x.current_ == y.end_;
return y.equal_with(x);
}

friend constexpr bool operator==(const sentinel& y, const transform_view::iterator<Const>& x) {
Expand Down Expand Up @@ -305,6 +304,11 @@ class transform_view : public view_interface<transform_view<V, F>> {
}

private:
constexpr bool equal_with(const iterator<Const>& x) const {
using namespace preview::rel_ops;
return x.current_ == end_;
}

sentinel_t<Base> end_;
};

Expand Down
4 changes: 2 additions & 2 deletions include/preview/__ranges/views/zip_transform_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ class zip_transform_view : public view_interface<zip_transform_view<Views...>> {

template<bool OtherConst, std::enable_if_t<sentinel_for<zentinel<Const>, ziperator<OtherConst>>::value, int> = 0>
friend constexpr bool operator==(const iterator<OtherConst>& x, const sentinel& y) {
return y.equal_to(x);
return y.equal_with(x);
}

template<bool OtherConst, std::enable_if_t<sentinel_for<zentinel<Const>, ziperator<OtherConst>>::value, int> = 0>
Expand Down Expand Up @@ -345,7 +345,7 @@ class zip_transform_view : public view_interface<zip_transform_view<Views...>> {
: inner_(std::move(inner)) {}

template<bool OtherConst>
constexpr bool equal_to(const iterator<OtherConst>& x) const {
constexpr bool equal_with(const iterator<OtherConst>& x) const {
return x.inner_ == inner_;
}

Expand Down
4 changes: 2 additions & 2 deletions include/preview/__ranges/views/zip_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ class zip_view : public view_interface<zip_view<Views...>> {
>...
>::value, int> = 0>
friend constexpr bool operator==(const iterator<OtherConst>& x, const sentinel& y) {
return y.is_equal(x);
return y.equal_with(x);
}

template<bool OtherConst, std::enable_if_t<conjunction<
Expand Down Expand Up @@ -452,7 +452,7 @@ class zip_view : public view_interface<zip_view<Views...>> {
: end_(std::forward<Tuple>(tup)) {}

template<bool OtherConst>
constexpr bool is_equal(const iterator<OtherConst>& i) const {
constexpr bool equal_with(const iterator<OtherConst>& i) const {
return i.equal_2(end_, in_place_index_t<0>{});
}

Expand Down
Loading