* @a __str is a valid, but unspecified string.
*/
basic_string(basic_string&& __str) noexcept
-#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
: _M_dataplus(std::move(__str._M_dataplus))
{
+#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
+ // Make __str use the shared empty string rep.
__str._M_data(_S_empty_rep()._M_refdata());
- }
#else
- : _M_dataplus(__str._M_rep())
- {
// Rather than allocate an empty string for the rvalue string,
// just share ownership with it by incrementing the reference count.
// If the rvalue string was "leaked" then it was the unique owner,
__gnu_cxx::__atomic_add_dispatch(&_M_rep()->_M_refcount, 2);
else
__gnu_cxx::__atomic_add_dispatch(&_M_rep()->_M_refcount, 1);
- }
#endif
+ }
/**
* @brief Construct string from an initializer %list.
typedef std::string stype;
-// True except for COW strings with _GLIBCXX_FULLY_DYNAMIC_STRING:
static_assert(std::is_nothrow_move_constructible<stype>::value, "Error");
// True for std::allocator because is_always_equal, but not true in general:
typedef std::wstring wstype;
-// True except for COW strings with _GLIBCXX_FULLY_DYNAMIC_STRING:
static_assert(std::is_nothrow_move_constructible<wstype>::value, "Error");
// True for std::allocator because is_always_equal, but not true in general: