зеркало из https://github.com/microsoft/STL.git
<algorithm>: fill should accept volatile byte pointers (#1557)
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
This commit is contained in:
Родитель
3a7946ebf4
Коммит
85ad05396a
|
@ -4361,11 +4361,12 @@ struct _Is_character_or_byte_or_bool<byte> : true_type {};
|
|||
template <>
|
||||
struct _Is_character_or_byte_or_bool<bool> : true_type {};
|
||||
|
||||
// _Fill_memset_is_safe determines if _FwdIt and _Ty are eligible for memset optimization in fill
|
||||
// _Fill_memset_is_safe determines if _FwdIt and _Ty are eligible for memset optimization in fill.
|
||||
// Need to explicitly test for volatile because _Unwrap_enum_t discards qualifiers.
|
||||
template <class _FwdIt, class _Ty, bool = is_pointer_v<_FwdIt>>
|
||||
_INLINE_VAR constexpr bool _Fill_memset_is_safe = conjunction_v<is_scalar<_Ty>,
|
||||
_Is_character_or_byte_or_bool<_Unwrap_enum_t<remove_reference_t<_Iter_ref_t<_FwdIt>>>>,
|
||||
is_assignable<_Iter_ref_t<_FwdIt>, const _Ty&>>;
|
||||
negation<is_volatile<remove_reference_t<_Iter_ref_t<_FwdIt>>>>, is_assignable<_Iter_ref_t<_FwdIt>, const _Ty&>>;
|
||||
|
||||
template <class _FwdIt, class _Ty>
|
||||
_INLINE_VAR constexpr bool _Fill_memset_is_safe<_FwdIt, _Ty, false> = false;
|
||||
|
|
|
@ -134,6 +134,9 @@ int main() {
|
|||
test_fill<char, int>();
|
||||
|
||||
test_fill<volatile char, char>(); // Test GH-1183
|
||||
#ifdef __cpp_lib_byte
|
||||
test_fill<volatile byte, byte>(); // Test GH-1556
|
||||
#endif // __cpp_lib_byte
|
||||
|
||||
test_uninitialized_fill(
|
||||
[](count_copies* buff, size_t n, const count_copies& src) { uninitialized_fill(buff, buff + n, src); });
|
||||
|
|
Загрузка…
Ссылка в новой задаче