Commit 0e1a966a by Marc Glisse Committed by Marc Glisse

re PR libstdc++/58338 (Add noexcept to functions with a narrow contract)

2013-09-19  Marc Glisse  <marc.glisse@inria.fr>

	PR libstdc++/58338
	* include/bits/stl_tree.h (_Rb_tree_node_base) [_S_minimum, _S_maximum]:
	Mark as noexcept.
	(_Rb_tree_iterator) [_Rb_tree_iterator, operator*, operator->,
	operator++, operator--, operator==, operator!=]: Likewise.
	(_Rb_tree_const_iterator) [_Rb_tree_const_iterator, _M_const_cast,
	operator*, operator->, operator++, operator--, operator==, operator!=]:
	Likewise.
	(operator==(const _Rb_tree_iterator&, const _Rb_tree_const_iterator&),
	operator!=(const _Rb_tree_iterator&, const _Rb_tree_const_iterator&)):
	Likewise.
	(_Rb_tree) [_M_put_node, _M_destroy_node, _M_root, _M_leftmost,
	_M_rightmost, _M_begin, _M_end, _S_left, _S_right, _S_minimum,
	_S_maximum]: Likewise.
	* include/debug/string (basic_string) [basic_string(const _Allocator&),
	shrink_to_fit, operator[], pop_back]: Likewise.
	* include/ext/vstring.h (__versa_string) [_M_limit, _M_disjunct,
	_M_ibegin, _M_iend, __versa_string(const _Alloc&),
	operator=(__versa_string&&), shrink_to_fit, operator[], front,
	back, assign(__versa_string&&), swap]: Likewise.
	(__versa_string) [__versa_string(), __versa_string(const _Alloc&)]:
	Merge.

