-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[libc++][ranges] P2609R3: Relaxing Ranges Just A Smidge #101715
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
Merged
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
cc39cf1
Implement the major part of P2609R3
frederick-vs-ja 6098b44
Test coverage for P2609R3
frederick-vs-ja 377730b
Adjust feature-test macro `__cpp_lib_ranges`
frederick-vs-ja e460d7d
Add release notes
frederick-vs-ja 93f7675
Merge branch 'main' into p2609r3
frederick-vs-ja 16888bc
Merge branch 'main' into p2609r3
frederick-vs-ja 30ceb59
Merge branch 'main' into p2609r3
frederick-vs-ja 2d8791a
Add Github link to 20.rst
frederick-vs-ja 9110cdf
Merge branch 'main' into p2609r3
frederick-vs-ja 67fcd2d
Merge branch 'main' into p2609r3
frederick-vs-ja ff841c8
Run the test (also in constant evaluation since C++23)
frederick-vs-ja e1223d2
Update libcxx/test/std/iterators/iterator.requirements/indirectcallab…
ldionne 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
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
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
75 changes: 75 additions & 0 deletions
75
...iterators/iterator.requirements/indirectcallable.traits/indirect.value.t.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,75 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
// UNSUPPORTED: c++03, c++11, c++14, c++17 | ||
|
||
// template<indirectly_readable T> | ||
// using indirect-value-t = see below; // exposition only | ||
|
||
#include <algorithm> | ||
#include <memory> | ||
#include <ranges> | ||
#include <utility> | ||
#include <vector> | ||
|
||
void test() { | ||
auto ints = std::views::iota(0, 5); | ||
auto unique_ptr_maker = []<std::movable T>(T v) { return std::make_unique<T>(std::move(v)); }; | ||
|
||
using iota_iter = std::ranges::iterator_t<decltype(ints)>; | ||
using unique_ptr_projection = decltype(unique_ptr_maker); | ||
using projected_iter = std::projected<iota_iter, unique_ptr_projection>; | ||
|
||
{ // Check std::indirectly_unary_invocable | ||
auto consume = [](auto) {}; | ||
static_assert(std::indirectly_unary_invocable<decltype(consume), projected_iter>); | ||
|
||
std::ranges::for_each(ints, consume, unique_ptr_maker); | ||
std::ranges::for_each(ints.begin(), ints.end(), consume, unique_ptr_maker); | ||
} | ||
|
||
{ // Check std::indirectly_regular_unary_invocable | ||
static_assert(std::indirectly_regular_unary_invocable<decltype([](auto) {}), projected_iter>); | ||
using check_wellformedness [[maybe_unused]] = std::projected<projected_iter, unique_ptr_projection>; | ||
} | ||
|
||
{ // Check std::indirect_unary_predicate | ||
auto unary_pred = [](auto) { return false; }; | ||
static_assert(std::indirect_unary_predicate<decltype(unary_pred), projected_iter>); | ||
|
||
(void)std::ranges::find_if(ints, unary_pred, unique_ptr_maker); | ||
(void)std::ranges::find_if(ints.begin(), ints.end(), unary_pred, unique_ptr_maker); | ||
(void)std::ranges::count_if(ints, unary_pred, unique_ptr_maker); | ||
(void)std::ranges::count_if(ints.begin(), ints.end(), unary_pred, unique_ptr_maker); | ||
} | ||
|
||
{ // Check std::indirect_binary_predicate | ||
auto binary_pred = [](auto, auto) { return false; }; | ||
static_assert(std::indirect_binary_predicate<decltype(binary_pred), projected_iter, projected_iter>); | ||
|
||
(void)std::ranges::adjacent_find(ints, binary_pred, unique_ptr_maker); | ||
(void)std::ranges::adjacent_find(ints.begin(), ints.end(), binary_pred, unique_ptr_maker); | ||
} | ||
|
||
{ // Check std::indirect_equivalence_relation | ||
auto rel = [](auto, auto) { return false; }; | ||
static_assert(std::indirect_equivalence_relation<decltype(rel), projected_iter>); | ||
|
||
std::vector<int> out; | ||
(void)std::ranges::unique_copy(ints, std::back_inserter(out), rel, unique_ptr_maker); | ||
(void)std::ranges::unique_copy(ints.begin(), ints.end(), std::back_inserter(out), rel, unique_ptr_maker); | ||
} | ||
|
||
{ // Check std::indirect_strict_weak_order | ||
auto rel = [](auto x, auto y) { return x < y; }; | ||
static_assert(std::indirect_strict_weak_order<decltype(rel), projected_iter>); | ||
|
||
(void)std::ranges::is_sorted_until(ints, rel, unique_ptr_maker); | ||
(void)std::ranges::is_sorted_until(ints.begin(), ints.end(), rel, unique_ptr_maker); | ||
} | ||
} |
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
Oops, something went wrong.
Oops, something went wrong.
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.