aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@suse.de>2005-12-01 18:03:20 +0000
committerPaolo Carlini <pcarlini@suse.de>2005-12-01 18:03:20 +0000
commit0b6517201eb00362cdb109deec858e466d5813b8 (patch)
treeb705f1228492651a4c4267fb3057bc9b1bc80d16
parent137f6a68054a4766c62447d8e7a5e1ee87539da3 (diff)
2005-12-01 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.tcc (basic_string<>::_M_replace): Perform _M_check_length at the beginning and remove it from ... (append(size_type, _CharT), _M_replace_dispatch, _M_replace_aux, assign): ... here. (assign): Now move inline. (resize): Don't call _M_check_length redundantly, append does. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/libstdcxx_so_7-branch@107825 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libstdc++-v3/ChangeLog.libstdcxx_so_7-branch9
-rw-r--r--libstdc++-v3/include/bits/basic_string.h6
-rw-r--r--libstdc++-v3/include/bits/basic_string.tcc16
3 files changed, 16 insertions, 15 deletions
diff --git a/libstdc++-v3/ChangeLog.libstdcxx_so_7-branch b/libstdc++-v3/ChangeLog.libstdcxx_so_7-branch
index 74cbffcc602..d5d4b158006 100644
--- a/libstdc++-v3/ChangeLog.libstdcxx_so_7-branch
+++ b/libstdc++-v3/ChangeLog.libstdcxx_so_7-branch
@@ -1,5 +1,14 @@
2005-12-01 Paolo Carlini <pcarlini@suse.de>
+ * include/bits/basic_string.tcc (basic_string<>::_M_replace):
+ Perform _M_check_length at the beginning and remove it from ...
+ (append(size_type, _CharT), _M_replace_dispatch, _M_replace_aux,
+ assign): ... here.
+ (assign): Now move inline.
+ (resize): Don't call _M_check_length redundantly, append does.
+
+2005-12-01 Paolo Carlini <pcarlini@suse.de>
+
* include/bits/stl_vector.h (vector<>::size, resize, capacity,
operator[]): Avoid troubles with ADL, user defined operators
and __normal_iterator.
diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index 8b039f169b3..4d373054347 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -690,7 +690,11 @@ namespace std
* available characters in @a s, the remainder of @a s is used.
*/
basic_string&
- assign(const _CharT* __s, size_type __n);
+ assign(const _CharT* __s, size_type __n)
+ {
+ __glibcxx_requires_string_len(__s, __n);
+ return _M_replace(size_type(0), this->size(), __s, __n);
+ }
/**
* @brief Set value to contents of a C string.
diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc
index 2eed5f89ba5..c288703e42b 100644
--- a/libstdc++-v3/include/bits/basic_string.tcc
+++ b/libstdc++-v3/include/bits/basic_string.tcc
@@ -69,16 +69,6 @@ namespace std
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>&
basic_string<_CharT, _Traits, _Alloc>::
- assign(const _CharT* __s, size_type __n)
- {
- __glibcxx_requires_string_len(__s, __n);
- _M_check_length(this->size(), __n, "basic_string::assign");
- return _M_replace(size_type(0), this->size(), __s, __n);
- }
-
- template<typename _CharT, typename _Traits, typename _Alloc>
- basic_string<_CharT, _Traits, _Alloc>&
- basic_string<_CharT, _Traits, _Alloc>::
append(size_type __n, _CharT __c)
{
if (__n)
@@ -166,7 +156,6 @@ namespace std
__glibcxx_requires_string_len(__s, __n2);
_M_check(__pos, "basic_string::replace");
__n1 = _M_limit(__pos, __n1);
- _M_check_length(__n1, __n2, "basic_string::replace");
return _M_replace(__pos, __n1, __s, __n2);
}
@@ -176,7 +165,6 @@ namespace std
resize(size_type __n, _CharT __c)
{
const size_type __size = this->size();
- _M_check_length(__size, __n, "basic_string::resize");
if (__size < __n)
this->append(__n - __size, __c);
else if (__n < __size)
@@ -192,7 +180,6 @@ namespace std
{
const basic_string __s(__k1, __k2);
const size_type __n1 = __i2 - __i1;
- _M_check_length(__n1, __s.size(), "basic_string::_M_replace_dispatch");
return _M_replace(__i1 - _M_ibegin(), __n1, __s._M_data(),
__s.size());
}
@@ -203,7 +190,6 @@ namespace std
_M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
_CharT __c)
{
- _M_check_length(__n1, __n2, "basic_string::_M_replace_aux");
_M_replace(__pos1, __n1, 0, __n2);
if (__n2)
this->_S_assign(this->_M_data() + __pos1, __n2, __c);
@@ -216,6 +202,8 @@ namespace std
_M_replace(size_type __pos, size_type __len1, const _CharT* __s,
const size_type __len2)
{
+ _M_check_length(__len1, __len2, "basic_string::_M_replace");
+
const size_type __old_size = this->size();
const size_type __new_size = __old_size + __len2 - __len1;
const size_type __how_much = __old_size - __pos - __len1;