Skip to content

adds ranges::contains_subrange#1675

Merged
brevzin merged 3 commits into
ericniebler:masterfrom
cjdb:contains
Jun 23, 2022
Merged

adds ranges::contains_subrange#1675
brevzin merged 3 commits into
ericniebler:masterfrom
cjdb:contains

Conversation

@cjdb

@cjdb cjdb commented Nov 8, 2021

Copy link
Copy Markdown
Contributor

P2302 proposes an find-based contains (called contains) and a
search-based contains (called contains_subrange). The former is used
to determine if an element exists in a range, while the latter is used
to determine whether or not a needle range is a subrange of a
haystack range.

P2302 proposes an `find`-based contains (called `contains`) and a
`search`-based contains (called `contains_subrange`). The former is used
to determine if an element exists in a range, while the latter is used
to determine whether or not a needle range is a subrange of a
haystack range.
@JeffGarland

Copy link
Copy Markdown
Contributor

Given that LWG has adopted this paper for C++23 it would be nice if this could be added.

Comment thread test/algorithm/contains_subrange.cpp Outdated
using namespace ranges;
auto full_range = std::array<int, 10>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
auto valid_subrange = std::array<int, 5>{2, 3, 4, 5, 6};
auto invalid_subrange = std::array<int, 5>{3, 4, 5, 6, 2};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With MSVC, std::array<int, N>::iterator isn't int*, so this test is failing. Can you change these to an int[N] instead? The clang 5 build is failing for reasons that are also basically related to this.

@brevzin brevzin merged commit 77bf1e3 into ericniebler:master Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants