#pragma GCC system_header
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <initializer_list>
+#endif
+
#include <ext/vstring_util.h>
#include <ext/rc_string_base.h>
#include <ext/sso_string_base.h>
// NB: per LWG issue 42, semantics different from IS:
/**
- * @brief Construct string with copy of value of @a str.
+ * @brief Construct string with copy of value of @a __str.
* @param __str Source string.
*/
__versa_string(const __versa_string& __str)
* @param __str Source string.
*
* The newly-constructed %string contains the exact contents of
- * @a str. The contents of @a str are a valid, but unspecified
+ * @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)) { }
/**
/**
* @brief Destroy the string instance.
*/
- ~__versa_string() { }
+ ~__versa_string() _GLIBCXX_NOEXCEPT { }
/**
* @brief Assign the value of @a str to this string.
* 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(); }
/**
void
shrink_to_fit()
{
- __try
- { this->reserve(0); }
- __catch(...)
- { }
+ if (capacity() > size())
+ {
+ __try
+ { this->reserve(0); }
+ __catch(...)
+ { }
+ }
}
#endif
* 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:
return iterator(this->_M_data() + __pos);
}
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ /**
+ * @brief Remove the last character.
+ *
+ * The string must be non-empty.
+ */
+ void
+ pop_back()
+ { this->_M_erase(size()-1, 1); }
+#endif // __GXX_EXPERIMENTAL_CXX0X__
+
/**
* @brief Replace characters with value from another string.
* @param __pos Index of first character to replace.
&& __i2 <= _M_iend());
__glibcxx_requires_valid_range(__k1, __k2);
typedef typename std::__is_integer<_InputIterator>::__type _Integral;
- return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
+ return this->_M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
}
// Specializations for the common case of pointer and iterator:
* 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.
int __r = traits_type::compare(this->_M_data(), __str.data(), __len);
if (!__r)
- __r = _S_compare(__size, __osize);
+ __r = this->_S_compare(__size, __osize);
return __r;
}
/**
* @brief Compare substring against a character array.
- * @param __pos1 Index of first character of substring.
+ * @param __pos Index of first character of substring.
* @param __n1 Number of characters in substring.
* @param __s character array to compare against.
* @param __n2 Number of characters of s.
* @return Integer < 0, 0, or > 0.
*
* Form the substring of this string from the @a __n1
- * characters starting at @a __pos1. Form a string from the
+ * characters starting at @a __pos. Form a string from the
* first @a __n2 characters of @a __s. Returns an integer < 0
* if this substring is ordered before the string from @a __s,
* 0 if their values are equivalent, or > 0 if this substring
* effective length rlen of the strings to compare as the
* smallest of the length of the substring and @a __n2. The
* function then compares the two strings by calling
- * traits::compare(substring.data(),s,rlen). If the result of
+ * traits::compare(substring.data(),__s,rlen). If the result of
* the comparison is nonzero returns it, otherwise the shorter
* one is ordered first.
*
- * NB: s must have at least n2 characters, <em>\\0</em> has no special
+ * NB: __s must have at least n2 characters, <em>\\0</em> has no special
* meaning.
*/
int