diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.unique/ranges_unique_copy.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.unique/ranges_unique_copy.pass.cpp index b84600b92c2b2..a4cf97069c96a 100644 --- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.unique/ranges_unique_copy.pass.cpp +++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.unique/ranges_unique_copy.pass.cpp @@ -418,7 +418,7 @@ constexpr bool test() { assert(std::ranges::equal(out, expected)); assert(base(result.in) == in.end()); assert(base(result.out) == out.end()); - assert(numberOfComp == in.size() - 1); + assert(numberOfComp == static_cast(in.size() - 1)); assert(numberOfProj <= static_cast(2 * (in.size() - 1))); } // range overload @@ -434,7 +434,7 @@ constexpr bool test() { assert(std::ranges::equal(out, expected)); assert(base(result.in) == in.end()); assert(base(result.out) == out.end()); - assert(numberOfComp == in.size() - 1); + assert(numberOfComp == static_cast(in.size() - 1)); assert(numberOfProj <= static_cast(2 * (in.size() - 1))); } } diff --git a/libcxx/test/std/containers/sequences/insert_range_sequence_containers.h b/libcxx/test/std/containers/sequences/insert_range_sequence_containers.h index b77b2510eae23..352ee474cae76 100644 --- a/libcxx/test/std/containers/sequences/insert_range_sequence_containers.h +++ b/libcxx/test/std/containers/sequences/insert_range_sequence_containers.h @@ -427,7 +427,8 @@ template <> constexpr TestCase FullContainer_End_LongRange { template constexpr void test_sequence_insert_range(Validate validate) { using T = typename Container::value_type; - auto get_pos = [](auto& c, auto& test_case) { return std::ranges::next(c.begin(), test_case.index); }; + using D = typename Container::difference_type; + auto get_pos = [](auto& c, auto& test_case) { return std::ranges::next(c.begin(), static_cast(test_case.index)); }; auto test = [&](auto& test_case) { Container c(test_case.initial.begin(), test_case.initial.end()); diff --git a/libcxx/test/std/containers/unord/unord.map/eq.different_hash.pass.cpp b/libcxx/test/std/containers/unord/unord.map/eq.different_hash.pass.cpp index 52a806f04d72d..94de7589eb060 100644 --- a/libcxx/test/std/containers/unord/unord.map/eq.different_hash.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.map/eq.different_hash.pass.cpp @@ -36,7 +36,7 @@ std::size_t hash_neg(T val) { } template std::size_t hash_scale(T val) { - return val << 1; + return static_cast(val << 1); } template std::size_t hash_even(T val) { @@ -57,7 +57,7 @@ std::size_t hash_neg(T* val) { } template std::size_t hash_scale(T* val) { - return *val << 1; + return static_cast(*val << 1); } template std::size_t hash_even(T* val) { diff --git a/libcxx/test/std/containers/unord/unord.multimap/eq.different_hash.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/eq.different_hash.pass.cpp index 2644c96576446..0aafb401d42ca 100644 --- a/libcxx/test/std/containers/unord/unord.multimap/eq.different_hash.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.multimap/eq.different_hash.pass.cpp @@ -37,7 +37,7 @@ std::size_t hash_neg(T val) { } template std::size_t hash_scale(T val) { - return val << 1; + return static_cast(val << 1); } template std::size_t hash_even(T val) { @@ -58,7 +58,7 @@ std::size_t hash_neg(T* val) { } template std::size_t hash_scale(T* val) { - return *val << 1; + return static_cast(*val << 1); } template std::size_t hash_even(T* val) { diff --git a/libcxx/test/std/containers/unord/unord.multiset/eq.different_hash.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/eq.different_hash.pass.cpp index 9f53e8d79e866..5b8f11e929279 100644 --- a/libcxx/test/std/containers/unord/unord.multiset/eq.different_hash.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.multiset/eq.different_hash.pass.cpp @@ -36,7 +36,7 @@ std::size_t hash_neg(T val) { } template std::size_t hash_scale(T val) { - return val << 1; + return static_cast(val << 1); } template std::size_t hash_even(T val) { @@ -57,7 +57,7 @@ std::size_t hash_neg(T* val) { } template std::size_t hash_scale(T* val) { - return *val << 1; + return static_cast(*val << 1); } template std::size_t hash_even(T* val) { diff --git a/libcxx/test/std/containers/unord/unord.set/eq.different_hash.pass.cpp b/libcxx/test/std/containers/unord/unord.set/eq.different_hash.pass.cpp index a763c7fee623a..3cb4815a5bcb1 100644 --- a/libcxx/test/std/containers/unord/unord.set/eq.different_hash.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.set/eq.different_hash.pass.cpp @@ -36,7 +36,7 @@ std::size_t hash_neg(T val) { } template std::size_t hash_scale(T val) { - return val << 1; + return static_cast(val << 1); } template std::size_t hash_even(T val) { @@ -56,11 +56,11 @@ std::size_t hash_neg(T* val) { return std::numeric_limits::max() - *val; } template -size_t hash_scale(T* val) { - return *val << 1; +std::size_t hash_scale(T* val) { + return static_cast(*val << 1); } template -size_t hash_even(T* val) { +std::size_t hash_even(T* val) { return *val & 1 ? 1 : 0; } diff --git a/libcxx/test/std/containers/views/mdspan/layout_stride/index_operator.pass.cpp b/libcxx/test/std/containers/views/mdspan/layout_stride/index_operator.pass.cpp index 01278e9076714..30281a8d922d1 100644 --- a/libcxx/test/std/containers/views/mdspan/layout_stride/index_operator.pass.cpp +++ b/libcxx/test/std/containers/views/mdspan/layout_stride/index_operator.pass.cpp @@ -53,10 +53,10 @@ constexpr void iterate_stride(M m, const std::array(M::extents_type::rank()) - 1 - static_cast(sizeof...(Args)); if constexpr (-1 == r) { ASSERT_NOEXCEPT(m(args...)); - size_t expected_val = [&](std::index_sequence) { + std::size_t expected_val = static_cast([&](std::index_sequence) { return ((args * strides[Pos]) + ... + 0); - }(std::make_index_sequence()); - assert(expected_val == static_cast(m(args...))); + }(std::make_index_sequence())); + assert(expected_val == static_cast(m(args...))); } else { for (typename M::index_type i = 0; i < m.extents().extent(r); i++) { iterate_stride(m, strides, i, args...); @@ -73,7 +73,7 @@ constexpr void test_iteration(std::array strides, Args... args) } constexpr bool test() { - constexpr size_t D = std::dynamic_extent; + constexpr std::size_t D = std::dynamic_extent; test_iteration>(std::array{}); test_iteration>(std::array{2}, 1); test_iteration>(std::array{3}, 7); @@ -102,7 +102,7 @@ constexpr bool test() { } constexpr bool test_large() { - constexpr size_t D = std::dynamic_extent; + constexpr std::size_t D = std::dynamic_extent; test_iteration>(std::array{2000, 2, 20, 200}, 7, 9, 10); test_iteration>(std::array{2000, 20, 20, 200}, 7, 10); return true; diff --git a/libcxx/test/std/ranges/range.utility/range.utility.conv/container.h b/libcxx/test/std/ranges/range.utility/range.utility.conv/container.h index fafccacd456d5..ca89e3757affc 100644 --- a/libcxx/test/std/ranges/range.utility/range.utility.conv/container.h +++ b/libcxx/test/std/ranges/range.utility/range.utility.conv/container.h @@ -38,7 +38,7 @@ struct Container { constexpr explicit Container(std::ranges::input_range auto&& in) requires(Rank >= CtrChoice::DirectCtr) - : ctr_choice(CtrChoice::DirectCtr), size_(std::ranges::size(in)) { + : ctr_choice(CtrChoice::DirectCtr), size_(static_cast(std::ranges::size(in))) { std::ranges::copy(in, begin()); } @@ -54,7 +54,7 @@ struct Container { constexpr Container(std::from_range_t, std::ranges::input_range auto&& in) requires(Rank >= CtrChoice::FromRangeT) - : ctr_choice(CtrChoice::FromRangeT), size_(std::ranges::size(in)) { + : ctr_choice(CtrChoice::FromRangeT), size_(static_cast(std::ranges::size(in))) { std::ranges::copy(in, begin()); } @@ -70,7 +70,7 @@ struct Container { template constexpr Container(Iter b, Iter e) requires(Rank >= CtrChoice::BeginEndPair) - : ctr_choice(CtrChoice::BeginEndPair), size_(e - b) { + : ctr_choice(CtrChoice::BeginEndPair), size_(static_cast(e - b)) { std::ranges::copy(b, e, begin()); } diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_for_overwrite.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_for_overwrite.pass.cpp index 27ff3cd563740..e6e063304453a 100644 --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_for_overwrite.pass.cpp +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_for_overwrite.pass.cpp @@ -156,7 +156,7 @@ void testAllocatorOperationsCalled() { template struct AllocatorWithPattern { - constexpr static char pattern = 0xDE; + constexpr static char pattern = static_cast(0xDE); using value_type = T; diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared_for_overwrite.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared_for_overwrite.pass.cpp index 21e1786f01588..459b5a708cd4a 100644 --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared_for_overwrite.pass.cpp +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared_for_overwrite.pass.cpp @@ -56,7 +56,7 @@ static_assert(!HasMakeSharedForOverwrite); static_assert(!HasMakeSharedForOverwrite); static_assert(!HasMakeSharedForOverwrite); -constexpr char pattern = 0xDE; +constexpr char pattern = static_cast(0xDE); void* operator new(std::size_t count) { void* ptr = std::malloc(count); diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique_for_overwrite.default_init.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique_for_overwrite.default_init.pass.cpp index 8011a37be08ec..a1373ac3ac80c 100644 --- a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique_for_overwrite.default_init.pass.cpp +++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique_for_overwrite.default_init.pass.cpp @@ -23,7 +23,7 @@ #include #include -constexpr char pattern = 0xDE; +constexpr char pattern = static_cast(0xDE); void* operator new(std::size_t count) { void* ptr = std::malloc(count); diff --git a/libcxx/test/support/concat_macros.h b/libcxx/test/support/concat_macros.h index bc1306fbdb533..7621914e53f02 100644 --- a/libcxx/test/support/concat_macros.h +++ b/libcxx/test/support/concat_macros.h @@ -52,14 +52,14 @@ template requires std::output_iterator void test_encode(OutIt& out_it, char16_t value) { if (value < 0x80) - *out_it++ = value; + *out_it++ = static_cast(value); else if (value < 0x800) { - *out_it++ = 0b11000000 | (value >> 6); - *out_it++ = 0b10000000 | (value & 0b00111111); + *out_it++ = static_cast(0b11000000 | (value >> 6)); + *out_it++ = static_cast(0b10000000 | (value & 0b00111111)); } else { - *out_it++ = 0b11100000 | (value >> 12); - *out_it++ = 0b10000000 | ((value) >> 6 & 0b00111111); - *out_it++ = 0b10000000 | (value & 0b00111111); + *out_it++ = static_cast(0b11100000 | (value >> 12)); + *out_it++ = static_cast(0b10000000 | ((value) >> 6 & 0b00111111)); + *out_it++ = static_cast(0b10000000 | (value & 0b00111111)); } } @@ -69,10 +69,10 @@ void test_encode(OutIt& out_it, char32_t value) { if ((value & 0xffff0000) == 0) test_encode(out_it, static_cast(value)); else { - *out_it++ = 0b11100000 | (value >> 18); - *out_it++ = 0b10000000 | ((value) >> 12 & 0b00111111); - *out_it++ = 0b10000000 | ((value) >> 6 & 0b00111111); - *out_it++ = 0b10000000 | (value & 0b00111111); + *out_it++ = static_cast(0b11100000 | (value >> 18)); + *out_it++ = static_cast(0b10000000 | ((value) >> 12 & 0b00111111)); + *out_it++ = static_cast(0b10000000 | ((value) >> 6 & 0b00111111)); + *out_it++ = static_cast(0b10000000 | (value & 0b00111111)); } }