Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions libcxx/docs/ReleaseNotes/22.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,8 @@ ABI Affecting Changes
potentially inheriting from the types they wrap. At this point in time we are not aware of any ABI changes caused by
this.

- ``ranges::iota_view`` is now aware of ``__int128``. This causes ``iota_view::difference_type`` to change from
``long long`` to ``__int128`` in some cases.

Build System Changes
--------------------
14 changes: 10 additions & 4 deletions libcxx/include/__ranges/iota_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 the largest integer like type.");
}

using type = typename decltype(__call())::type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>);
#ifdef TEST_HAS_NO_INT128
LIBCPP_STATIC_ASSERT(std::same_as<Iter::difference_type, long long>);
#else
LIBCPP_STATIC_ASSERT(std::same_as<Iter::difference_type,
std::conditional_t<sizeof(long) == sizeof(long long), __int128, long long>>);
#endif
}
{
const std::ranges::iota_view<long long> io(0);
Expand All @@ -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>);
#ifdef TEST_HAS_NO_INT128
LIBCPP_STATIC_ASSERT(std::same_as<Iter::difference_type, long long>);
#else
LIBCPP_STATIC_ASSERT(std::same_as<Iter::difference_type, __int128>);
#endif
}
{
const std::ranges::iota_view<Decrementable> io;
Expand Down
Loading