-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[libc++] Make views::iota aware of __int128 #167869
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
+22
−5
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
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
2cd4b4a to
b92742a
Compare
b92742a to
6320d55
Compare
Member
|
@llvm/pr-subscribers-libcxx Author: Nikolas Klauser (philnik777) ChangesFixes #167991 Full diff: https://github.com/llvm/llvm-project/pull/167869.diff 3 Files Affected:
diff --git a/libcxx/include/__ranges/iota_view.h b/libcxx/include/__ranges/iota_view.h
index 22adc22e69190..d91c365233215 100644
--- a/libcxx/include/__ranges/iota_view.h
+++ b/libcxx/include/__ranges/iota_view.h
@@ -58,11 +58,17 @@ struct __get_wider_signed {
return type_identity<int>{};
else if constexpr (sizeof(_Int) < sizeof(long))
return type_identity<long>{};
- else
+ else if constexpr (sizeof(_Int) < sizeof(long long))
return type_identity<long long>{};
-
- static_assert(
- sizeof(_Int) <= sizeof(long long), "Found integer-like type that is bigger than largest integer like type.");
+# if _LIBCPP_HAS_INT128
+ else if constexpr (sizeof(_Int) <= sizeof(__int128))
+ return type_identity<__int128>{};
+# else
+ else if constexpr (sizeof(_Int) <= sizeof(long long))
+ return type_identity<long long>{};
+# endif
+ else
+ static_assert(false, "Found integer-like type that is bigger than largest integer like type.");
}
using type = typename decltype(__call())::type;
diff --git a/libcxx/test/std/ranges/range.factories/range.iota.view/indices.pass.cpp b/libcxx/test/std/ranges/range.factories/range.iota.view/indices.pass.cpp
index b70471b25d32b..872308594ba06 100644
--- a/libcxx/test/std/ranges/range.factories/range.iota.view/indices.pass.cpp
+++ b/libcxx/test/std/ranges/range.factories/range.iota.view/indices.pass.cpp
@@ -21,7 +21,6 @@
#include <vector>
#include "test_macros.h"
-#define TEST_HAS_NO_INT128 // Size cannot be larger than 64 bits
#include "type_algorithms.h"
#include "types.h"
diff --git a/libcxx/test/std/ranges/range.factories/range.iota.view/iterator/member_typedefs.compile.pass.cpp b/libcxx/test/std/ranges/range.factories/range.iota.view/iterator/member_typedefs.compile.pass.cpp
index c2f7fd14042a8..d1b97cf889a42 100644
--- a/libcxx/test/std/ranges/range.factories/range.iota.view/iterator/member_typedefs.compile.pass.cpp
+++ b/libcxx/test/std/ranges/range.factories/range.iota.view/iterator/member_typedefs.compile.pass.cpp
@@ -106,7 +106,12 @@ void test() {
// Same as below, if there is no type larger than long, we can just use that.
static_assert(sizeof(Iter::difference_type) >= sizeof(long));
static_assert(std::is_signed_v<Iter::difference_type>);
+#if !defined(TEST_HAS_NO_INT128)
+ LIBCPP_STATIC_ASSERT(std::same_as<Iter::difference_type,
+ std::conditional_t<sizeof(long) == sizeof(long long), __int128, long long>>);
+#else
LIBCPP_STATIC_ASSERT(std::same_as<Iter::difference_type, long long>);
+#endif
}
{
const std::ranges::iota_view<long long> io(0);
@@ -118,7 +123,11 @@ void test() {
// https://eel.is/c++draft/range.iota.view#1.3
static_assert(sizeof(Iter::difference_type) >= sizeof(long long));
static_assert(std::is_signed_v<Iter::difference_type>);
+#ifndef TEST_HAS_NO_INT128
+ LIBCPP_STATIC_ASSERT(std::same_as<Iter::difference_type, __int128>);
+#else
LIBCPP_STATIC_ASSERT(std::same_as<Iter::difference_type, long long>);
+#endif
}
{
const std::ranges::iota_view<Decrementable> io;
|
ldionne
approved these changes
Nov 17, 2025
...xx/test/std/ranges/range.factories/range.iota.view/iterator/member_typedefs.compile.pass.cpp
Outdated
Show resolved
Hide resolved
...xx/test/std/ranges/range.factories/range.iota.view/iterator/member_typedefs.compile.pass.cpp
Outdated
Show resolved
Hide resolved
6320d55 to
d76296e
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.
Fixes #167991