2004-01-26 Paolo Carlini <pcarlini@suse.de>
+ * include/bits/basic_string.h (_M_replace_aux): Use the
+ __N marker in throw message.
+ * include/bits/basic_string.tcc (assign(const _CharT*,
+ size_type), insert(size_type, const _CharT*, size_type),
+ replace(size_type, size_type, const _CharT*, size_type),
+ reserve, _Rep::_S_create, resize, _M_replace_dispatch):
+ Likewise.
+
+ * include/bits/basic_string.h, include/bits/basic_string.tcc:
+ Fold overlong lines, minor formatting changes.
+
+2004-01-26 Paolo Carlini <pcarlini@suse.de>
+
* include/bits/basic_string.h (replace(iterator, iterator,
const basic_string&)): Remove _GLIBCXX_DEBUG_PEDASSERT.
(replace(iterator, iterator, const _CharT*)): Ditto.
_CharT __c)
{
if (this->max_size() - (this->size() - __n1) < __n2)
- __throw_length_error("basic_string::_M_replace_aux");
+ __throw_length_error(__N("basic_string::_M_replace_aux"));
_M_mutate(__pos1, __n1, __n2);
if (__n2)
traits_type::assign(_M_data() + __pos1, __n2, __c);
// requires special behaviour if _InIter is an integral type
template<class _InIterator>
static _CharT*
- _S_construct_aux(_InIterator __beg, _InIterator __end, const _Alloc& __a,
- __false_type)
+ _S_construct_aux(_InIterator __beg, _InIterator __end,
+ const _Alloc& __a, __false_type)
{
typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
return _S_construct(__beg, __end, __a, _Tag());
template<class _InIterator>
static _CharT*
- _S_construct_aux(_InIterator __beg, _InIterator __end, const _Alloc& __a,
- __true_type)
- {
- return _S_construct(static_cast<size_type>(__beg),
- static_cast<value_type>(__end), __a);
- }
+ _S_construct_aux(_InIterator __beg, _InIterator __end,
+ const _Alloc& __a, __true_type)
+ { return _S_construct(static_cast<size_type>(__beg),
+ static_cast<value_type>(__end), __a); }
template<class _InIterator>
static _CharT*
* happen.
*/
const _CharT*
- c_str() const
- { return _M_data(); }
+ c_str() const { return _M_data(); }
/**
* @brief Return const pointer to contents.
*/
basic_string
substr(size_type __pos = 0, size_type __n = npos) const
- { return basic_string(*this, _M_check(__pos, "basic_string::substr"), __n); }
+ { return basic_string(*this,
+ _M_check(__pos, "basic_string::substr"), __n); }
/**
* @brief Compare to a string.
* at @a pos1. 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
- * is ordered after the string from @a s. If the lengths of this substring
- * and @a n2 are different, the shorter one is ordered first. If they are
- * the same, returns the result of traits::compare(substring.data(),s,size());
+ * is ordered after the string from @a s. If the lengths of this
+ * substring and @a n2 are different, the shorter one is ordered first.
+ * If they are the same, returns the result of
+ * traits::compare(substring.data(),s,size());
*
* NB: s must have at least n2 characters, '\0' has no special
* meaning.
// NB: Not required, but considered best practice.
if (__builtin_expect(__is_null_pointer(__beg), 0))
- __throw_logic_error("basic_string::_S_construct NULL not valid");
+ __throw_logic_error(__N("basic_string::_S_construct NULL not valid"));
- const size_type __dnew = static_cast<size_type>(std::distance(__beg, __end));
+ const size_type __dnew = static_cast<size_type>(std::distance(__beg,
+ __end));
// Check for out_of_range and length_error exceptions.
_Rep* __r = _Rep::_S_create(__dnew, __a);
basic_string<_CharT, _Traits, _Alloc>::
basic_string(const basic_string& __str, size_type __pos, size_type __n)
: _M_dataplus(_S_construct(__str._M_ibegin()
- + __str._M_check(__pos, "basic_string::basic_string"),
- __str._M_ibegin() + __pos + __str._M_limit(__pos, __n),
+ + __str._M_check(__pos,
+ "basic_string::basic_string"),
+ __str._M_ibegin() + __pos
+ + __str._M_limit(__pos, __n),
_Alloc()), _Alloc())
{ }
basic_string(const basic_string& __str, size_type __pos,
size_type __n, const _Alloc& __a)
: _M_dataplus(_S_construct(__str._M_ibegin()
- + __str._M_check(__pos, "basic_string::basic_string"),
- __str._M_ibegin() + __pos + __str._M_limit(__pos, __n),
- __a), __a)
+ + __str._M_check(__pos,
+ "basic_string::basic_string"),
+ __str._M_ibegin() + __pos
+ + __str._M_limit(__pos, __n), __a), __a)
{ }
// TBD: DPG annotate
{
__glibcxx_requires_string_len(__s, __n);
if (__n > this->max_size())
- __throw_length_error("basic_string::assign");
+ __throw_length_error(__N("basic_string::assign"));
if (_M_rep()->_M_is_shared() || less<const _CharT*>()(__s, _M_data())
|| less<const _CharT*>()(_M_data() + this->size(), __s))
return _M_replace_safe(size_type(0), this->size(), __s, __n);
__glibcxx_requires_string_len(__s, __n);
_M_check(__pos, "basic_string::insert");
if (this->max_size() - this->size() < __n)
- __throw_length_error("basic_string::insert");
+ __throw_length_error(__N("basic_string::insert"));
if (_M_rep()->_M_is_shared() || less<const _CharT*>()(__s, _M_data())
|| less<const _CharT*>()(_M_data() + this->size(), __s))
return _M_replace_safe(__pos, size_type(0), __s, __n);
_M_check(__pos, "basic_string::replace");
__n1 = _M_limit(__pos, __n1);
if (this->max_size() - (this->size() - __n1) < __n2)
- __throw_length_error("basic_string::replace");
+ __throw_length_error(__N("basic_string::replace"));
bool __left;
if (_M_rep()->_M_is_shared() || less<const _CharT*>()(__s, _M_data())
|| less<const _CharT*>()(_M_data() + this->size(), __s))
if (__res != this->capacity() || _M_rep()->_M_is_shared())
{
if (__res > this->max_size())
- __throw_length_error("basic_string::reserve");
+ __throw_length_error(__N("basic_string::reserve"));
// Make sure we don't shrink below the current size
if (__res < this->size())
__res = this->size();
// The code below can usually be optimized away.
else
{
- basic_string __tmp1(_M_ibegin(), _M_iend(), __s.get_allocator());
- basic_string __tmp2(__s._M_ibegin(), __s._M_iend(),
- this->get_allocator());
+ const basic_string __tmp1(_M_ibegin(), _M_iend(),
+ __s.get_allocator());
+ const basic_string __tmp2(__s._M_ibegin(), __s._M_iend(),
+ this->get_allocator());
*this = __tmp2;
__s = __tmp1;
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 83. String::npos vs. string::max_size()
if (__capacity > _S_max_size)
- __throw_length_error("basic_string::_S_create");
+ __throw_length_error(__N("basic_string::_S_create"));
// NB: Need an array of char_type[__capacity], plus a
// terminating null char_type() element, plus enough for the
basic_string<_CharT, _Traits, _Alloc>::resize(size_type __n, _CharT __c)
{
if (__n > max_size())
- __throw_length_error("basic_string::resize");
+ __throw_length_error(__N("basic_string::resize"));
const size_type __size = this->size();
if (__size < __n)
this->append(__n - __size, __c);
const basic_string __s(__k1, __k2);
const size_type __n1 = __i2 - __i1;
if (this->max_size() - (this->size() - __n1) < __s.size())
- __throw_length_error("basic_string::_M_replace_dispatch");
+ __throw_length_error(__N("basic_string::_M_replace_dispatch"));
return _M_replace_safe(__i1 - _M_ibegin(), __n1, __s._M_data(),
__s.size());
}