// Ensure that _M_local_buf is the active member of the union.
__attribute__((__always_inline__))
_GLIBCXX14_CONSTEXPR
- pointer
- _M_use_local_data() _GLIBCXX_NOEXCEPT
+ void
+ _M_init_local_buf() _GLIBCXX_NOEXCEPT
{
#if __cpp_lib_is_constant_evaluated
if (std::is_constant_evaluated())
for (size_type __i = 0; __i <= _S_local_capacity; ++__i)
_M_local_buf[__i] = _CharT();
+#endif
+ }
+
+ __attribute__((__always_inline__))
+ _GLIBCXX14_CONSTEXPR
+ pointer
+ _M_use_local_data() _GLIBCXX_NOEXCEPT
+ {
+#if __cpp_lib_is_constant_evaluated
+ _M_init_local_buf();
#endif
return _M_local_data();
}
_GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Alloc>::value)
: _M_dataplus(_M_local_data())
{
- _M_use_local_data();
+ _M_init_local_buf();
_M_set_length(0);
}
basic_string(const _Alloc& __a) _GLIBCXX_NOEXCEPT
: _M_dataplus(_M_local_data(), __a)
{
- _M_use_local_data();
+ _M_init_local_buf();
_M_set_length(0);
}
{
if (__str._M_is_local())
{
- (void)_M_use_local_data();
+ _M_init_local_buf();
traits_type::copy(_M_local_buf, __str._M_local_buf,
__str.length() + 1);
}
{
if (__str._M_is_local())
{
- (void)_M_use_local_data();
+ _M_init_local_buf();
traits_type::copy(_M_local_buf, __str._M_local_buf,
__str.length() + 1);
_M_length(__str.length());
}
else if (__s.length())
{
- (void)_M_use_local_data();
+ _M_init_local_buf();
traits_type::copy(_M_local_buf, __s._M_local_buf,
__s.length() + 1);
_M_length(__s.length());
}
else if (length())
{
- (void)__s._M_use_local_data();
+ __s._M_init_local_buf();
traits_type::copy(__s._M_local_buf, _M_local_buf,
length() + 1);
__s._M_length(length());
else
{
const size_type __tmp_capacity = __s._M_allocated_capacity;
- (void)__s._M_use_local_data();
+ __s._M_init_local_buf();
traits_type::copy(__s._M_local_buf, _M_local_buf,
length() + 1);
_M_data(__s._M_data());
const size_type __tmp_capacity = _M_allocated_capacity;
if (__s._M_is_local())
{
- (void)_M_use_local_data();
+ _M_init_local_buf();
traits_type::copy(_M_local_buf, __s._M_local_buf,
__s.length() + 1);
__s._M_data(_M_data());
size_type __len = 0;
size_type __capacity = size_type(_S_local_capacity);
- pointer __p = _M_use_local_data();
+ _M_init_local_buf();
while (__beg != __end && __len < __capacity)
{
- __p[__len++] = *__beg;
+ _M_local_buf[__len++] = *__beg;
++__beg;
}
_M_capacity(__dnew);
}
else
- _M_use_local_data();
+ _M_init_local_buf();
// Check for out_of_range and length_error exceptions.
struct _Guard
_M_capacity(__n);
}
else
- _M_use_local_data();
+ _M_init_local_buf();
if (__n)
this->_S_assign(_M_data(), __n, __c);
if (__length <= size_type(_S_local_capacity))
{
- this->_S_copy(_M_use_local_data(), _M_data(), __length + 1);
+ _M_init_local_buf();
+ this->_S_copy(_M_local_buf, _M_data(), __length + 1);
_M_destroy(__capacity);
_M_data(_M_local_data());
}