basic_string.h (assign(__str, __pos, __n)): Call assign(__s, __n).
2001-12-18 Paolo Carlini <pcarlini@unitus.it> Nathan Myers <ncm@cantrip.org> * include/bits/basic_string.h (assign(__str, __pos, __n)): Call assign(__s, __n). (assign(__s, __n)): Terminate the string with _S_terminal. Co-Authored-By: Nathan Myers <ncm@cantrip.org> From-SVN: r48151
This commit is contained in:
parent
ea50ad828c
commit
c448ca845c
2 changed files with 13 additions and 19 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2001-12-18 Paolo Carlini <pcarlini@unitus.it>
|
||||||
|
Nathan Myers <ncm@cantrip.org>
|
||||||
|
|
||||||
|
* include/bits/basic_string.h (assign(__str, __pos, __n)):
|
||||||
|
Call assign(__s, __n).
|
||||||
|
(assign(__s, __n)): Terminate the string with _S_terminal.
|
||||||
|
|
||||||
2001-12-17 Benjamin Kosnik <bkoz@redhat.com>
|
2001-12-17 Benjamin Kosnik <bkoz@redhat.com>
|
||||||
|
|
||||||
* include/bits/std_limits.h (__glibcpp_long_double_is_bounded):
|
* include/bits/std_limits.h (__glibcpp_long_double_is_bounded):
|
||||||
|
|
|
@ -478,26 +478,12 @@ namespace std
|
||||||
basic_string&
|
basic_string&
|
||||||
assign(const basic_string& __str, size_type __pos, size_type __n)
|
assign(const basic_string& __str, size_type __pos, size_type __n)
|
||||||
{
|
{
|
||||||
if (__pos > __str.size())
|
const size_type __strsize = __str.size();
|
||||||
|
if (__pos > __strsize)
|
||||||
__throw_out_of_range("basic_string::assign");
|
__throw_out_of_range("basic_string::assign");
|
||||||
if (_M_rep()->_M_is_shared() || _M_rep() != __str._M_rep())
|
const bool __testn = __n < __strsize - __pos;
|
||||||
return _M_replace_safe(_M_ibegin(), _M_iend(),
|
const size_type __newsize = __testn ? __n : __strsize - __pos;
|
||||||
__str._M_check(__pos),
|
return this->assign(__str._M_data() + __pos, __newsize);
|
||||||
__str._M_fold(__pos, __n));
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Work in-place.
|
|
||||||
bool __testn = __n < __str.size() - __pos;
|
|
||||||
const size_type __newsize = __testn ? __n : __str.size() - __pos;
|
|
||||||
// Avoid move, if possible.
|
|
||||||
if (__pos >= __newsize)
|
|
||||||
traits_type::copy(_M_data(), __str._M_data() + __pos, __newsize);
|
|
||||||
else if (__pos)
|
|
||||||
traits_type::move(_M_data(), __str._M_data() + __pos, __newsize);
|
|
||||||
// else nothing (avoid calling move unnecessarily)
|
|
||||||
_M_rep()->_M_length = __newsize;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_string&
|
basic_string&
|
||||||
|
@ -517,6 +503,7 @@ namespace std
|
||||||
else if (__pos)
|
else if (__pos)
|
||||||
traits_type::move(_M_data(), __s, __n);
|
traits_type::move(_M_data(), __s, __n);
|
||||||
_M_rep()->_M_length = __n;
|
_M_rep()->_M_length = __n;
|
||||||
|
_M_data()[__n] = _Rep::_S_terminal;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue