Skip to content

Commit 30a9274

Browse files
committed
Replace enable_if by static_assert
1 parent a2d2f23 commit 30a9274

File tree

6 files changed

+12
-8
lines changed

6 files changed

+12
-8
lines changed

libcxx/include/__bit_reference

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,11 @@ struct __size_difference_type_traits<_Cp, __void_t<typename _Cp::difference_type
6363
// or `unsigned short`. Casting back to _StorageType is crucial to prevent undefined behavior that can arise
6464
// from integral promotions.
6565
// See https://github.com/llvm/llvm-project/pull/122410.
66-
template <class _StoragePointer,
67-
__enable_if_t<is_unsigned<typename pointer_traits<_StoragePointer>::element_type>::value, int> >
66+
template <class _StoragePointer>
6867
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
6968
__fill_masked_range(_StoragePointer __word, unsigned __clz, unsigned __ctz, bool __fill_val) {
69+
static_assert(is_unsigned<typename pointer_traits<_StoragePointer>::element_type>::value,
70+
"__fill_masked_range must be called with unsigned type");
7071
using _StorageType = typename pointer_traits<_StoragePointer>::element_type;
7172
_LIBCPP_ASSERT_VALID_INPUT_RANGE(
7273
__ctz + __clz < sizeof(_StorageType) * CHAR_BIT, "__fill_masked_range called with invalid range");

libcxx/include/__fwd/bit_reference.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ class __bit_iterator;
2626
template <class, class = void>
2727
struct __size_difference_type_traits;
2828

29-
template <class _StoragePointer,
30-
__enable_if_t<is_unsigned<typename pointer_traits<_StoragePointer>::element_type>::value, int> = 0>
29+
template <class _StoragePointer>
3130
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
3231
__fill_masked_range(_StoragePointer __word, unsigned __ctz, unsigned __clz, bool __fill_val);
3332

libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ struct Test {
4747
}
4848
};
4949

50+
// Make sure std::fill behaves properly with std::vector<bool> iterators with custom size types.
51+
// See https://github.com/llvm/llvm-project/pull/122410.
5052
TEST_CONSTEXPR_CXX20 void test_bititer_with_custom_sized_types() {
5153
{
5254
using Alloc = sized_allocator<bool, std::uint8_t, std::int8_t>;

libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ void test6() {
129129
std::fill_n(&foo[0], UDI(5), Storage());
130130
}
131131

132+
// Make sure std::fill_n behaves properly with std::vector<bool> iterators with custom size types.
133+
// See https://github.com/llvm/llvm-project/pull/122410.
132134
TEST_CONSTEXPR_CXX20 void test_bititer_with_custom_sized_types() {
133135
{
134136
using Alloc = sized_allocator<bool, std::uint8_t, std::int8_t>;

libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/ranges.fill.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ constexpr void test_iterators() {
7878
}
7979
}
8080

81-
// Make sure we behave properly with std::vector<bool> iterators with custom size types, see
82-
// https://github.com/llvm/llvm-project/pull/122410.
81+
// Make sure std::ranges::fill behaves properly with std::vector<bool> iterators with custom
82+
// size types. See https://github.com/llvm/llvm-project/pull/122410.
8383
//
8484
// The `ranges::{fill, fill_n}` algorithms require `vector<bool, Alloc>::iterator` to satisfy
8585
// the `std::indirectly_writable` concept when used with `vector<bool, Alloc>`, which is only

libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/ranges.fill_n.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ constexpr void test_iterators() {
5151
}
5252
}
5353

54-
// Make sure we behave properly with std::vector<bool> iterators with custom size types, see
55-
// https://github.com/llvm/llvm-project/pull/122410.
54+
// Make sure std::ranges::fill_n behaves properly with std::vector<bool> iterators with custom
55+
// size types. See https://github.com/llvm/llvm-project/pull/122410.
5656
//
5757
// The `ranges::{fill, fill_n}` algorithms require `vector<bool, Alloc>::iterator` to satisfy
5858
// the `std::indirectly_writable` concept when used with `vector<bool, Alloc>`, which is only

0 commit comments

Comments
 (0)