diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 94a2adb2ada..f51f6f1d005 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2004-10-26 Paolo Carlini + + * include/bits/basic_string.h (append(const basic_string&), + append(size_type, _CharT)): Move out of line... + * include/bits/basic_string.tcc: ... here. + 2004-10-26 Paolo Carlini * include/bits/basic_string.h (erase(size_type, size_type), diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index 34c6fab94a5..6550b9c3362 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -776,19 +776,7 @@ namespace std * @return Reference to this string. */ basic_string& - append(const basic_string& __str) - { - const size_type __size = __str.size(); - if (__size) - { - const size_type __len = __size + this->size(); - if (__len > this->capacity() || _M_rep()->_M_is_shared()) - this->reserve(__len); - _M_copy(_M_data() + this->size(), __str._M_data(), __size); - _M_rep()->_M_set_length_and_sharable(__len); - } - return *this; - } + append(const basic_string& __str); /** * @brief Append a substring. @@ -835,19 +823,7 @@ namespace std * Appends n copies of c to this string. */ basic_string& - append(size_type __n, _CharT __c) - { - if (__n) - { - _M_check_length(size_type(0), __n, "basic_string::append"); - const size_type __len = __n + this->size(); - if (__len > this->capacity() || _M_rep()->_M_is_shared()) - this->reserve(__len); - _M_assign(_M_data() + this->size(), __n, __c); - _M_rep()->_M_set_length_and_sharable(__len); - } - return *this; - } + append(size_type __n, _CharT __c); /** * @brief Append a range of characters. diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc index 9e59e2c6b50..6bd12968202 100644 --- a/libstdc++-v3/include/bits/basic_string.tcc +++ b/libstdc++-v3/include/bits/basic_string.tcc @@ -261,6 +261,23 @@ namespace std } } + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + append(size_type __n, _CharT __c) + { + if (__n) + { + _M_check_length(size_type(0), __n, "basic_string::append"); + const size_type __len = __n + this->size(); + if (__len > this->capacity() || _M_rep()->_M_is_shared()) + this->reserve(__len); + _M_assign(_M_data() + this->size(), __n, __c); + _M_rep()->_M_set_length_and_sharable(__len); + } + return *this; + } + template basic_string<_CharT, _Traits, _Alloc>& basic_string<_CharT, _Traits, _Alloc>:: @@ -288,6 +305,23 @@ namespace std return *this; } + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + append(const basic_string& __str) + { + const size_type __size = __str.size(); + if (__size) + { + const size_type __len = __size + this->size(); + if (__len > this->capacity() || _M_rep()->_M_is_shared()) + this->reserve(__len); + _M_copy(_M_data() + this->size(), __str._M_data(), __size); + _M_rep()->_M_set_length_and_sharable(__len); + } + return *this; + } + template basic_string<_CharT, _Traits, _Alloc>& basic_string<_CharT, _Traits, _Alloc>::