-
Notifications
You must be signed in to change notification settings - Fork 1.7k
P2609R3: Relaxing Ranges Just A Smidge #3486
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
Merged
Stephan T. Lavavej (StephanTLavavej)
merged 7 commits into
microsoft:main
from
JMazurkiewicz:relaxed_ranges
Feb 23, 2023
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6ab8897
Feature test macro
JMazurkiewicz 3742489
Relax concepts
JMazurkiewicz 475f1b0
Tests
JMazurkiewicz b70c474
Remove `<iterator>` include and add missing `<utility>` for `std::move`
JMazurkiewicz 2688a31
Rename `int main` to `void test`
JMazurkiewicz 8554f2f
Implement P2609R3 in C++20 mode too
JMazurkiewicz febff34
This and P2606R2 are implemented in C++20 mode
CaseyCarter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
tests/std/tests/P2609R3_relaxing_ranges_just_a_smidge/env.lst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| RUNALL_INCLUDE ..\concepts_latest_matrix.lst |
67 changes: 67 additions & 0 deletions
67
tests/std/tests/P2609R3_relaxing_ranges_just_a_smidge/test.compile.pass.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
|
CaseyCarter marked this conversation as resolved.
|
||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| #include <algorithm> | ||
| #include <memory> | ||
| #include <ranges> | ||
| #include <utility> | ||
| #include <vector> | ||
|
|
||
| using namespace std; | ||
|
|
||
| void test() { | ||
| auto ints = views::iota(0, 5); | ||
| auto project_to_unique_ptr = []<movable T>(T v) { return make_unique<T>(move(v)); }; | ||
|
|
||
| using It = ranges::iterator_t<decltype(ints)>; | ||
| using Proj = decltype(project_to_unique_ptr); | ||
| using ProjectedIt = projected<It, Proj>; | ||
|
|
||
| { // Check indirectly_unary_invocable | ||
| auto consume = [](auto) {}; | ||
| static_assert(indirectly_unary_invocable<decltype(consume), ProjectedIt>); | ||
|
|
||
| ranges::for_each(ints, consume, project_to_unique_ptr); | ||
| ranges::for_each(ints.begin(), ints.end(), consume, project_to_unique_ptr); | ||
| } | ||
|
|
||
| { // Check indirectly_regular_unary_invocable | ||
| static_assert(indirectly_regular_unary_invocable<decltype([](auto) {}), ProjectedIt>); | ||
| using Check [[maybe_unused]] = projected<ProjectedIt, Proj>; | ||
| } | ||
|
|
||
| { // Check indirect_unary_predicate | ||
| auto unary_pred = [](auto) { return false; }; | ||
| static_assert(indirect_unary_predicate<decltype(unary_pred), ProjectedIt>); | ||
|
|
||
| (void) ranges::find_if(ints, unary_pred, project_to_unique_ptr); | ||
| (void) ranges::find_if(ints.begin(), ints.end(), unary_pred, project_to_unique_ptr); | ||
| (void) ranges::count_if(ints, unary_pred, project_to_unique_ptr); | ||
| (void) ranges::count_if(ints.begin(), ints.end(), unary_pred, project_to_unique_ptr); | ||
| } | ||
|
|
||
| { // Check indirect_binary_predicate | ||
| auto binary_pred = [](auto, auto) { return false; }; | ||
| static_assert(indirect_binary_predicate<decltype(binary_pred), ProjectedIt, ProjectedIt>); | ||
|
|
||
| (void) ranges::adjacent_find(ints, binary_pred, project_to_unique_ptr); | ||
| (void) ranges::adjacent_find(ints.begin(), ints.end(), binary_pred, project_to_unique_ptr); | ||
| } | ||
|
|
||
| { // Check indirect_equivalence_relation | ||
| auto rel = [](auto, auto) { return false; }; | ||
| static_assert(indirect_equivalence_relation<decltype(rel), ProjectedIt>); | ||
|
|
||
| vector<int> out; | ||
| (void) ranges::unique_copy(ints, back_inserter(out), rel, project_to_unique_ptr); | ||
| (void) ranges::unique_copy(ints.begin(), ints.end(), back_inserter(out), rel, project_to_unique_ptr); | ||
| } | ||
|
|
||
| { // Check indirect_strict_weak_order | ||
| auto rel = [](auto x, auto y) { return x < y; }; | ||
| static_assert(indirect_strict_weak_order<decltype(rel), ProjectedIt>); | ||
|
|
||
| (void) ranges::is_sorted_until(ints, rel, project_to_unique_ptr); | ||
| (void) ranges::is_sorted_until(ints.begin(), ints.end(), rel, project_to_unique_ptr); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.