Commit 0e50667c by Paolo Carlini Committed by Paolo Carlini

basic_string.h (_M_replace_aux): Use the __N marker in throw message.

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.

From-SVN: r76664
parent d6456562
2004-01-26 Paolo Carlini <pcarlini@suse.de> 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, * include/bits/basic_string.h (replace(iterator, iterator,
const basic_string&)): Remove _GLIBCXX_DEBUG_PEDASSERT. const basic_string&)): Remove _GLIBCXX_DEBUG_PEDASSERT.
(replace(iterator, iterator, const _CharT*)): Ditto. (replace(iterator, iterator, const _CharT*)): Ditto.
......
...@@ -1362,7 +1362,7 @@ namespace std ...@@ -1362,7 +1362,7 @@ namespace std
_CharT __c) _CharT __c)
{ {
if (this->max_size() - (this->size() - __n1) < __n2) 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); _M_mutate(__pos1, __n1, __n2);
if (__n2) if (__n2)
traits_type::assign(_M_data() + __pos1, __n2, __c); traits_type::assign(_M_data() + __pos1, __n2, __c);
...@@ -1383,8 +1383,8 @@ namespace std ...@@ -1383,8 +1383,8 @@ namespace std
// requires special behaviour if _InIter is an integral type // requires special behaviour if _InIter is an integral type
template<class _InIterator> template<class _InIterator>
static _CharT* static _CharT*
_S_construct_aux(_InIterator __beg, _InIterator __end, const _Alloc& __a, _S_construct_aux(_InIterator __beg, _InIterator __end,
__false_type) const _Alloc& __a, __false_type)
{ {
typedef typename iterator_traits<_InIterator>::iterator_category _Tag; typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
return _S_construct(__beg, __end, __a, _Tag()); return _S_construct(__beg, __end, __a, _Tag());
...@@ -1392,12 +1392,10 @@ namespace std ...@@ -1392,12 +1392,10 @@ namespace std
template<class _InIterator> template<class _InIterator>
static _CharT* static _CharT*
_S_construct_aux(_InIterator __beg, _InIterator __end, const _Alloc& __a, _S_construct_aux(_InIterator __beg, _InIterator __end,
__true_type) const _Alloc& __a, __true_type)
{ { return _S_construct(static_cast<size_type>(__beg),
return _S_construct(static_cast<size_type>(__beg), static_cast<value_type>(__end), __a); }
static_cast<value_type>(__end), __a);
}
template<class _InIterator> template<class _InIterator>
static _CharT* static _CharT*
...@@ -1457,8 +1455,7 @@ namespace std ...@@ -1457,8 +1455,7 @@ namespace std
* happen. * happen.
*/ */
const _CharT* const _CharT*
c_str() const c_str() const { return _M_data(); }
{ return _M_data(); }
/** /**
* @brief Return const pointer to contents. * @brief Return const pointer to contents.
...@@ -1845,7 +1842,8 @@ namespace std ...@@ -1845,7 +1842,8 @@ namespace std
*/ */
basic_string basic_string
substr(size_type __pos = 0, size_type __n = npos) const 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. * @brief Compare to a string.
...@@ -1958,9 +1956,10 @@ namespace std ...@@ -1958,9 +1956,10 @@ namespace std
* at @a pos1. Form a string from the first @a n2 characters of @a s. * 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 * 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 * 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 * is ordered after the string from @a s. If the lengths of this
* and @a n2 are different, the shorter one is ordered first. If they are * substring and @a n2 are different, the shorter one is ordered first.
* the same, returns the result of traits::compare(substring.data(),s,size()); * 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 * NB: s must have at least n2 characters, '\0' has no special
* meaning. * meaning.
......
...@@ -153,9 +153,10 @@ namespace std ...@@ -153,9 +153,10 @@ namespace std
// NB: Not required, but considered best practice. // NB: Not required, but considered best practice.
if (__builtin_expect(__is_null_pointer(__beg), 0)) 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. // Check for out_of_range and length_error exceptions.
_Rep* __r = _Rep::_S_create(__dnew, __a); _Rep* __r = _Rep::_S_create(__dnew, __a);
...@@ -207,8 +208,10 @@ namespace std ...@@ -207,8 +208,10 @@ namespace std
basic_string<_CharT, _Traits, _Alloc>:: basic_string<_CharT, _Traits, _Alloc>::
basic_string(const basic_string& __str, size_type __pos, size_type __n) basic_string(const basic_string& __str, size_type __pos, size_type __n)
: _M_dataplus(_S_construct(__str._M_ibegin() : _M_dataplus(_S_construct(__str._M_ibegin()
+ __str._M_check(__pos, "basic_string::basic_string"), + __str._M_check(__pos,
__str._M_ibegin() + __pos + __str._M_limit(__pos, __n), "basic_string::basic_string"),
__str._M_ibegin() + __pos
+ __str._M_limit(__pos, __n),
_Alloc()), _Alloc()) _Alloc()), _Alloc())
{ } { }
...@@ -217,9 +220,10 @@ namespace std ...@@ -217,9 +220,10 @@ namespace std
basic_string(const basic_string& __str, size_type __pos, basic_string(const basic_string& __str, size_type __pos,
size_type __n, const _Alloc& __a) size_type __n, const _Alloc& __a)
: _M_dataplus(_S_construct(__str._M_ibegin() : _M_dataplus(_S_construct(__str._M_ibegin()
+ __str._M_check(__pos, "basic_string::basic_string"), + __str._M_check(__pos,
__str._M_ibegin() + __pos + __str._M_limit(__pos, __n), "basic_string::basic_string"),
__a), __a) __str._M_ibegin() + __pos
+ __str._M_limit(__pos, __n), __a), __a)
{ } { }
// TBD: DPG annotate // TBD: DPG annotate
...@@ -274,7 +278,7 @@ namespace std ...@@ -274,7 +278,7 @@ namespace std
{ {
__glibcxx_requires_string_len(__s, __n); __glibcxx_requires_string_len(__s, __n);
if (__n > this->max_size()) 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()) if (_M_rep()->_M_is_shared() || less<const _CharT*>()(__s, _M_data())
|| less<const _CharT*>()(_M_data() + this->size(), __s)) || less<const _CharT*>()(_M_data() + this->size(), __s))
return _M_replace_safe(size_type(0), this->size(), __s, __n); return _M_replace_safe(size_type(0), this->size(), __s, __n);
...@@ -300,7 +304,7 @@ namespace std ...@@ -300,7 +304,7 @@ namespace std
__glibcxx_requires_string_len(__s, __n); __glibcxx_requires_string_len(__s, __n);
_M_check(__pos, "basic_string::insert"); _M_check(__pos, "basic_string::insert");
if (this->max_size() - this->size() < __n) 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()) if (_M_rep()->_M_is_shared() || less<const _CharT*>()(__s, _M_data())
|| less<const _CharT*>()(_M_data() + this->size(), __s)) || less<const _CharT*>()(_M_data() + this->size(), __s))
return _M_replace_safe(__pos, size_type(0), __s, __n); return _M_replace_safe(__pos, size_type(0), __s, __n);
...@@ -337,7 +341,7 @@ namespace std ...@@ -337,7 +341,7 @@ namespace std
_M_check(__pos, "basic_string::replace"); _M_check(__pos, "basic_string::replace");
__n1 = _M_limit(__pos, __n1); __n1 = _M_limit(__pos, __n1);
if (this->max_size() - (this->size() - __n1) < __n2) if (this->max_size() - (this->size() - __n1) < __n2)
__throw_length_error("basic_string::replace"); __throw_length_error(__N("basic_string::replace"));
bool __left; bool __left;
if (_M_rep()->_M_is_shared() || less<const _CharT*>()(__s, _M_data()) if (_M_rep()->_M_is_shared() || less<const _CharT*>()(__s, _M_data())
|| less<const _CharT*>()(_M_data() + this->size(), __s)) || less<const _CharT*>()(_M_data() + this->size(), __s))
...@@ -451,7 +455,7 @@ namespace std ...@@ -451,7 +455,7 @@ namespace std
if (__res != this->capacity() || _M_rep()->_M_is_shared()) if (__res != this->capacity() || _M_rep()->_M_is_shared())
{ {
if (__res > this->max_size()) 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 // Make sure we don't shrink below the current size
if (__res < this->size()) if (__res < this->size())
__res = this->size(); __res = this->size();
...@@ -478,9 +482,10 @@ namespace std ...@@ -478,9 +482,10 @@ namespace std
// The code below can usually be optimized away. // The code below can usually be optimized away.
else else
{ {
basic_string __tmp1(_M_ibegin(), _M_iend(), __s.get_allocator()); const basic_string __tmp1(_M_ibegin(), _M_iend(),
basic_string __tmp2(__s._M_ibegin(), __s._M_iend(), __s.get_allocator());
this->get_allocator()); const basic_string __tmp2(__s._M_ibegin(), __s._M_iend(),
this->get_allocator());
*this = __tmp2; *this = __tmp2;
__s = __tmp1; __s = __tmp1;
} }
...@@ -495,7 +500,7 @@ namespace std ...@@ -495,7 +500,7 @@ namespace std
// _GLIBCXX_RESOLVE_LIB_DEFECTS // _GLIBCXX_RESOLVE_LIB_DEFECTS
// 83. String::npos vs. string::max_size() // 83. String::npos vs. string::max_size()
if (__capacity > _S_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 // NB: Need an array of char_type[__capacity], plus a
// terminating null char_type() element, plus enough for the // terminating null char_type() element, plus enough for the
...@@ -591,7 +596,7 @@ namespace std ...@@ -591,7 +596,7 @@ namespace std
basic_string<_CharT, _Traits, _Alloc>::resize(size_type __n, _CharT __c) basic_string<_CharT, _Traits, _Alloc>::resize(size_type __n, _CharT __c)
{ {
if (__n > max_size()) if (__n > max_size())
__throw_length_error("basic_string::resize"); __throw_length_error(__N("basic_string::resize"));
const size_type __size = this->size(); const size_type __size = this->size();
if (__size < __n) if (__size < __n)
this->append(__n - __size, __c); this->append(__n - __size, __c);
...@@ -610,7 +615,7 @@ namespace std ...@@ -610,7 +615,7 @@ namespace std
const basic_string __s(__k1, __k2); const basic_string __s(__k1, __k2);
const size_type __n1 = __i2 - __i1; const size_type __n1 = __i2 - __i1;
if (this->max_size() - (this->size() - __n1) < __s.size()) 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(), return _M_replace_safe(__i1 - _M_ibegin(), __n1, __s._M_data(),
__s.size()); __s.size());
} }
......
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