Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fe7f82e

Browse files
<xstring>: Make char_traits::assign not start lifetime of elements (#4613)
1 parent 9c04cbe commit fe7f82e

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

stl/inc/xstring

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -161,31 +161,15 @@ struct _Char_traits { // properties of a string or stream element
161161
static _CONSTEXPR20 _Elem* assign(
162162
_Out_writes_all_(_Count) _Elem* const _First, size_t _Count, const _Elem _Ch) noexcept /* strengthened */ {
163163
// assign _Count * _Ch to [_First, ...)
164-
#if _HAS_CXX20
165-
if (_STD is_constant_evaluated()) {
166-
for (_Elem* _Next = _First; _Count > 0; --_Count, ++_Next) {
167-
_STD construct_at(_Next, _Ch);
168-
}
169-
} else
170-
#endif // _HAS_CXX20
171-
{
172-
for (_Elem* _Next = _First; _Count > 0; --_Count, ++_Next) {
173-
*_Next = _Ch;
174-
}
164+
for (_Elem* _Next = _First; _Count > 0; --_Count, ++_Next) {
165+
*_Next = _Ch;
175166
}
176167

177168
return _First;
178169
}
179170

180171
static _CONSTEXPR17 void assign(_Elem& _Left, const _Elem& _Right) noexcept {
181-
#if _HAS_CXX20
182-
if (_STD is_constant_evaluated()) {
183-
_STD construct_at(_STD addressof(_Left), _Right);
184-
} else
185-
#endif // _HAS_CXX20
186-
{
187-
_Left = _Right;
188-
}
172+
_Left = _Right;
189173
}
190174

191175
_NODISCARD static constexpr bool eq(const _Elem _Left, const _Elem _Right) noexcept {

0 commit comments

Comments
 (0)