*
* The newly-created string contains the exact contents of @a __str.
* @a __str is a valid, but unspecified string.
- **/
+ */
basic_string(basic_string&& __str) noexcept
: _M_dataplus(_M_local_data(), std::move(__str._M_get_allocator()))
{
*
* The contents of @a str are moved into this string (without copying).
* @a str is a valid, but unspecified string.
- **/
+ */
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2063. Contradictory requirements for string move assignment
basic_string&
* @brief Construct an empty string using allocator @a a.
*/
explicit
- basic_string(const _Alloc& __a);
+ basic_string(const _Alloc& __a)
+ : _M_dataplus(_S_construct(size_type(), _CharT(), __a), __a)
+ { }
// NB: per LWG issue 42, semantics different from IS:
/**
* @brief Construct string with copy of value of @a str.
* @param __str Source string.
*/
- basic_string(const basic_string& __str);
+ basic_string(const basic_string& __str)
+ : _M_dataplus(__str._M_rep()->_M_grab(_Alloc(__str.get_allocator()),
+ __str.get_allocator()),
+ __str.get_allocator())
+ { }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2583. no way to supply an allocator for basic_string(str, pos)
* has no special meaning.
*/
basic_string(const _CharT* __s, size_type __n,
- const _Alloc& __a = _Alloc());
+ const _Alloc& __a = _Alloc())
+ : _M_dataplus(_S_construct(__s, __s + __n, __a), __a)
+ { }
/**
* @brief Construct string as copy of a C string.
// 3076. basic_string CTAD ambiguity
template<typename = _RequireAllocator<_Alloc>>
#endif
- basic_string(const _CharT* __s, const _Alloc& __a = _Alloc());
+ basic_string(const _CharT* __s, const _Alloc& __a = _Alloc())
+ : _M_dataplus(_S_construct(__s, __s ? __s + traits_type::length(__s) :
+ __s + npos, __a), __a)
+ { }
/**
* @brief Construct string as multiple characters.
* @param __c Character to use.
* @param __a Allocator to use (default is default allocator).
*/
- basic_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc());
+ basic_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc())
+ : _M_dataplus(_S_construct(__n, __c, __a), __a)
+ { }
#if __cplusplus >= 201103L
/**
*
* The newly-created string contains the exact contents of @a __str.
* @a __str is a valid, but unspecified string.
- **/
+ */
basic_string(basic_string&& __str)
#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
noexcept // FIXME C++11: should always be noexcept.
* @param __l std::initializer_list of characters.
* @param __a Allocator to use (default is default allocator).
*/
- basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc());
+ basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc())
+ : _M_dataplus(_S_construct(__l.begin(), __l.end(), __a), __a)
+ { }
basic_string(const basic_string& __str, const _Alloc& __a)
: _M_dataplus(__str._M_rep()->_M_grab(__a, __str.get_allocator()), __a)
*/
template<class _InputIterator>
basic_string(_InputIterator __beg, _InputIterator __end,
- const _Alloc& __a = _Alloc());
+ const _Alloc& __a = _Alloc())
+ : _M_dataplus(_S_construct(__beg, __end, __a), __a)
+ { }
#if __cplusplus >= 201703L
/**
*
* The contents of @a str are moved into this string (without copying).
* @a str is a valid, but unspecified string.
- **/
+ */
basic_string&
operator=(basic_string&& __str)
_GLIBCXX_NOEXCEPT_IF(allocator_traits<_Alloc>::is_always_equal::value)
return __r->_M_refdata();
}
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT, _Traits, _Alloc>::
- basic_string(const basic_string& __str)
- : _M_dataplus(__str._M_rep()->_M_grab(_Alloc(__str.get_allocator()),
- __str.get_allocator()),
- __str.get_allocator())
- { }
-
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT, _Traits, _Alloc>::
- basic_string(const _Alloc& __a)
- : _M_dataplus(_S_construct(size_type(), _CharT(), __a), __a)
- { }
-
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>::
basic_string(const basic_string& __str, size_type __pos, const _Alloc& __a)
+ __pos, __a), __a)
{ }
- // TBD: DPG annotate
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT, _Traits, _Alloc>::
- basic_string(const _CharT* __s, size_type __n, const _Alloc& __a)
- : _M_dataplus(_S_construct(__s, __s + __n, __a), __a)
- { }
-
- // TBD: DPG annotate
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT, _Traits, _Alloc>::
- basic_string(const _CharT* __s, const _Alloc& __a)
- : _M_dataplus(_S_construct(__s, __s ? __s + traits_type::length(__s) :
- __s + npos, __a), __a)
- { }
-
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT, _Traits, _Alloc>::
- basic_string(size_type __n, _CharT __c, const _Alloc& __a)
- : _M_dataplus(_S_construct(__n, __c, __a), __a)
- { }
-
- // TBD: DPG annotate
- template<typename _CharT, typename _Traits, typename _Alloc>
- template<typename _InputIterator>
- basic_string<_CharT, _Traits, _Alloc>::
- basic_string(_InputIterator __beg, _InputIterator __end, const _Alloc& __a)
- : _M_dataplus(_S_construct(__beg, __end, __a), __a)
- { }
-
-#if __cplusplus >= 201103L
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT, _Traits, _Alloc>::
- basic_string(initializer_list<_CharT> __l, const _Alloc& __a)
- : _M_dataplus(_S_construct(__l.begin(), __l.end(), __a), __a)
- { }
-#endif
-
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>&
basic_string<_CharT, _Traits, _Alloc>::