From-SVN: r202737
parent 06c055fc
2013-09-19 Marc Glisse <marc.glisse@inria.fr>
PR libstdc++/58338
* include/bits/stl_tree.h (_Rb_tree_node_base) [_S_minimum, _S_maximum]:
Mark as noexcept.
(_Rb_tree_iterator) [_Rb_tree_iterator, operator*, operator->,
operator++, operator--, operator==, operator!=]: Likewise.
(_Rb_tree_const_iterator) [_Rb_tree_const_iterator, _M_const_cast,
operator*, operator->, operator++, operator--, operator==, operator!=]:
Likewise.
(operator==(const _Rb_tree_iterator&, const _Rb_tree_const_iterator&),
operator!=(const _Rb_tree_iterator&, const _Rb_tree_const_iterator&)):
Likewise.
(_Rb_tree) [_M_put_node, _M_destroy_node, _M_root, _M_leftmost,
_M_rightmost, _M_begin, _M_end, _S_left, _S_right, _S_minimum,
_S_maximum]: Likewise.
* include/debug/string (basic_string) [basic_string(const _Allocator&),
shrink_to_fit, operator[], pop_back]: Likewise.
* include/ext/vstring.h (__versa_string) [_M_limit, _M_disjunct,
_M_ibegin, _M_iend, __versa_string(const _Alloc&),
operator=(__versa_string&&), shrink_to_fit, operator[], front,
back, assign(__versa_string&&), swap]: Likewise.
(__versa_string) [__versa_string(), __versa_string(const _Alloc&)]:
Merge.
2013-09-18 Marc Glisse <marc.glisse@inria.fr> 2013-09-18 Marc Glisse <marc.glisse@inria.fr>
PR libstdc++/58338 PR libstdc++/58338
......
...@@ -99,28 +99,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -99,28 +99,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_Base_ptr _M_right; _Base_ptr _M_right;
static _Base_ptr static _Base_ptr
_S_minimum(_Base_ptr __x) _S_minimum(_Base_ptr __x) _GLIBCXX_NOEXCEPT
{ {
while (__x->_M_left != 0) __x = __x->_M_left; while (__x->_M_left != 0) __x = __x->_M_left;
return __x; return __x;
} }
static _Const_Base_ptr static _Const_Base_ptr
_S_minimum(_Const_Base_ptr __x) _S_minimum(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPT
{ {
while (__x->_M_left != 0) __x = __x->_M_left; while (__x->_M_left != 0) __x = __x->_M_left;
return __x; return __x;
} }
static _Base_ptr static _Base_ptr
_S_maximum(_Base_ptr __x) _S_maximum(_Base_ptr __x) _GLIBCXX_NOEXCEPT
{ {
while (__x->_M_right != 0) __x = __x->_M_right; while (__x->_M_right != 0) __x = __x->_M_right;
return __x; return __x;
} }
static _Const_Base_ptr static _Const_Base_ptr
_S_maximum(_Const_Base_ptr __x) _S_maximum(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPT
{ {
while (__x->_M_right != 0) __x = __x->_M_right; while (__x->_M_right != 0) __x = __x->_M_right;
return __x; return __x;
...@@ -167,31 +167,31 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -167,31 +167,31 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef _Rb_tree_node_base::_Base_ptr _Base_ptr; typedef _Rb_tree_node_base::_Base_ptr _Base_ptr;
typedef _Rb_tree_node<_Tp>* _Link_type; typedef _Rb_tree_node<_Tp>* _Link_type;
_Rb_tree_iterator() _Rb_tree_iterator() _GLIBCXX_NOEXCEPT
: _M_node() { } : _M_node() { }
explicit explicit
_Rb_tree_iterator(_Link_type __x) _Rb_tree_iterator(_Link_type __x) _GLIBCXX_NOEXCEPT
: _M_node(__x) { } : _M_node(__x) { }
reference reference
operator*() const operator*() const _GLIBCXX_NOEXCEPT
{ return static_cast<_Link_type>(_M_node)->_M_value_field; } { return static_cast<_Link_type>(_M_node)->_M_value_field; }
pointer pointer
operator->() const operator->() const _GLIBCXX_NOEXCEPT
{ return std::__addressof(static_cast<_Link_type> { return std::__addressof(static_cast<_Link_type>
(_M_node)->_M_value_field); } (_M_node)->_M_value_field); }
_Self& _Self&
operator++() operator++() _GLIBCXX_NOEXCEPT
{ {
_M_node = _Rb_tree_increment(_M_node); _M_node = _Rb_tree_increment(_M_node);
return *this; return *this;
} }
_Self _Self
operator++(int) operator++(int) _GLIBCXX_NOEXCEPT
{ {
_Self __tmp = *this; _Self __tmp = *this;
_M_node = _Rb_tree_increment(_M_node); _M_node = _Rb_tree_increment(_M_node);
...@@ -199,14 +199,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -199,14 +199,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
_Self& _Self&
operator--() operator--() _GLIBCXX_NOEXCEPT
{ {
_M_node = _Rb_tree_decrement(_M_node); _M_node = _Rb_tree_decrement(_M_node);
return *this; return *this;
} }
_Self _Self
operator--(int) operator--(int) _GLIBCXX_NOEXCEPT
{ {
_Self __tmp = *this; _Self __tmp = *this;
_M_node = _Rb_tree_decrement(_M_node); _M_node = _Rb_tree_decrement(_M_node);
...@@ -214,11 +214,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -214,11 +214,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
bool bool
operator==(const _Self& __x) const operator==(const _Self& __x) const _GLIBCXX_NOEXCEPT
{ return _M_node == __x._M_node; } { return _M_node == __x._M_node; }
bool bool
operator!=(const _Self& __x) const operator!=(const _Self& __x) const _GLIBCXX_NOEXCEPT
{ return _M_node != __x._M_node; } { return _M_node != __x._M_node; }
_Base_ptr _M_node; _Base_ptr _M_node;
...@@ -240,39 +240,39 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -240,39 +240,39 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef _Rb_tree_node_base::_Const_Base_ptr _Base_ptr; typedef _Rb_tree_node_base::_Const_Base_ptr _Base_ptr;
typedef const _Rb_tree_node<_Tp>* _Link_type; typedef const _Rb_tree_node<_Tp>* _Link_type;
_Rb_tree_const_iterator() _Rb_tree_const_iterator() _GLIBCXX_NOEXCEPT
: _M_node() { } : _M_node() { }
explicit explicit
_Rb_tree_const_iterator(_Link_type __x) _Rb_tree_const_iterator(_Link_type __x) _GLIBCXX_NOEXCEPT
: _M_node(__x) { } : _M_node(__x) { }
_Rb_tree_const_iterator(const iterator& __it) _Rb_tree_const_iterator(const iterator& __it) _GLIBCXX_NOEXCEPT
: _M_node(__it._M_node) { } : _M_node(__it._M_node) { }
iterator iterator
_M_const_cast() const _M_const_cast() const _GLIBCXX_NOEXCEPT
{ return iterator(static_cast<typename iterator::_Link_type> { return iterator(static_cast<typename iterator::_Link_type>
(const_cast<typename iterator::_Base_ptr>(_M_node))); } (const_cast<typename iterator::_Base_ptr>(_M_node))); }
reference reference
operator*() const operator*() const _GLIBCXX_NOEXCEPT
{ return static_cast<_Link_type>(_M_node)->_M_value_field; } { return static_cast<_Link_type>(_M_node)->_M_value_field; }
pointer pointer
operator->() const operator->() const _GLIBCXX_NOEXCEPT
{ return std::__addressof(static_cast<_Link_type> { return std::__addressof(static_cast<_Link_type>
(_M_node)->_M_value_field); } (_M_node)->_M_value_field); }
_Self& _Self&
operator++() operator++() _GLIBCXX_NOEXCEPT
{ {
_M_node = _Rb_tree_increment(_M_node); _M_node = _Rb_tree_increment(_M_node);
return *this; return *this;
} }
_Self _Self
operator++(int) operator++(int) _GLIBCXX_NOEXCEPT
{ {
_Self __tmp = *this; _Self __tmp = *this;
_M_node = _Rb_tree_increment(_M_node); _M_node = _Rb_tree_increment(_M_node);
...@@ -280,14 +280,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -280,14 +280,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
_Self& _Self&
operator--() operator--() _GLIBCXX_NOEXCEPT
{ {
_M_node = _Rb_tree_decrement(_M_node); _M_node = _Rb_tree_decrement(_M_node);
return *this; return *this;
} }
_Self _Self
operator--(int) operator--(int) _GLIBCXX_NOEXCEPT
{ {
_Self __tmp = *this; _Self __tmp = *this;
_M_node = _Rb_tree_decrement(_M_node); _M_node = _Rb_tree_decrement(_M_node);
...@@ -295,11 +295,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -295,11 +295,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
bool bool
operator==(const _Self& __x) const operator==(const _Self& __x) const _GLIBCXX_NOEXCEPT
{ return _M_node == __x._M_node; } { return _M_node == __x._M_node; }
bool bool
operator!=(const _Self& __x) const operator!=(const _Self& __x) const _GLIBCXX_NOEXCEPT
{ return _M_node != __x._M_node; } { return _M_node != __x._M_node; }
_Base_ptr _M_node; _Base_ptr _M_node;
...@@ -308,13 +308,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -308,13 +308,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Val> template<typename _Val>
inline bool inline bool
operator==(const _Rb_tree_iterator<_Val>& __x, operator==(const _Rb_tree_iterator<_Val>& __x,
const _Rb_tree_const_iterator<_Val>& __y) const _Rb_tree_const_iterator<_Val>& __y) _GLIBCXX_NOEXCEPT
{ return __x._M_node == __y._M_node; } { return __x._M_node == __y._M_node; }
template<typename _Val> template<typename _Val>
inline bool inline bool
operator!=(const _Rb_tree_iterator<_Val>& __x, operator!=(const _Rb_tree_iterator<_Val>& __x,
const _Rb_tree_const_iterator<_Val>& __y) const _Rb_tree_const_iterator<_Val>& __y) _GLIBCXX_NOEXCEPT
{ return __x._M_node != __y._M_node; } { return __x._M_node != __y._M_node; }
void void
...@@ -370,7 +370,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -370,7 +370,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ return _M_impl._Node_allocator::allocate(1); } { return _M_impl._Node_allocator::allocate(1); }
void void
_M_put_node(_Link_type __p) _M_put_node(_Link_type __p) _GLIBCXX_NOEXCEPT
{ _M_impl._Node_allocator::deallocate(__p, 1); } { _M_impl._Node_allocator::deallocate(__p, 1); }
#if __cplusplus < 201103L #if __cplusplus < 201103L
...@@ -416,7 +416,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -416,7 +416,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
void void
_M_destroy_node(_Link_type __p) _M_destroy_node(_Link_type __p) noexcept
{ {
_M_get_Node_allocator().destroy(__p); _M_get_Node_allocator().destroy(__p);
_M_put_node(__p); _M_put_node(__p);
...@@ -474,46 +474,46 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -474,46 +474,46 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
protected: protected:
_Base_ptr& _Base_ptr&
_M_root() _M_root() _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_header._M_parent; } { return this->_M_impl._M_header._M_parent; }
_Const_Base_ptr _Const_Base_ptr
_M_root() const _M_root() const _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_header._M_parent; } { return this->_M_impl._M_header._M_parent; }
_Base_ptr& _Base_ptr&
_M_leftmost() _M_leftmost() _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_header._M_left; } { return this->_M_impl._M_header._M_left; }
_Const_Base_ptr _Const_Base_ptr
_M_leftmost() const _M_leftmost() const _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_header._M_left; } { return this->_M_impl._M_header._M_left; }
_Base_ptr& _Base_ptr&
_M_rightmost() _M_rightmost() _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_header._M_right; } { return this->_M_impl._M_header._M_right; }
_Const_Base_ptr _Const_Base_ptr
_M_rightmost() const _M_rightmost() const _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_header._M_right; } { return this->_M_impl._M_header._M_right; }
_Link_type _Link_type
_M_begin() _M_begin() _GLIBCXX_NOEXCEPT
{ return static_cast<_Link_type>(this->_M_impl._M_header._M_parent); } { return static_cast<_Link_type>(this->_M_impl._M_header._M_parent); }
_Const_Link_type _Const_Link_type
_M_begin() const _M_begin() const _GLIBCXX_NOEXCEPT
{ {
return static_cast<_Const_Link_type> return static_cast<_Const_Link_type>
(this->_M_impl._M_header._M_parent); (this->_M_impl._M_header._M_parent);
} }
_Link_type _Link_type
_M_end() _M_end() _GLIBCXX_NOEXCEPT
{ return static_cast<_Link_type>(&this->_M_impl._M_header); } { return static_cast<_Link_type>(&this->_M_impl._M_header); }
_Const_Link_type _Const_Link_type
_M_end() const _M_end() const _GLIBCXX_NOEXCEPT
{ return static_cast<_Const_Link_type>(&this->_M_impl._M_header); } { return static_cast<_Const_Link_type>(&this->_M_impl._M_header); }
static const_reference static const_reference
...@@ -525,19 +525,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -525,19 +525,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ return _KeyOfValue()(_S_value(__x)); } { return _KeyOfValue()(_S_value(__x)); }
static _Link_type static _Link_type
_S_left(_Base_ptr __x) _S_left(_Base_ptr __x) _GLIBCXX_NOEXCEPT
{ return static_cast<_Link_type>(__x->_M_left); } { return static_cast<_Link_type>(__x->_M_left); }
static _Const_Link_type static _Const_Link_type
_S_left(_Const_Base_ptr __x) _S_left(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPT
{ return static_cast<_Const_Link_type>(__x->_M_left); } { return static_cast<_Const_Link_type>(__x->_M_left); }
static _Link_type static _Link_type
_S_right(_Base_ptr __x) _S_right(_Base_ptr __x) _GLIBCXX_NOEXCEPT
{ return static_cast<_Link_type>(__x->_M_right); } { return static_cast<_Link_type>(__x->_M_right); }
static _Const_Link_type static _Const_Link_type
_S_right(_Const_Base_ptr __x) _S_right(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPT
{ return static_cast<_Const_Link_type>(__x->_M_right); } { return static_cast<_Const_Link_type>(__x->_M_right); }
static const_reference static const_reference
...@@ -549,19 +549,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -549,19 +549,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ return _KeyOfValue()(_S_value(__x)); } { return _KeyOfValue()(_S_value(__x)); }
static _Base_ptr static _Base_ptr
_S_minimum(_Base_ptr __x) _S_minimum(_Base_ptr __x) _GLIBCXX_NOEXCEPT
{ return _Rb_tree_node_base::_S_minimum(__x); } { return _Rb_tree_node_base::_S_minimum(__x); }
static _Const_Base_ptr static _Const_Base_ptr
_S_minimum(_Const_Base_ptr __x) _S_minimum(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPT
{ return _Rb_tree_node_base::_S_minimum(__x); } { return _Rb_tree_node_base::_S_minimum(__x); }
static _Base_ptr static _Base_ptr
_S_maximum(_Base_ptr __x) _S_maximum(_Base_ptr __x) _GLIBCXX_NOEXCEPT
{ return _Rb_tree_node_base::_S_maximum(__x); } { return _Rb_tree_node_base::_S_maximum(__x); }
static _Const_Base_ptr static _Const_Base_ptr
_S_maximum(_Const_Base_ptr __x) _S_maximum(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPT
{ return _Rb_tree_node_base::_S_maximum(__x); } { return _Rb_tree_node_base::_S_maximum(__x); }
public: public:
......
...@@ -70,6 +70,7 @@ namespace __gnu_debug ...@@ -70,6 +70,7 @@ namespace __gnu_debug
// 21.3.1 construct/copy/destroy: // 21.3.1 construct/copy/destroy:
explicit basic_string(const _Allocator& __a = _Allocator()) explicit basic_string(const _Allocator& __a = _Allocator())
_GLIBCXX_NOEXCEPT
: _Base(__a) : _Base(__a)
{ } { }
...@@ -238,7 +239,7 @@ namespace __gnu_debug ...@@ -238,7 +239,7 @@ namespace __gnu_debug
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
void void
shrink_to_fit() shrink_to_fit() noexcept
{ {
if (capacity() > size()) if (capacity() > size())
{ {
...@@ -267,7 +268,7 @@ namespace __gnu_debug ...@@ -267,7 +268,7 @@ namespace __gnu_debug
// 21.3.4 element access: // 21.3.4 element access:
const_reference const_reference
operator[](size_type __pos) const operator[](size_type __pos) const _GLIBCXX_NOEXCEPT
{ {
_GLIBCXX_DEBUG_VERIFY(__pos <= this->size(), _GLIBCXX_DEBUG_VERIFY(__pos <= this->size(),
_M_message(__gnu_debug::__msg_subscript_oob) _M_message(__gnu_debug::__msg_subscript_oob)
...@@ -278,7 +279,7 @@ namespace __gnu_debug ...@@ -278,7 +279,7 @@ namespace __gnu_debug
} }
reference reference
operator[](size_type __pos) operator[](size_type __pos) _GLIBCXX_NOEXCEPT
{ {
#ifdef _GLIBCXX_DEBUG_PEDANTIC #ifdef _GLIBCXX_DEBUG_PEDANTIC
__glibcxx_check_subscript(__pos); __glibcxx_check_subscript(__pos);
...@@ -582,7 +583,7 @@ namespace __gnu_debug ...@@ -582,7 +583,7 @@ namespace __gnu_debug
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
void void
pop_back() pop_back() noexcept
{ {
__glibcxx_check_nonempty(); __glibcxx_check_nonempty();
_Base::pop_back(); _Base::pop_back();
......
...@@ -98,7 +98,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -98,7 +98,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// NB: _M_limit doesn't check for a bad __pos value. // NB: _M_limit doesn't check for a bad __pos value.
size_type size_type
_M_limit(size_type __pos, size_type __off) const _M_limit(size_type __pos, size_type __off) const _GLIBCXX_NOEXCEPT
{ {
const bool __testoff = __off < this->size() - __pos; const bool __testoff = __off < this->size() - __pos;
return __testoff ? __off : this->size() - __pos; return __testoff ? __off : this->size() - __pos;
...@@ -106,7 +106,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -106,7 +106,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// True if _Rep and source do not overlap. // True if _Rep and source do not overlap.
bool bool
_M_disjunct(const _CharT* __s) const _M_disjunct(const _CharT* __s) const _GLIBCXX_NOEXCEPT
{ {
return (std::less<const _CharT*>()(__s, this->_M_data()) return (std::less<const _CharT*>()(__s, this->_M_data())
|| std::less<const _CharT*>()(this->_M_data() || std::less<const _CharT*>()(this->_M_data()
...@@ -116,11 +116,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -116,11 +116,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// For the internal use we have functions similar to `begin'/`end' // For the internal use we have functions similar to `begin'/`end'
// but they do not call _M_leak. // but they do not call _M_leak.
iterator iterator
_M_ibegin() const _M_ibegin() const _GLIBCXX_NOEXCEPT
{ return iterator(this->_M_data()); } { return iterator(this->_M_data()); }
iterator iterator
_M_iend() const _M_iend() const _GLIBCXX_NOEXCEPT
{ return iterator(this->_M_data() + this->_M_length()); } { return iterator(this->_M_data() + this->_M_length()); }
public: public:
...@@ -129,16 +129,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -129,16 +129,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// arguments, per 17.4.4.4 para. 2 item 2. // arguments, per 17.4.4.4 para. 2 item 2.
/** /**
* @brief Default constructor creates an empty string.
*/
__versa_string()
: __vstring_base() { }
/**
* @brief Construct an empty string using allocator @a a. * @brief Construct an empty string using allocator @a a.
*/ */
explicit explicit
__versa_string(const _Alloc& __a) __versa_string(const _Alloc& __a = _Alloc()) _GLIBCXX_NOEXCEPT
: __vstring_base(__a) { } : __vstring_base(__a) { }
// NB: per LWG issue 42, semantics different from IS: // NB: per LWG issue 42, semantics different from IS:
...@@ -269,7 +263,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -269,7 +263,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* copying). @a __str is a valid, but unspecified string. * copying). @a __str is a valid, but unspecified string.
*/ */
__versa_string& __versa_string&
operator=(__versa_string&& __str) operator=(__versa_string&& __str) noexcept
{ {
// NB: DR 1204. // NB: DR 1204.
this->swap(__str); this->swap(__str);
...@@ -470,7 +464,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -470,7 +464,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
/// A non-binding request to reduce capacity() to size(). /// A non-binding request to reduce capacity() to size().
void void
shrink_to_fit() shrink_to_fit() noexcept
{ {
if (capacity() > size()) if (capacity() > size())
{ {
...@@ -538,7 +532,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -538,7 +532,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* see at().) * see at().)
*/ */
const_reference const_reference
operator[] (size_type __pos) const operator[] (size_type __pos) const _GLIBCXX_NOEXCEPT
{ {
_GLIBCXX_DEBUG_ASSERT(__pos <= this->size()); _GLIBCXX_DEBUG_ASSERT(__pos <= this->size());
return this->_M_data()[__pos]; return this->_M_data()[__pos];
...@@ -555,7 +549,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -555,7 +549,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* see at().) Unshares the string. * see at().) Unshares the string.
*/ */
reference reference
operator[](size_type __pos) operator[](size_type __pos) _GLIBCXX_NOEXCEPT
{ {
// Allow pos == size() both in C++98 mode, as v3 extension, // Allow pos == size() both in C++98 mode, as v3 extension,
// and in C++11 mode. // and in C++11 mode.
...@@ -611,7 +605,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -611,7 +605,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* element of the %string. * element of the %string.
*/ */
reference reference
front() front() _GLIBCXX_NOEXCEPT
{ return operator[](0); } { return operator[](0); }
/** /**
...@@ -619,7 +613,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -619,7 +613,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* element of the %string. * element of the %string.
*/ */
const_reference const_reference
front() const front() const _GLIBCXX_NOEXCEPT
{ return operator[](0); } { return operator[](0); }
/** /**
...@@ -627,7 +621,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -627,7 +621,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* element of the %string. * element of the %string.
*/ */
reference reference
back() back() _GLIBCXX_NOEXCEPT
{ return operator[](this->size() - 1); } { return operator[](this->size() - 1); }
/** /**
...@@ -635,7 +629,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -635,7 +629,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* last element of the %string. * last element of the %string.
*/ */
const_reference const_reference
back() const back() const _GLIBCXX_NOEXCEPT
{ return operator[](this->size() - 1); } { return operator[](this->size() - 1); }
#endif #endif
...@@ -814,7 +808,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -814,7 +808,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @a __str is a valid, but unspecified string. * @a __str is a valid, but unspecified string.
*/ */
__versa_string& __versa_string&
assign(__versa_string&& __str) assign(__versa_string&& __str) noexcept
{ {
this->swap(__str); this->swap(__str);
return *this; return *this;
...@@ -1631,7 +1625,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1631,7 +1625,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* constant time. * constant time.
*/ */
void void
swap(__versa_string& __s) swap(__versa_string& __s) _GLIBCXX_NOEXCEPT
{ this->_M_swap(__s); } { this->_M_swap(__s); }
// String operations: // String operations:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment