+2011-05-31 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * include/bits/basic_string.h: Use noexcept per the FDIS (minus
+ compare(const string&), which uses char_traits::compare, which
+ isn't noexcept; also no noexcept in the move assignment operator
+ and move assign, see c++std-lib-30855).
+ * include/bits/basic_string.tcc: Likewise.
+ * include/ext/vstring.h: Likewise.
+ * include/ext/vstring.tcc: Likewise.
+ * include/debug/string: Likewise.
+
2011-05-31 Jonathan Wakely <jwakely.gcc@gmail.com>
* doc/xml/manual/status_cxx200x.xml: Update.
* The newly-created string contains the exact contents of @a str.
* @a str is a valid, but unspecified string.
**/
- basic_string(basic_string&& __str)
+ basic_string(basic_string&& __str) noexcept
: _M_dataplus(__str._M_dataplus)
{
#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
* the %string. Unshares the string.
*/
iterator
- begin()
+ begin() _GLIBCXX_NOEXCEPT
{
_M_leak();
return iterator(_M_data());
* character in the %string.
*/
const_iterator
- begin() const
+ begin() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_M_data()); }
/**
* character in the %string. Unshares the string.
*/
iterator
- end()
+ end() _GLIBCXX_NOEXCEPT
{
_M_leak();
return iterator(_M_data() + this->size());
* last character in the %string.
*/
const_iterator
- end() const
+ end() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_M_data() + this->size()); }
/**
* order. Unshares the string.
*/
reverse_iterator
- rbegin()
+ rbegin() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(this->end()); }
/**
* reverse element order.
*/
const_reverse_iterator
- rbegin() const
+ rbegin() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(this->end()); }
/**
* element order. Unshares the string.
*/
reverse_iterator
- rend()
+ rend() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(this->begin()); }
/**
* is done in reverse element order.
*/
const_reverse_iterator
- rend() const
+ rend() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(this->begin()); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
* character in the %string.
*/
const_iterator
- cbegin() const
+ cbegin() const noexcept
{ return const_iterator(this->_M_data()); }
/**
* last character in the %string.
*/
const_iterator
- cend() const
+ cend() const noexcept
{ return const_iterator(this->_M_data() + this->size()); }
/**
* reverse element order.
*/
const_reverse_iterator
- crbegin() const
+ crbegin() const noexcept
{ return const_reverse_iterator(this->end()); }
/**
* is done in reverse element order.
*/
const_reverse_iterator
- crend() const
+ crend() const noexcept
{ return const_reverse_iterator(this->begin()); }
#endif
/// Returns the number of characters in the string, not including any
/// null-termination.
size_type
- size() const
+ size() const _GLIBCXX_NOEXCEPT
{ return _M_rep()->_M_length; }
/// Returns the number of characters in the string, not including any
/// null-termination.
size_type
- length() const
+ length() const _GLIBCXX_NOEXCEPT
{ return _M_rep()->_M_length; }
/// Returns the size() of the largest possible %string.
size_type
- max_size() const
+ max_size() const _GLIBCXX_NOEXCEPT
{ return _Rep::_S_max_size; }
/**
* before needing to allocate more memory.
*/
size_type
- capacity() const
+ capacity() const _GLIBCXX_NOEXCEPT
{ return _M_rep()->_M_capacity; }
/**
* Erases the string, making it empty.
*/
void
- clear()
+ clear() _GLIBCXX_NOEXCEPT
{ _M_mutate(0, this->size(), 0); }
/**
* <code>*this == ""</code>.
*/
bool
- empty() const
+ empty() const _GLIBCXX_NOEXCEPT
{ return this->size() == 0; }
// Element access:
* happen.
*/
const _CharT*
- c_str() const
+ c_str() const _GLIBCXX_NOEXCEPT
{ return _M_data(); }
/**
* happen.
*/
const _CharT*
- data() const
+ data() const _GLIBCXX_NOEXCEPT
{ return _M_data(); }
/**
* @brief Return copy of allocator used to construct this string.
*/
allocator_type
- get_allocator() const
+ get_allocator() const _GLIBCXX_NOEXCEPT
{ return _M_dataplus; }
/**
*/
size_type
find(const basic_string& __str, size_type __pos = 0) const
+ _GLIBCXX_NOEXCEPT
{ return this->find(__str.data(), __pos, __str.size()); }
/**
* returns npos.
*/
size_type
- find(_CharT __c, size_type __pos = 0) const;
+ find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
/**
* @brief Find last position of a string.
*/
size_type
rfind(const basic_string& __str, size_type __pos = npos) const
+ _GLIBCXX_NOEXCEPT
{ return this->rfind(__str.data(), __pos, __str.size()); }
/**
* returns npos.
*/
size_type
- rfind(_CharT __c, size_type __pos = npos) const;
+ rfind(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT;
/**
* @brief Find position of a character of string.
*/
size_type
find_first_of(const basic_string& __str, size_type __pos = 0) const
+ _GLIBCXX_NOEXCEPT
{ return this->find_first_of(__str.data(), __pos, __str.size()); }
/**
* Note: equivalent to find(c, pos).
*/
size_type
- find_first_of(_CharT __c, size_type __pos = 0) const
+ find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
{ return this->find(__c, __pos); }
/**
*/
size_type
find_last_of(const basic_string& __str, size_type __pos = npos) const
+ _GLIBCXX_NOEXCEPT
{ return this->find_last_of(__str.data(), __pos, __str.size()); }
/**
* Note: equivalent to rfind(c, pos).
*/
size_type
- find_last_of(_CharT __c, size_type __pos = npos) const
+ find_last_of(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT
{ return this->rfind(__c, __pos); }
/**
*/
size_type
find_first_not_of(const basic_string& __str, size_type __pos = 0) const
+ _GLIBCXX_NOEXCEPT
{ return this->find_first_not_of(__str.data(), __pos, __str.size()); }
/**
* If not found, returns npos.
*/
size_type
- find_first_not_of(_CharT __c, size_type __pos = 0) const;
+ find_first_not_of(_CharT __c, size_type __pos = 0) const
+ _GLIBCXX_NOEXCEPT;
/**
* @brief Find last position of a character not in string.
*/
size_type
find_last_not_of(const basic_string& __str, size_type __pos = npos) const
+ _GLIBCXX_NOEXCEPT
{ return this->find_last_not_of(__str.data(), __pos, __str.size()); }
/**
* found. If not found, returns npos.
*/
size_type
- find_last_not_of(_CharT __c, size_type __pos = npos) const;
+ find_last_not_of(_CharT __c, size_type __pos = npos) const
+ _GLIBCXX_NOEXCEPT;
/**
* @brief Get a substring.
template<typename _CharT, typename _Traits, typename _Alloc>
typename basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>::
- find(_CharT __c, size_type __pos) const
+ find(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT
{
size_type __ret = npos;
const size_type __size = this->size();
template<typename _CharT, typename _Traits, typename _Alloc>
typename basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>::
- rfind(_CharT __c, size_type __pos) const
+ rfind(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT
{
size_type __size = this->size();
if (__size)
template<typename _CharT, typename _Traits, typename _Alloc>
typename basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>::
- find_first_not_of(_CharT __c, size_type __pos) const
+ find_first_not_of(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT
{
for (; __pos < this->size(); ++__pos)
if (!traits_type::eq(_M_data()[__pos], __c))
template<typename _CharT, typename _Traits, typename _Alloc>
typename basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>::
- find_last_not_of(_CharT __c, size_type __pos) const
+ find_last_not_of(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT
{
size_type __size = this->size();
if (__size)
// Debugging string implementation -*- C++ -*-
-// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
{ }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
- basic_string(basic_string&& __str)
+ basic_string(basic_string&& __str) noexcept
: _Base(std::move(__str))
{ }
// 21.3.2 iterators:
iterator
- begin()
+ begin() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::begin(), this); }
const_iterator
- begin() const
+ begin() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::begin(), this); }
iterator
- end()
+ end() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::end(), this); }
const_iterator
- end() const
+ end() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::end(), this); }
reverse_iterator
- rbegin()
+ rbegin() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(end()); }
const_reverse_iterator
- rbegin() const
+ rbegin() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(end()); }
reverse_iterator
- rend()
+ rend() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(begin()); }
const_reverse_iterator
- rend() const
+ rend() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(begin()); }
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ const_iterator
+ cbegin() const noexcept
+ { return const_iterator(_Base::begin(), this); }
+
+ const_iterator
+ cend() const noexcept
+ { return const_iterator(_Base::end(), this); }
+
+ const_reverse_iterator
+ crbegin() const noexcept
+ { return const_reverse_iterator(end()); }
+
+ const_reverse_iterator
+ crend() const noexcept
+ { return const_reverse_iterator(begin()); }
+#endif
+
// 21.3.3 capacity:
using _Base::size;
using _Base::length;
using _Base::reserve;
void
- clear()
+ clear() _GLIBCXX_NOEXCEPT
{
_Base::clear();
this->_M_invalidate_all();
// 21.3.6 string operations:
const _CharT*
- c_str() const
+ c_str() const _GLIBCXX_NOEXCEPT
{
const _CharT* __res = _Base::c_str();
this->_M_invalidate_all();
}
const _CharT*
- data() const
+ data() const _GLIBCXX_NOEXCEPT
{
const _CharT* __res = _Base::data();
this->_M_invalidate_all();
size_type
find(const basic_string& __str, size_type __pos = 0) const
+ _GLIBCXX_NOEXCEPT
{ return _Base::find(__str, __pos); }
size_type
}
size_type
- find(_CharT __c, size_type __pos = 0) const
+ find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
{ return _Base::find(__c, __pos); }
size_type
rfind(const basic_string& __str, size_type __pos = _Base::npos) const
+ _GLIBCXX_NOEXCEPT
{ return _Base::rfind(__str, __pos); }
size_type
}
size_type
- rfind(_CharT __c, size_type __pos = _Base::npos) const
+ rfind(_CharT __c, size_type __pos = _Base::npos) const _GLIBCXX_NOEXCEPT
{ return _Base::rfind(__c, __pos); }
size_type
find_first_of(const basic_string& __str, size_type __pos = 0) const
+ _GLIBCXX_NOEXCEPT
{ return _Base::find_first_of(__str, __pos); }
size_type
}
size_type
- find_first_of(_CharT __c, size_type __pos = 0) const
+ find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
{ return _Base::find_first_of(__c, __pos); }
size_type
find_last_of(const basic_string& __str,
- size_type __pos = _Base::npos) const
+ size_type __pos = _Base::npos) const _GLIBCXX_NOEXCEPT
{ return _Base::find_last_of(__str, __pos); }
size_type
size_type
find_last_of(_CharT __c, size_type __pos = _Base::npos) const
+ _GLIBCXX_NOEXCEPT
{ return _Base::find_last_of(__c, __pos); }
size_type
find_first_not_of(const basic_string& __str, size_type __pos = 0) const
+ _GLIBCXX_NOEXCEPT
{ return _Base::find_first_not_of(__str, __pos); }
size_type
}
size_type
- find_first_not_of(_CharT __c, size_type __pos = 0) const
+ find_first_not_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
{ return _Base::find_first_not_of(__c, __pos); }
size_type
find_last_not_of(const basic_string& __str,
size_type __pos = _Base::npos) const
+ _GLIBCXX_NOEXCEPT
{ return _Base::find_last_not_of(__str, __pos); }
size_type
size_type
find_last_not_of(_CharT __c, size_type __pos = _Base::npos) const
+ _GLIBCXX_NOEXCEPT
{ return _Base::find_last_not_of(__c, __pos); }
basic_string
}
_Base&
- _M_base() { return *this; }
+ _M_base() _GLIBCXX_NOEXCEPT { return *this; }
const _Base&
- _M_base() const { return *this; }
+ _M_base() const _GLIBCXX_NOEXCEPT { return *this; }
using _Safe_base::_M_invalidate_all;
};
* @a str. The contents of @a str are a valid, but unspecified
* string.
*/
- __versa_string(__versa_string&& __str)
+ __versa_string(__versa_string&& __str) noexcept
: __vstring_base(std::move(__str)) { }
/**
* the %string. Unshares the string.
*/
iterator
- begin()
+ begin() _GLIBCXX_NOEXCEPT
{
this->_M_leak();
return iterator(this->_M_data());
* character in the %string.
*/
const_iterator
- begin() const
+ begin() const _GLIBCXX_NOEXCEPT
{ return const_iterator(this->_M_data()); }
/**
* character in the %string. Unshares the string.
*/
iterator
- end()
+ end() _GLIBCXX_NOEXCEPT
{
this->_M_leak();
return iterator(this->_M_data() + this->size());
* last character in the %string.
*/
const_iterator
- end() const
+ end() const _GLIBCXX_NOEXCEPT
{ return const_iterator(this->_M_data() + this->size()); }
/**
* order. Unshares the string.
*/
reverse_iterator
- rbegin()
+ rbegin() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(this->end()); }
/**
* reverse element order.
*/
const_reverse_iterator
- rbegin() const
+ rbegin() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(this->end()); }
/**
* element order. Unshares the string.
*/
reverse_iterator
- rend()
+ rend() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(this->begin()); }
/**
* is done in reverse element order.
*/
const_reverse_iterator
- rend() const
+ rend() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(this->begin()); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
* character in the %string.
*/
const_iterator
- cbegin() const
+ cbegin() const noexcept
{ return const_iterator(this->_M_data()); }
/**
* last character in the %string.
*/
const_iterator
- cend() const
+ cend() const noexcept
{ return const_iterator(this->_M_data() + this->size()); }
/**
* reverse element order.
*/
const_reverse_iterator
- crbegin() const
+ crbegin() const noexcept
{ return const_reverse_iterator(this->end()); }
/**
* is done in reverse element order.
*/
const_reverse_iterator
- crend() const
+ crend() const noexcept
{ return const_reverse_iterator(this->begin()); }
#endif
/// Returns the number of characters in the string, not including any
/// null-termination.
size_type
- size() const
+ size() const _GLIBCXX_NOEXCEPT
{ return this->_M_length(); }
/// Returns the number of characters in the string, not including any
/// null-termination.
size_type
- length() const
+ length() const _GLIBCXX_NOEXCEPT
{ return this->_M_length(); }
/// Returns the size() of the largest possible %string.
size_type
- max_size() const
+ max_size() const _GLIBCXX_NOEXCEPT
{ return this->_M_max_size(); }
/**
* hold before needing to allocate more memory.
*/
size_type
- capacity() const
+ capacity() const _GLIBCXX_NOEXCEPT
{ return this->_M_capacity(); }
/**
* Erases the string, making it empty.
*/
void
- clear()
+ clear() _GLIBCXX_NOEXCEPT
{ this->_M_clear(); }
/**
* <code>*this == ""</code>.
*/
bool
- empty() const
+ empty() const _GLIBCXX_NOEXCEPT
{ return this->size() == 0; }
// Element access:
* happen.
*/
const _CharT*
- c_str() const
+ c_str() const _GLIBCXX_NOEXCEPT
{ return this->_M_data(); }
/**
* happen.
*/
const _CharT*
- data() const
+ data() const _GLIBCXX_NOEXCEPT
{ return this->_M_data(); }
/**
* @brief Return copy of allocator used to construct this string.
*/
allocator_type
- get_allocator() const
+ get_allocator() const _GLIBCXX_NOEXCEPT
{ return allocator_type(this->_M_get_allocator()); }
/**
*/
size_type
find(const __versa_string& __str, size_type __pos = 0) const
+ _GLIBCXX_NOEXCEPT
{ return this->find(__str.data(), __pos, __str.size()); }
/**
* found. If not found, returns npos.
*/
size_type
- find(_CharT __c, size_type __pos = 0) const;
+ find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
/**
* @brief Find last position of a string.
*/
size_type
rfind(const __versa_string& __str, size_type __pos = npos) const
+ _GLIBCXX_NOEXCEPT
{ return this->rfind(__str.data(), __pos, __str.size()); }
/**
* found. If not found, returns npos.
*/
size_type
- rfind(_CharT __c, size_type __pos = npos) const;
+ rfind(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT;
/**
* @brief Find position of a character of string.
*/
size_type
find_first_of(const __versa_string& __str, size_type __pos = 0) const
+ _GLIBCXX_NOEXCEPT
{ return this->find_first_of(__str.data(), __pos, __str.size()); }
/**
* Note: equivalent to find(c, pos).
*/
size_type
- find_first_of(_CharT __c, size_type __pos = 0) const
+ find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
{ return this->find(__c, __pos); }
/**
*/
size_type
find_last_of(const __versa_string& __str, size_type __pos = npos) const
+ _GLIBCXX_NOEXCEPT
{ return this->find_last_of(__str.data(), __pos, __str.size()); }
/**
* Note: equivalent to rfind(c, pos).
*/
size_type
- find_last_of(_CharT __c, size_type __pos = npos) const
+ find_last_of(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT
{ return this->rfind(__c, __pos); }
/**
*/
size_type
find_first_not_of(const __versa_string& __str, size_type __pos = 0) const
+ _GLIBCXX_NOEXCEPT
{ return this->find_first_not_of(__str.data(), __pos, __str.size()); }
/**
* index where it was found. If not found, returns npos.
*/
size_type
- find_first_not_of(_CharT __c, size_type __pos = 0) const;
+ find_first_not_of(_CharT __c, size_type __pos = 0) const
+ _GLIBCXX_NOEXCEPT;
/**
* @brief Find last position of a character not in string.
*/
size_type
find_last_not_of(const __versa_string& __str,
- size_type __pos = npos) const
+ size_type __pos = npos) const _GLIBCXX_NOEXCEPT
{ return this->find_last_not_of(__str.data(), __pos, __str.size()); }
/**
* index where it was found. If not found, returns npos.
*/
size_type
- find_last_not_of(_CharT __c, size_type __pos = npos) const;
+ find_last_not_of(_CharT __c, size_type __pos = npos) const
+ _GLIBCXX_NOEXCEPT;
/**
* @brief Get a substring.
template <typename, typename, typename> class _Base>
typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
__versa_string<_CharT, _Traits, _Alloc, _Base>::
- find(_CharT __c, size_type __pos) const
+ find(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT
{
size_type __ret = npos;
const size_type __size = this->size();
template <typename, typename, typename> class _Base>
typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
__versa_string<_CharT, _Traits, _Alloc, _Base>::
- rfind(_CharT __c, size_type __pos) const
+ rfind(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT
{
size_type __size = this->size();
if (__size)
template <typename, typename, typename> class _Base>
typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
__versa_string<_CharT, _Traits, _Alloc, _Base>::
- find_first_not_of(_CharT __c, size_type __pos) const
+ find_first_not_of(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT
{
for (; __pos < this->size(); ++__pos)
if (!traits_type::eq(this->_M_data()[__pos], __c))
template <typename, typename, typename> class _Base>
typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type
__versa_string<_CharT, _Traits, _Alloc, _Base>::
- find_last_not_of(_CharT __c, size_type __pos) const
+ find_last_not_of(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT
{
size_type __size = this->size();
if (__size)