Skip to content

Commit d9504e4

Browse files
committed
Address @ldionne's review comments
1 parent 3afaddf commit d9504e4

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

libcxx/include/__algorithm/fill_n.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ __fill_n_bool(__bit_iterator<_Cp, false> __first, typename __size_difference_typ
4141
if (__first.__ctz_ != 0) {
4242
__storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);
4343
__storage_type __dn = std::min(__clz_f, __n);
44-
__storage_type __m = std::__middle_mask<__storage_type>(__first.__ctz_, __clz_f - __dn);
45-
if (_FillVal)
46-
*__first.__seg_ |= __m;
47-
else
48-
*__first.__seg_ &= ~__m;
44+
*__first.__seg_ = __fill_range_in_word(*__first.__seg_, __first.__ctz_, __clz_f - __dn, _FillVal);
4945
__n -= __dn;
5046
++__first.__seg_;
5147
}
@@ -56,11 +52,7 @@ __fill_n_bool(__bit_iterator<_Cp, false> __first, typename __size_difference_typ
5652
// do last partial word
5753
if (__n > 0) {
5854
__first.__seg_ += __nw;
59-
__storage_type __m = std::__trailing_mask<__storage_type>(__bits_per_word - __n);
60-
if (_FillVal)
61-
*__first.__seg_ |= __m;
62-
else
63-
*__first.__seg_ &= ~__m;
55+
*__first.__seg_ = __fill_range_in_word(*__first.__seg_, 0u, __bits_per_word - __n, _FillVal);
6456
}
6557
}
6658

libcxx/include/__fwd/bit_reference.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2424
template <class _Cp, bool _IsConst, typename _Cp::__storage_type = 0>
2525
class __bit_iterator;
2626

27+
template <class, class = void>
28+
struct __size_difference_type_traits;
29+
2730
template <class _StorageType, __enable_if_t<is_unsigned<_StorageType>::value, int> = 0>
2831
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _StorageType
2932
__fill_range_in_word(_StorageType __word, unsigned __ctz, unsigned __clz, bool __fill_val) {

libcxx/test/support/sized_allocator.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616

1717
#include "test_macros.h"
1818

19-
template <typename T, typename SIZE_TYPE = std::size_t, typename DIFF_TYPE = std::ptrdiff_t>
19+
template <typename T, typename Size = std::size_t, typename Difference = std::ptrdiff_t>
2020
class sized_allocator {
2121
template <typename U, typename Sz, typename Diff>
2222
friend class sized_allocator;
2323

2424
public:
2525
using value_type = T;
26-
using size_type = SIZE_TYPE;
27-
using difference_type = DIFF_TYPE;
26+
using size_type = Size;
27+
using difference_type = Difference;
2828
using propagate_on_container_swap = std::true_type;
2929

3030
TEST_CONSTEXPR_CXX20 explicit sized_allocator(int d = 0) : data_(d) {}
@@ -55,4 +55,4 @@ class sized_allocator {
5555
}
5656
};
5757

58-
#endif
58+
#endif // TEST_SUPPORT_SIZED_ALLOCATOR_H

0 commit comments

Comments
 (0)