-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[libc++][c++23] P2374: views::cartesian_product
#111215
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
Draft
PaulXiCao
wants to merge
51
commits into
llvm:main
Choose a base branch
from
PaulXiCao:cartesian_product_view
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
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
You can test this locally with the following command:git-clang-format --diff 1a9521565019edc8589f234c95477ab0a6b164d5 150eed31fbe65730b989bf02cb1e62fbb99f340d --extensions cpp,,h -- libcxx/include/__ranges/cartesian_product_view.h libcxx/test/std/ranges/range.adaptors/range.cartesian.product.view/begin.pass.cpp libcxx/test/std/ranges/range.adaptors/range.cartesian.product.view/ctad.compile.pass.cpp libcxx/test/std/ranges/range.adaptors/range.cartesian.product.view/ctor.default.pass.cpp libcxx/test/std/ranges/range.adaptors/range.cartesian.product.view/ctor.pass.cpp libcxx/test/std/ranges/range.adaptors/range.cartesian.product.view/ctor.views.pass.cpp libcxx/test/std/ranges/range.adaptors/range.cartesian.product.view/end.pass.cpp libcxx/test/std/ranges/range.adaptors/range.cartesian.product.view/example_from_std.pass.cpp libcxx/test/std/ranges/range.adaptors/range.cartesian.product.view/size.pass.cpp libcxx/include/ranges libcxx/test/std/ranges/range.adaptors/range.zip/types.hView the diff from clang-format here.diff --git a/libcxx/include/__ranges/cartesian_product_view.h b/libcxx/include/__ranges/cartesian_product_view.h
index 4d95de846b..b413ebbb05 100644
--- a/libcxx/include/__ranges/cartesian_product_view.h
+++ b/libcxx/include/__ranges/cartesian_product_view.h
@@ -138,7 +138,7 @@ private:
return ranges::begin(rng);
};
- return std::make_tuple(begin_or_first_end(std::bool_constant<I == 0>{}, std::get<I>(b))...);
+ return std::make_tuple(begin_or_first_end(std::bool_constant < I == 0 > {}, std::get<I>(b))...);
};
iterator<is_const> it(*this, ranges_to_iterators(std::make_index_sequence<1 + sizeof...(Vs)>{}));
return it;
diff --git a/libcxx/test/std/ranges/range.adaptors/range.cartesian.product.view/begin.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.cartesian.product.view/begin.pass.cpp
index fac0d39b9f..586d757e0c 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.cartesian.product.view/begin.pass.cpp
+++ b/libcxx/test/std/ranges/range.adaptors/range.cartesian.product.view/begin.pass.cpp
@@ -47,9 +47,8 @@ constexpr bool test() {
{ // all underlying iterators should be at the begin position
std::ranges::cartesian_product_view v(
SizedRandomAccessView{buffer}, std::views::iota(0), std::ranges::single_view(2.0));
- std::same_as<std::tuple<int&, int, double&>> decltype(auto) mutVal = *v.begin();
- std::same_as<std::tuple<int&, int, const double&>> decltype(auto) constVal =
- *std::as_const(v).begin();
+ std::same_as<std::tuple<int&, int, double&>> decltype(auto) mutVal = *v.begin();
+ std::same_as<std::tuple<int&, int, const double&>> decltype(auto) constVal = *std::as_const(v).begin();
assert(mutVal == std::make_tuple(1, 0, 2.0));
assert(constVal == std::make_tuple(1, 0, 2.0));
assert(&(std::get<0>(mutVal)) == &buffer[0]);
diff --git a/libcxx/test/std/ranges/range.adaptors/range.cartesian.product.view/ctor.views.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.cartesian.product.view/ctor.views.pass.cpp
index 0c424acaf3..99391a8d5d 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.cartesian.product.view/ctor.views.pass.cpp
+++ b/libcxx/test/std/ranges/range.adaptors/range.cartesian.product.view/ctor.views.pass.cpp
@@ -25,16 +25,19 @@ concept implicitly_constructible_from = requires(Args&&... args) { conversion_te
static_assert(std::constructible_from<std::ranges::cartesian_product_view<SimpleCommon>, SimpleCommon>);
static_assert(!implicitly_constructible_from<std::ranges::cartesian_product_view<SimpleCommon>, SimpleCommon>);
-static_assert(std::constructible_from<std::ranges::cartesian_product_view<SimpleCommon, SimpleCommon>, SimpleCommon, SimpleCommon>);
-static_assert(
- !implicitly_constructible_from<std::ranges::cartesian_product_view<SimpleCommon, SimpleCommon>, SimpleCommon, SimpleCommon>);
+static_assert(std::constructible_from<std::ranges::cartesian_product_view<SimpleCommon, SimpleCommon>,
+ SimpleCommon,
+ SimpleCommon>);
+static_assert(!implicitly_constructible_from<std::ranges::cartesian_product_view<SimpleCommon, SimpleCommon>,
+ SimpleCommon,
+ SimpleCommon>);
struct MoveAwareView : std::ranges::view_base {
- int moves = 0;
+ int moves = 0;
constexpr MoveAwareView() = default;
constexpr MoveAwareView(MoveAwareView&& other) : moves(other.moves + 1) { other.moves = 1; }
constexpr MoveAwareView& operator=(MoveAwareView&& other) {
- moves = other.moves + 1;
+ moves = other.moves + 1;
other.moves = 0;
return *this;
}
@@ -51,12 +54,12 @@ constexpr void constructorTest(auto&& buffer1, auto&& buffer2) {
}
constexpr bool test() {
-
- int buffer[] = {1, 2, 3, 4, 5, 6, 7, 8};
+ int buffer[] = {1, 2, 3, 4, 5, 6, 7, 8};
int buffer2[] = {9, 8, 7, 6};
{ // constructor from views
- std::ranges::cartesian_product_view v(SizedRandomAccessView{buffer}, std::views::iota(0), std::ranges::single_view(2.));
+ std::ranges::cartesian_product_view v(
+ SizedRandomAccessView{buffer}, std::views::iota(0), std::ranges::single_view(2.));
assert(*v.begin() == std::make_tuple(1, 0, 2.0));
}
diff --git a/libcxx/test/std/ranges/range.adaptors/range.cartesian.product.view/end.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.cartesian.product.view/end.pass.cpp
index 1d057d05bc..8ec3bc925c 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.cartesian.product.view/end.pass.cpp
+++ b/libcxx/test/std/ranges/range.adaptors/range.cartesian.product.view/end.pass.cpp
@@ -34,13 +34,13 @@ constexpr bool test() {
assert(c.end() == c.begin() + N0 * N1);
}
- { // (non-empty range)^3
+ { // (non-empty range)^3
constexpr size_t N0 = 5, N1 = 42, N2 = 7;
std::array<int, N0> a0;
std::array<int, N1> a1;
std::array<int, N2> a2;
std::ranges::cartesian_product_view c{a0, a1, a2};
- assert(c.end() == c.begin() + N0*N1*N2);
+ assert(c.end() == c.begin() + N0 * N1 * N2);
}
{ // empty range
@@ -85,7 +85,7 @@ constexpr bool test() {
assert(c.end() == c.begin());
}
- { // empty range X common range X empty range
+ { // empty range X common range X empty range
std::ranges::empty_view<int> e;
constexpr size_t N = 7;
std::array<int, N> a;
@@ -93,7 +93,7 @@ constexpr bool test() {
assert(c.end() == c.begin());
}
- { // common range X empty range X empty range
+ { // common range X empty range X empty range
std::ranges::empty_view<int> e;
constexpr size_t N = 7;
std::array<int, N> a;
@@ -101,7 +101,7 @@ constexpr bool test() {
assert(c.end() == c.begin());
}
- { // empty range X common range X common range
+ { // empty range X common range X common range
std::ranges::empty_view<int> e;
constexpr size_t N0 = 7, N1 = 42;
std::array<int, N0> a0;
@@ -110,7 +110,7 @@ constexpr bool test() {
assert(c.end() == c.begin());
}
- { // common range X empty range X common range
+ { // common range X empty range X common range
std::ranges::empty_view<int> e;
constexpr size_t N0 = 7, N1 = 42;
std::array<int, N0> a0;
@@ -119,7 +119,7 @@ constexpr bool test() {
assert(c.end() == c.begin());
}
- { // common range X common range X empty range
+ { // common range X common range X empty range
std::ranges::empty_view<int> e;
constexpr size_t N0 = 7, N1 = 42;
std::array<int, N0> a0;
diff --git a/libcxx/test/std/ranges/range.adaptors/range.cartesian.product.view/example_from_std.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.cartesian.product.view/example_from_std.pass.cpp
index 4d505921b3..90384fa590 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.cartesian.product.view/example_from_std.pass.cpp
+++ b/libcxx/test/std/ranges/range.adaptors/range.cartesian.product.view/example_from_std.pass.cpp
@@ -17,9 +17,7 @@ constexpr bool test() {
struct ConstexprStringStream {
std::string str;
- constexpr ConstexprStringStream& operator<<(int x) {
- return *this << char(x + 48);
- }
+ constexpr ConstexprStringStream& operator<<(int x) { return *this << char(x + 48); }
constexpr ConstexprStringStream& operator<<(char c) {
str += c;
return *this;
@@ -61,7 +59,7 @@ constexpr bool test() {
"2 2 1\n"
"2 2 2\n";
assert(out.str == expected);
-
+
return true;
}
|
b16e603 to
948ae96
Compare
fd984a8 to
3bbaf36
Compare
3bbaf36 to
58dfeb8
Compare
58dfeb8 to
150eed3
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #105209 .
WIP !!