2000-10-05 13:27:02 +02:00
|
|
|
// Components for manipulating sequences of characters -*- C++ -*-
|
|
|
|
|
basic_string.h (basic_string<>::_S_compare): Add.
2007-01-18 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (basic_string<>::_S_compare): Add.
(compare(const basic_string&)): Use it.
* include/bits/basic_string.tcc (compare(size_type, size_type,
const basic_string&), compare(size_type, size_type,
const basic_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
* include/ext/vstring_util.h (__vstring_utility<>::_S_compare): Add.
* include/ext/vstring.h (compare(const __versa_string&)): Use it.
* include/ext/vstring.tcc (compare(size_type, size_type,
const __versa_string&), compare(size_type, size_type,
const __versa_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
From-SVN: r120896
2007-01-18 13:03:35 +01:00
|
|
|
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
2011-01-15 01:27:10 +01:00
|
|
|
// 2006, 2007, 2008, 2009, 2010, 2011
|
2002-01-14 Paolo Carlini <pcarlini@unitus.it>
Nathan Myers <ncm@cantrip.org>
* include/bits/basic_string.h
(replace(__pos, __n1, __s, __n2)): Optimize by avoiding
temporaries (i.e., call _M_replace_safe) when possible.
(replace(__pos, __n, __str)): Call replace(__pos, __n1, __s, __n2).
(replace(__pos, __n1, __s)): Call replace(__pos, __n1, __s , __n2).
(replace(__i1, __i2, __str)): Call replace(__i1, __i2, __s, __n).
(replace(__i1, __i2, __s)): Call replace(__i1, __i2, __s, __n).
(replace(__i1, __i2, __s, __n)): Call replace(__pos1, __n1, __s, __n2).
* include/bits/basic_string.tcc
(replace(__pos1, __n1, __str, __pos2, __n2)): Call
replace(__pos, __n1, __s, __n2).
* testsuite/21_strings/replace.cc (test03): New testcases.
* include/bits/basic_string.h (insert(__pos, __s, __n)):
Adjust comparison wrt overflow.
Co-Authored-By: Nathan Myers <ncm@cantrip.org>
From-SVN: r48834
2002-01-14 20:04:15 +01:00
|
|
|
// Free Software Foundation, Inc.
|
2000-10-05 13:27:02 +02:00
|
|
|
//
|
|
|
|
// This file is part of the GNU ISO C++ Library. This library is free
|
|
|
|
// software; you can redistribute it and/or modify it under the
|
|
|
|
// terms of the GNU General Public License as published by the
|
2009-04-09 17:00:19 +02:00
|
|
|
// Free Software Foundation; either version 3, or (at your option)
|
2000-10-05 13:27:02 +02:00
|
|
|
// any later version.
|
|
|
|
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
2009-04-09 17:00:19 +02:00
|
|
|
// Under Section 7 of GPL version 3, you are granted additional
|
|
|
|
// permissions described in the GCC Runtime Library Exception, version
|
|
|
|
// 3.1, as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License and
|
|
|
|
// a copy of the GCC Runtime Library Exception along with this program;
|
|
|
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
// <http://www.gnu.org/licenses/>.
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2010-12-19 10:21:16 +01:00
|
|
|
/** @file bits/basic_string.tcc
|
2004-11-24 05:11:23 +01:00
|
|
|
* This is an internal header file, included by other library headers.
|
2010-12-19 10:21:16 +01:00
|
|
|
* Do not attempt to use it directly. @headername{string}
|
2004-11-24 05:11:23 +01:00
|
|
|
*/
|
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
//
|
|
|
|
// ISO C++ 14882: 21 Strings library
|
|
|
|
//
|
|
|
|
|
|
|
|
// Written by Jason Merrill based upon the specification by Takanori Adachi
|
|
|
|
// in ANSI X3J16/94-0013R2. Rewritten by Nathan Myers to ISO-14882.
|
|
|
|
|
2003-07-05 06:05:45 +02:00
|
|
|
#ifndef _BASIC_STRING_TCC
|
|
|
|
#define _BASIC_STRING_TCC 1
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2002-02-16 20:33:43 +01:00
|
|
|
#pragma GCC system_header
|
|
|
|
|
2011-01-15 01:27:10 +01:00
|
|
|
#include <bits/cxxabi_forced.h>
|
2007-05-07 23:27:54 +02:00
|
|
|
|
PR libstdc++/36104 part four
2011-01-30 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/36104 part four
* include/bits/c++config (_GLIBCXX_STD): Remove.
(_GLIBCXX_STD_D, _GLIBCXX_PR): Now _GLIBCXX_STD_C.
(_GLIBCXX_P): Now _GLIBCXX_STD_A.
(_GLIBCXX_NAMESPACE_DEBUG, _GLIBCXX_NAMESPACE_PARALLEL,
_GLIBCXX_NAMESPACE_PROFILE, _GLIBCXX_NAMESPACE_VERSION): Remove.
(_GLIBCXX_INLINE_DEBUG, _GLIBCXX_INLINE_PARALLEL,
_GLIBCXX_INLINE_PROFILE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE(X)): Remove.
(_GLIBCXX_END_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NESTED_NAMESPACE(X, Y)): Remove.
(_GLIBCXX_END_NESTED_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE_ALGO): Add.
(_GLIBCXX_END_NAMESPACE_ALGO): Add.
(_GLIBCXX_BEGIN_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_END_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_BEGIN_NAMESPACE_VERSION): Add.
(_GLIBCXX_END_NAMESPACE_VERSION): Add.
(_GLIBCXX_BEGIN_LDBL_NAMESPACE): To _GLIBCXX_BEGIN_NAMESPACE_LDBL.
(_GLIBCXX_END_LDBL_NAMESPACE): To _GLIBCXX_END_NAMESPACE_LDBL.
(_GLIBCXX_VISIBILITY_ATTR): Revert to _GLIBCXX_VISIBILITY.
* include/*: Use new macros for namespace scope.
* config/*: Same.
* src/*: Same.
* src/Makefile.am (sources): Remove debug_list.cc, add
compatibility-debug_list-2.cc.
(parallel_sources): Remove parallel_list.cc, add
compatibility-parallel_list-2.cc.
(compatibility-parallel_list-2.[o,lo]): New rule.
* src/Makefile.in: Regenerate.
* src/debug_list.cc: Remove.
* src/parallel_list.cc: Remove.
* src/compatibility-list-2.cc: New.
* src/compatibility-debug_list-2.cc: New.
* src/compatibility-parallel_list-2.cc: New.
* doc/doxygen/user.cfg.in: Adjust macros.
* testsuite/20_util/auto_ptr/assign_neg.cc: Adjust line numbers, macros.
* testsuite/20_util/declval/requirements/1_neg.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg1.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg2.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg3.cc: Same.
* testsuite/20_util/forward/c_neg.cc: Same.
* testsuite/20_util/forward/f_neg.cc: Same.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Same.
* testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Same.
* testsuite/20_util/shared_ptr/cons/43820_neg.cc: Same.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/forward_list/capacity/1.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
assign_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
insert_neg.cc: Same.
* testsuite/23_containers/list/capacity/29134.cc: Same.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/vector/bool/capacity/29134.cc: Same.
* testsuite/23_containers/vector/bool/modifiers/insert/31370.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc: Same.
* testsuite/25_algorithms/sort/35588.cc: Same.
* testsuite/27_io/ios_base/cons/assign_neg.cc: Same.
* testsuite/27_io/ios_base/cons/copy_neg.cc: Same.
* testsuite/ext/profile/mutex_extensions_neg.cc: Same.
* testsuite/ext/profile/profiler_algos.cc: Same.
* testsuite/ext/type_traits/add_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/add_unsigned_integer_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_integer_neg.cc: Same.
* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc: Same.
From-SVN: r169421
2011-01-30 23:39:36 +01:00
|
|
|
namespace std _GLIBCXX_VISIBILITY(default)
|
|
|
|
{
|
|
|
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
2005-12-19 01:56:05 +01:00
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
2004-02-08 05:46:42 +01:00
|
|
|
const typename basic_string<_CharT, _Traits, _Alloc>::size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
Avoid multi-processor bus contention on increment/decrement-and- test of the reference count in the empty-string object...
2003-06-13 Nathan C. Myers <ncm-nospam@cantrip.org>
Avoid multi-processor bus contention on increment/decrement-and-
test of the reference count in the empty-string object, by comparing
addresses first, and never touching the reference count of the empty-
string object.
* include/bits/basic_string.h:
(_S_empty_rep_storage): Move into basic_string<>::_Rep for use by its
members.
(_Rep::_S_empty_rep()): New accessor.
(_Rep::_M_length, _Rep::_M_capacity, _Rep::_M_references): Move to
a base class _Rep_base.
(_Rep::_M_dispose, _Rep::_M_refcopy): Check for the empty string.
(basic_string()): Change to use _M_refdata() in place of _M_refcopy(),
since no longer must increment its refcount.
* include/bits/basic_string.tcc:
(_Rep::_M_destroy, _M_leak_hard): Check for the empty string and
return immediately. The former might be unnecessary. The latter
prevents begin() and end() from cloning it unnecessarily.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
input_iterator_tag), _S_construct(_InIterator, _InIterator,
const _Alloc&, forward_iterator_tag), _S_construct(size_type, _CharT,
const _Alloc&)): Change to use _M_refdata() in place of _M_refcopy().
(_M_mutate): Check for the empty string and treat it as shared.
This is necessary here because _M_mutate is sometimes called with
all-zero arguments; in all other uses of _M_is_shared, the test comes
out right anyhow.
From-SVN: r67912
2003-06-13 22:59:42 +02:00
|
|
|
_Rep::_S_max_size = (((npos - sizeof(_Rep_base))/sizeof(_CharT)) - 1) / 4;
|
2000-10-05 13:27:02 +02:00
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
2004-02-08 05:46:42 +01:00
|
|
|
const _CharT
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
2002-02-12 05:35:58 +01:00
|
|
|
_Rep::_S_terminal = _CharT();
|
2000-10-05 13:27:02 +02:00
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
2000-11-16 02:03:20 +01:00
|
|
|
const typename basic_string<_CharT, _Traits, _Alloc>::size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>::npos;
|
|
|
|
|
|
|
|
// Linker sets _S_empty_rep_storage to all 0s (one reference, empty string)
|
|
|
|
// at static init time (before static ctors are run).
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
2000-11-16 02:03:20 +01:00
|
|
|
typename basic_string<_CharT, _Traits, _Alloc>::size_type
|
Avoid multi-processor bus contention on increment/decrement-and- test of the reference count in the empty-string object...
2003-06-13 Nathan C. Myers <ncm-nospam@cantrip.org>
Avoid multi-processor bus contention on increment/decrement-and-
test of the reference count in the empty-string object, by comparing
addresses first, and never touching the reference count of the empty-
string object.
* include/bits/basic_string.h:
(_S_empty_rep_storage): Move into basic_string<>::_Rep for use by its
members.
(_Rep::_S_empty_rep()): New accessor.
(_Rep::_M_length, _Rep::_M_capacity, _Rep::_M_references): Move to
a base class _Rep_base.
(_Rep::_M_dispose, _Rep::_M_refcopy): Check for the empty string.
(basic_string()): Change to use _M_refdata() in place of _M_refcopy(),
since no longer must increment its refcount.
* include/bits/basic_string.tcc:
(_Rep::_M_destroy, _M_leak_hard): Check for the empty string and
return immediately. The former might be unnecessary. The latter
prevents begin() and end() from cloning it unnecessarily.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
input_iterator_tag), _S_construct(_InIterator, _InIterator,
const _Alloc&, forward_iterator_tag), _S_construct(size_type, _CharT,
const _Alloc&)): Change to use _M_refdata() in place of _M_refcopy().
(_M_mutate): Check for the empty string and treat it as shared.
This is necessary here because _M_mutate is sometimes called with
all-zero arguments; in all other uses of _M_is_shared, the test comes
out right anyhow.
From-SVN: r67912
2003-06-13 22:59:42 +02:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>::_Rep::_S_empty_rep_storage[
|
|
|
|
(sizeof(_Rep_base) + sizeof(_CharT) + sizeof(size_type) - 1) /
|
|
|
|
sizeof(size_type)];
|
2000-10-05 13:27:02 +02:00
|
|
|
|
|
|
|
// NB: This is the special case for Input Iterators, used in
|
|
|
|
// istreambuf_iterators, etc.
|
|
|
|
// Input Iterators have a cost structure very different from
|
|
|
|
// pointers, calling for a different coding style.
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
BUGS: Update from 2.90.8 snapshot.
2003-06-10 Phil Edwards <pme@gcc.gnu.org>
* docs/html/17_intro/BUGS: Update from 2.90.8 snapshot.
* docs/html/17_intro/CHECKLIST: Bring up to date with respect to
correctness of container::iterator typedefs. Fix whitespace.
* docs/html/20_util/howto.html, docs/html/ext/howto.html: Add links
to allocator docs.
* docs/html/documentation.html: Regenerate.
* include/bits/basic_string.h, include/bits/basic_string.tcc,
include/bits/deque.tcc, include/bits/list.tcc, include/bits/stl_algo.h,
include/bits/stl_algobase.h, include/bits/stl_bvector.h,
include/bits/stl_deque.h, include/bits/stl_iterator_base_funcs.h,
include/bits/stl_list.h, include/bits/stl_uninitialized.h,
include/bits/stl_vector.h, include/bits/vector.tcc,
include/ext/algorithm, include/ext/slist, include/std/std_bitset.h:
Change _Iter names to _Iterator, and __pos to __position.
* include/bits/stl_relops.h, include/bits/stl_numeric.h,
include/bits/stl_multiset.h, include/bits/stl_set.h:
Remove emacs markers.
* include/bits/stl_threads.h (_STL_auto_lock): Add __unused__.
From-SVN: r67736
2003-06-10 23:52:25 +02:00
|
|
|
template<typename _InIterator>
|
2000-10-05 13:27:02 +02:00
|
|
|
_CharT*
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
BUGS: Update from 2.90.8 snapshot.
2003-06-10 Phil Edwards <pme@gcc.gnu.org>
* docs/html/17_intro/BUGS: Update from 2.90.8 snapshot.
* docs/html/17_intro/CHECKLIST: Bring up to date with respect to
correctness of container::iterator typedefs. Fix whitespace.
* docs/html/20_util/howto.html, docs/html/ext/howto.html: Add links
to allocator docs.
* docs/html/documentation.html: Regenerate.
* include/bits/basic_string.h, include/bits/basic_string.tcc,
include/bits/deque.tcc, include/bits/list.tcc, include/bits/stl_algo.h,
include/bits/stl_algobase.h, include/bits/stl_bvector.h,
include/bits/stl_deque.h, include/bits/stl_iterator_base_funcs.h,
include/bits/stl_list.h, include/bits/stl_uninitialized.h,
include/bits/stl_vector.h, include/bits/vector.tcc,
include/ext/algorithm, include/ext/slist, include/std/std_bitset.h:
Change _Iter names to _Iterator, and __pos to __position.
* include/bits/stl_relops.h, include/bits/stl_numeric.h,
include/bits/stl_multiset.h, include/bits/stl_set.h:
Remove emacs markers.
* include/bits/stl_threads.h (_STL_auto_lock): Add __unused__.
From-SVN: r67736
2003-06-10 23:52:25 +02:00
|
|
|
_S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
|
2000-10-05 13:27:02 +02:00
|
|
|
input_iterator_tag)
|
|
|
|
{
|
2011-10-14 08:57:55 +02:00
|
|
|
#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
|
2000-10-05 13:27:02 +02:00
|
|
|
if (__beg == __end && __a == _Alloc())
|
Avoid multi-processor bus contention on increment/decrement-and- test of the reference count in the empty-string object...
2003-06-13 Nathan C. Myers <ncm-nospam@cantrip.org>
Avoid multi-processor bus contention on increment/decrement-and-
test of the reference count in the empty-string object, by comparing
addresses first, and never touching the reference count of the empty-
string object.
* include/bits/basic_string.h:
(_S_empty_rep_storage): Move into basic_string<>::_Rep for use by its
members.
(_Rep::_S_empty_rep()): New accessor.
(_Rep::_M_length, _Rep::_M_capacity, _Rep::_M_references): Move to
a base class _Rep_base.
(_Rep::_M_dispose, _Rep::_M_refcopy): Check for the empty string.
(basic_string()): Change to use _M_refdata() in place of _M_refcopy(),
since no longer must increment its refcount.
* include/bits/basic_string.tcc:
(_Rep::_M_destroy, _M_leak_hard): Check for the empty string and
return immediately. The former might be unnecessary. The latter
prevents begin() and end() from cloning it unnecessarily.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
input_iterator_tag), _S_construct(_InIterator, _InIterator,
const _Alloc&, forward_iterator_tag), _S_construct(size_type, _CharT,
const _Alloc&)): Change to use _M_refdata() in place of _M_refcopy().
(_M_mutate): Check for the empty string and treat it as shared.
This is necessary here because _M_mutate is sometimes called with
all-zero arguments; in all other uses of _M_is_shared, the test comes
out right anyhow.
From-SVN: r67912
2003-06-13 22:59:42 +02:00
|
|
|
return _S_empty_rep()._M_refdata();
|
2004-09-28 10:58:35 +02:00
|
|
|
#endif
|
2000-10-05 13:27:02 +02:00
|
|
|
// Avoid reallocation for common case.
|
2004-04-25 17:45:13 +02:00
|
|
|
_CharT __buf[128];
|
2004-01-30 10:58:45 +01:00
|
|
|
size_type __len = 0;
|
|
|
|
while (__beg != __end && __len < sizeof(__buf) / sizeof(_CharT))
|
2004-02-08 05:46:42 +01:00
|
|
|
{
|
|
|
|
__buf[__len++] = *__beg;
|
2004-01-30 10:58:45 +01:00
|
|
|
++__beg;
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
2004-01-30 10:58:45 +01:00
|
|
|
_Rep* __r = _Rep::_S_create(__len, size_type(0), __a);
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
_M_copy(__r->_M_refdata(), __buf, __len);
|
2009-02-04 00:44:53 +01:00
|
|
|
__try
|
2001-02-16 01:44:44 +01:00
|
|
|
{
|
2004-01-30 10:58:45 +01:00
|
|
|
while (__beg != __end)
|
2001-02-16 01:44:44 +01:00
|
|
|
{
|
2004-01-30 10:58:45 +01:00
|
|
|
if (__len == __r->_M_capacity)
|
2001-02-16 01:44:44 +01:00
|
|
|
{
|
2004-01-30 10:58:45 +01:00
|
|
|
// Allocate more space.
|
|
|
|
_Rep* __another = _Rep::_S_create(__len + 1, __len, __a);
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
_M_copy(__another->_M_refdata(), __r->_M_refdata(), __len);
|
2004-01-30 10:58:45 +01:00
|
|
|
__r->_M_destroy(__a);
|
|
|
|
__r = __another;
|
2001-02-16 01:44:44 +01:00
|
|
|
}
|
2004-02-08 05:46:42 +01:00
|
|
|
__r->_M_refdata()[__len++] = *__beg;
|
2004-01-30 10:58:45 +01:00
|
|
|
++__beg;
|
2001-02-16 01:44:44 +01:00
|
|
|
}
|
|
|
|
}
|
2009-02-04 00:44:53 +01:00
|
|
|
__catch(...)
|
2001-02-16 01:44:44 +01:00
|
|
|
{
|
2004-02-08 05:46:42 +01:00
|
|
|
__r->_M_destroy(__a);
|
2001-02-16 01:44:44 +01:00
|
|
|
__throw_exception_again;
|
|
|
|
}
|
2004-10-22 00:01:41 +02:00
|
|
|
__r->_M_set_length_and_sharable(__len);
|
2004-01-30 10:58:45 +01:00
|
|
|
return __r->_M_refdata();
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
re PR libstdc++/41773 (Many libstdc++ failures)
2009-10-20 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/41773
Revert:
2009-10-20 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/basic_string.h (_S_construct(const _CharT*, size_type,
const _Alloc&)): New, declare.
(_S_construct(_CharT*, _CharT*, const _Alloc&),
_S_construct(const _CharT*, const _CharT*, const _Alloc&),
_S_construct(iterator, iterator, const _Alloc&),
_S_construct(const_iterator, const_iterator, const _Alloc&)): New,
forward to the latter.
* include/bits/basic_string.tcc (_S_construct(const _CharT*,
size_type, const _Alloc&)): Define.
(basic_string(const basic_string&, size_type, size_type),
basic_string(const basic_string&, size_type, size_type,
const _Alloc&), basic_string(const _CharT*, size_type,
const _Alloc&), basic_string(const _CharT*, const _Alloc&),
basic_string(initializer_list<>, const _Alloc&)): Call the latter.
* config/abi/pre/gnu.ver: Remove recently added exports.
* src/string-inst.cc: Remove instantiations.
From-SVN: r153040
2009-10-20 23:54:22 +02:00
|
|
|
template <typename _InIterator>
|
2000-10-05 13:27:02 +02:00
|
|
|
_CharT*
|
2001-10-31 09:27:20 +01:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
re PR libstdc++/41773 (Many libstdc++ failures)
2009-10-20 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/41773
Revert:
2009-10-20 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/basic_string.h (_S_construct(const _CharT*, size_type,
const _Alloc&)): New, declare.
(_S_construct(_CharT*, _CharT*, const _Alloc&),
_S_construct(const _CharT*, const _CharT*, const _Alloc&),
_S_construct(iterator, iterator, const _Alloc&),
_S_construct(const_iterator, const_iterator, const _Alloc&)): New,
forward to the latter.
* include/bits/basic_string.tcc (_S_construct(const _CharT*,
size_type, const _Alloc&)): Define.
(basic_string(const basic_string&, size_type, size_type),
basic_string(const basic_string&, size_type, size_type,
const _Alloc&), basic_string(const _CharT*, size_type,
const _Alloc&), basic_string(const _CharT*, const _Alloc&),
basic_string(initializer_list<>, const _Alloc&)): Call the latter.
* config/abi/pre/gnu.ver: Remove recently added exports.
* src/string-inst.cc: Remove instantiations.
From-SVN: r153040
2009-10-20 23:54:22 +02:00
|
|
|
_S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
|
2000-10-05 13:27:02 +02:00
|
|
|
forward_iterator_tag)
|
|
|
|
{
|
2011-10-14 08:57:55 +02:00
|
|
|
#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
|
2002-10-27 08:35:06 +01:00
|
|
|
if (__beg == __end && __a == _Alloc())
|
Avoid multi-processor bus contention on increment/decrement-and- test of the reference count in the empty-string object...
2003-06-13 Nathan C. Myers <ncm-nospam@cantrip.org>
Avoid multi-processor bus contention on increment/decrement-and-
test of the reference count in the empty-string object, by comparing
addresses first, and never touching the reference count of the empty-
string object.
* include/bits/basic_string.h:
(_S_empty_rep_storage): Move into basic_string<>::_Rep for use by its
members.
(_Rep::_S_empty_rep()): New accessor.
(_Rep::_M_length, _Rep::_M_capacity, _Rep::_M_references): Move to
a base class _Rep_base.
(_Rep::_M_dispose, _Rep::_M_refcopy): Check for the empty string.
(basic_string()): Change to use _M_refdata() in place of _M_refcopy(),
since no longer must increment its refcount.
* include/bits/basic_string.tcc:
(_Rep::_M_destroy, _M_leak_hard): Check for the empty string and
return immediately. The former might be unnecessary. The latter
prevents begin() and end() from cloning it unnecessarily.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
input_iterator_tag), _S_construct(_InIterator, _InIterator,
const _Alloc&, forward_iterator_tag), _S_construct(size_type, _CharT,
const _Alloc&)): Change to use _M_refdata() in place of _M_refcopy().
(_M_mutate): Check for the empty string and treat it as shared.
This is necessary here because _M_mutate is sometimes called with
all-zero arguments; in all other uses of _M_is_shared, the test comes
out right anyhow.
From-SVN: r67912
2003-06-13 22:59:42 +02:00
|
|
|
return _S_empty_rep()._M_refdata();
|
2004-09-28 10:58:35 +02:00
|
|
|
#endif
|
2004-02-08 05:46:42 +01:00
|
|
|
// NB: Not required, but considered best practice.
|
2009-04-24 11:35:19 +02:00
|
|
|
if (__gnu_cxx::__is_null_pointer(__beg) && __beg != __end)
|
2010-06-03 21:15:56 +02:00
|
|
|
__throw_logic_error(__N("basic_string::_S_construct null not valid"));
|
basic_string.tcc (basic_string::append(const basic_string&, size_type, size_type), [...]): Fully qualify min() with std::.
2002-12-02 Paolo Carlini <pcarlini@unitus.it>
* include/bits/basic_string.tcc
(basic_string::append(const basic_string&, size_type,
size_type), basic_string::compare(size_type, size_type,
const basic_string&), basic_string::compare(size_type,
size_type, const basic_string&, size_type, size_type),
basic_string::compare(const _CharT*), basic_string::
compare(size_type, size_type, const _CharT*),
basic_string::compare(size_type, size_type, const _CharT*,
size_type), _S_string_copy(const basic_string&, _CharT*,
typename _Alloc::size_type)): Fully qualify min() with std::.
2002-12-02 Paolo Carlini <pcarlini@unitus.it>
* include/bits/basic_string.tcc
(basic_string::_S_construct(_InIter, _InIter, const _Alloc&,
forward_iterator_tag)): Delay the declaration of __dnew,
fully qualify distance() with std::.
(basic_string::_M_replace_safe): Fully qualify distance()
with std::.
From-SVN: r59726
2002-12-02 19:53:41 +01:00
|
|
|
|
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
2004-01-26 21:23:20 +01:00
|
|
|
const size_type __dnew = static_cast<size_type>(std::distance(__beg,
|
|
|
|
__end));
|
2000-10-05 13:27:02 +02:00
|
|
|
// Check for out_of_range and length_error exceptions.
|
basic_string.h (_S_create(size_t, const _Alloc&): Change signature to take two size_type arguments.
2004-01-28 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_S_create(size_t,
const _Alloc&): Change signature to take two size_type
arguments.
* include/bits/basic_string.tcc (_S_construct(_InIterator,
_InIterator, const _Alloc&, input_iterator_tag)): Update
call, tweak a bit.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
forward_iterator_tag)): Likewise.
(_S_construct(size_type, _CharT, const _Alloc&)): Likewise.
(_M_mutate(size_type, size_type, size_type)): Don't
implement the exponential growth policy, demand it to
_S_create, update call and simplify.
(_M_clone(const _Alloc&, size_type)): Likewise.
(_S_create(size_type, size_type, const _Alloc&)): Implement
the growth policy, simplify otherwise.
* include/bits/basic_string.h (_Rep::operator[]): Tweak
signature to take a size_type, consistently with the other
members.
From-SVN: r76786
2004-01-28 11:37:32 +01:00
|
|
|
_Rep* __r = _Rep::_S_create(__dnew, size_type(0), __a);
|
2009-02-04 00:44:53 +01:00
|
|
|
__try
|
2001-02-16 01:44:44 +01:00
|
|
|
{ _S_copy_chars(__r->_M_refdata(), __beg, __end); }
|
2009-02-04 00:44:53 +01:00
|
|
|
__catch(...)
|
2004-02-08 05:46:42 +01:00
|
|
|
{
|
|
|
|
__r->_M_destroy(__a);
|
2001-02-16 01:44:44 +01:00
|
|
|
__throw_exception_again;
|
|
|
|
}
|
2004-10-22 00:01:41 +02:00
|
|
|
__r->_M_set_length_and_sharable(__dnew);
|
2000-10-05 13:27:02 +02:00
|
|
|
return __r->_M_refdata();
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
_CharT*
|
2001-10-31 09:27:20 +01:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
2000-10-05 13:27:02 +02:00
|
|
|
_S_construct(size_type __n, _CharT __c, const _Alloc& __a)
|
|
|
|
{
|
2011-10-14 08:57:55 +02:00
|
|
|
#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
|
2000-10-05 13:27:02 +02:00
|
|
|
if (__n == 0 && __a == _Alloc())
|
Avoid multi-processor bus contention on increment/decrement-and- test of the reference count in the empty-string object...
2003-06-13 Nathan C. Myers <ncm-nospam@cantrip.org>
Avoid multi-processor bus contention on increment/decrement-and-
test of the reference count in the empty-string object, by comparing
addresses first, and never touching the reference count of the empty-
string object.
* include/bits/basic_string.h:
(_S_empty_rep_storage): Move into basic_string<>::_Rep for use by its
members.
(_Rep::_S_empty_rep()): New accessor.
(_Rep::_M_length, _Rep::_M_capacity, _Rep::_M_references): Move to
a base class _Rep_base.
(_Rep::_M_dispose, _Rep::_M_refcopy): Check for the empty string.
(basic_string()): Change to use _M_refdata() in place of _M_refcopy(),
since no longer must increment its refcount.
* include/bits/basic_string.tcc:
(_Rep::_M_destroy, _M_leak_hard): Check for the empty string and
return immediately. The former might be unnecessary. The latter
prevents begin() and end() from cloning it unnecessarily.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
input_iterator_tag), _S_construct(_InIterator, _InIterator,
const _Alloc&, forward_iterator_tag), _S_construct(size_type, _CharT,
const _Alloc&)): Change to use _M_refdata() in place of _M_refcopy().
(_M_mutate): Check for the empty string and treat it as shared.
This is necessary here because _M_mutate is sometimes called with
all-zero arguments; in all other uses of _M_is_shared, the test comes
out right anyhow.
From-SVN: r67912
2003-06-13 22:59:42 +02:00
|
|
|
return _S_empty_rep()._M_refdata();
|
2004-09-28 10:58:35 +02:00
|
|
|
#endif
|
2000-10-05 13:27:02 +02:00
|
|
|
// Check for out_of_range and length_error exceptions.
|
basic_string.h (_S_create(size_t, const _Alloc&): Change signature to take two size_type arguments.
2004-01-28 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_S_create(size_t,
const _Alloc&): Change signature to take two size_type
arguments.
* include/bits/basic_string.tcc (_S_construct(_InIterator,
_InIterator, const _Alloc&, input_iterator_tag)): Update
call, tweak a bit.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
forward_iterator_tag)): Likewise.
(_S_construct(size_type, _CharT, const _Alloc&)): Likewise.
(_M_mutate(size_type, size_type, size_type)): Don't
implement the exponential growth policy, demand it to
_S_create, update call and simplify.
(_M_clone(const _Alloc&, size_type)): Likewise.
(_S_create(size_type, size_type, const _Alloc&)): Implement
the growth policy, simplify otherwise.
* include/bits/basic_string.h (_Rep::operator[]): Tweak
signature to take a size_type, consistently with the other
members.
From-SVN: r76786
2004-01-28 11:37:32 +01:00
|
|
|
_Rep* __r = _Rep::_S_create(__n, size_type(0), __a);
|
2004-02-08 05:46:42 +01:00
|
|
|
if (__n)
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
_M_assign(__r->_M_refdata(), __n, __c);
|
2004-01-19 09:53:32 +01:00
|
|
|
|
2004-10-22 00:01:41 +02:00
|
|
|
__r->_M_set_length_and_sharable(__n);
|
2000-10-05 13:27:02 +02:00
|
|
|
return __r->_M_refdata();
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
basic_string(const basic_string& __str)
|
2004-03-28 18:27:27 +02:00
|
|
|
: _M_dataplus(__str._M_rep()->_M_grab(_Alloc(__str.get_allocator()),
|
|
|
|
__str.get_allocator()),
|
|
|
|
__str.get_allocator())
|
2000-10-05 13:27:02 +02:00
|
|
|
{ }
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
basic_string(const _Alloc& __a)
|
|
|
|
: _M_dataplus(_S_construct(size_type(), _CharT(), __a), __a)
|
|
|
|
{ }
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
basic_string(const basic_string& __str, size_type __pos, size_type __n)
|
2004-01-27 11:46:36 +01:00
|
|
|
: _M_dataplus(_S_construct(__str._M_data()
|
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
2004-01-26 21:23:20 +01:00
|
|
|
+ __str._M_check(__pos,
|
|
|
|
"basic_string::basic_string"),
|
re PR libstdc++/41773 (Many libstdc++ failures)
2009-10-20 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/41773
Revert:
2009-10-20 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/basic_string.h (_S_construct(const _CharT*, size_type,
const _Alloc&)): New, declare.
(_S_construct(_CharT*, _CharT*, const _Alloc&),
_S_construct(const _CharT*, const _CharT*, const _Alloc&),
_S_construct(iterator, iterator, const _Alloc&),
_S_construct(const_iterator, const_iterator, const _Alloc&)): New,
forward to the latter.
* include/bits/basic_string.tcc (_S_construct(const _CharT*,
size_type, const _Alloc&)): Define.
(basic_string(const basic_string&, size_type, size_type),
basic_string(const basic_string&, size_type, size_type,
const _Alloc&), basic_string(const _CharT*, size_type,
const _Alloc&), basic_string(const _CharT*, const _Alloc&),
basic_string(initializer_list<>, const _Alloc&)): Call the latter.
* config/abi/pre/gnu.ver: Remove recently added exports.
* src/string-inst.cc: Remove instantiations.
From-SVN: r153040
2009-10-20 23:54:22 +02:00
|
|
|
__str._M_data() + __str._M_limit(__pos, __n)
|
|
|
|
+ __pos, _Alloc()), _Alloc())
|
2000-10-05 13:27:02 +02:00
|
|
|
{ }
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
basic_string(const basic_string& __str, size_type __pos,
|
|
|
|
size_type __n, const _Alloc& __a)
|
2004-01-27 11:46:36 +01:00
|
|
|
: _M_dataplus(_S_construct(__str._M_data()
|
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
2004-01-26 21:23:20 +01:00
|
|
|
+ __str._M_check(__pos,
|
|
|
|
"basic_string::basic_string"),
|
re PR libstdc++/41773 (Many libstdc++ failures)
2009-10-20 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/41773
Revert:
2009-10-20 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/basic_string.h (_S_construct(const _CharT*, size_type,
const _Alloc&)): New, declare.
(_S_construct(_CharT*, _CharT*, const _Alloc&),
_S_construct(const _CharT*, const _CharT*, const _Alloc&),
_S_construct(iterator, iterator, const _Alloc&),
_S_construct(const_iterator, const_iterator, const _Alloc&)): New,
forward to the latter.
* include/bits/basic_string.tcc (_S_construct(const _CharT*,
size_type, const _Alloc&)): Define.
(basic_string(const basic_string&, size_type, size_type),
basic_string(const basic_string&, size_type, size_type,
const _Alloc&), basic_string(const _CharT*, size_type,
const _Alloc&), basic_string(const _CharT*, const _Alloc&),
basic_string(initializer_list<>, const _Alloc&)): Call the latter.
* config/abi/pre/gnu.ver: Remove recently added exports.
* src/string-inst.cc: Remove instantiations.
From-SVN: r153040
2009-10-20 23:54:22 +02:00
|
|
|
__str._M_data() + __str._M_limit(__pos, __n)
|
|
|
|
+ __pos, __a), __a)
|
2000-10-05 13:27:02 +02:00
|
|
|
{ }
|
|
|
|
|
2003-11-11 21:09:16 +01:00
|
|
|
// TBD: DPG annotate
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
basic_string(const _CharT* __s, size_type __n, const _Alloc& __a)
|
re PR libstdc++/41773 (Many libstdc++ failures)
2009-10-20 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/41773
Revert:
2009-10-20 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/basic_string.h (_S_construct(const _CharT*, size_type,
const _Alloc&)): New, declare.
(_S_construct(_CharT*, _CharT*, const _Alloc&),
_S_construct(const _CharT*, const _CharT*, const _Alloc&),
_S_construct(iterator, iterator, const _Alloc&),
_S_construct(const_iterator, const_iterator, const _Alloc&)): New,
forward to the latter.
* include/bits/basic_string.tcc (_S_construct(const _CharT*,
size_type, const _Alloc&)): Define.
(basic_string(const basic_string&, size_type, size_type),
basic_string(const basic_string&, size_type, size_type,
const _Alloc&), basic_string(const _CharT*, size_type,
const _Alloc&), basic_string(const _CharT*, const _Alloc&),
basic_string(initializer_list<>, const _Alloc&)): Call the latter.
* config/abi/pre/gnu.ver: Remove recently added exports.
* src/string-inst.cc: Remove instantiations.
From-SVN: r153040
2009-10-20 23:54:22 +02:00
|
|
|
: _M_dataplus(_S_construct(__s, __s + __n, __a), __a)
|
2000-10-05 13:27:02 +02:00
|
|
|
{ }
|
|
|
|
|
2003-11-11 21:09:16 +01:00
|
|
|
// TBD: DPG annotate
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
basic_string(const _CharT* __s, const _Alloc& __a)
|
re PR libstdc++/41773 (Many libstdc++ failures)
2009-10-20 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/41773
Revert:
2009-10-20 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/basic_string.h (_S_construct(const _CharT*, size_type,
const _Alloc&)): New, declare.
(_S_construct(_CharT*, _CharT*, const _Alloc&),
_S_construct(const _CharT*, const _CharT*, const _Alloc&),
_S_construct(iterator, iterator, const _Alloc&),
_S_construct(const_iterator, const_iterator, const _Alloc&)): New,
forward to the latter.
* include/bits/basic_string.tcc (_S_construct(const _CharT*,
size_type, const _Alloc&)): Define.
(basic_string(const basic_string&, size_type, size_type),
basic_string(const basic_string&, size_type, size_type,
const _Alloc&), basic_string(const _CharT*, size_type,
const _Alloc&), basic_string(const _CharT*, const _Alloc&),
basic_string(initializer_list<>, const _Alloc&)): Call the latter.
* config/abi/pre/gnu.ver: Remove recently added exports.
* src/string-inst.cc: Remove instantiations.
From-SVN: r153040
2009-10-20 23:54:22 +02:00
|
|
|
: _M_dataplus(_S_construct(__s, __s ? __s + traits_type::length(__s) :
|
|
|
|
__s + npos, __a), __a)
|
2000-10-05 13:27:02 +02:00
|
|
|
{ }
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
basic_string(size_type __n, _CharT __c, const _Alloc& __a)
|
|
|
|
: _M_dataplus(_S_construct(__n, __c, __a), __a)
|
|
|
|
{ }
|
2003-11-11 21:09:16 +01:00
|
|
|
|
2004-02-08 05:46:42 +01:00
|
|
|
// TBD: DPG annotate
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
BUGS: Update from 2.90.8 snapshot.
2003-06-10 Phil Edwards <pme@gcc.gnu.org>
* docs/html/17_intro/BUGS: Update from 2.90.8 snapshot.
* docs/html/17_intro/CHECKLIST: Bring up to date with respect to
correctness of container::iterator typedefs. Fix whitespace.
* docs/html/20_util/howto.html, docs/html/ext/howto.html: Add links
to allocator docs.
* docs/html/documentation.html: Regenerate.
* include/bits/basic_string.h, include/bits/basic_string.tcc,
include/bits/deque.tcc, include/bits/list.tcc, include/bits/stl_algo.h,
include/bits/stl_algobase.h, include/bits/stl_bvector.h,
include/bits/stl_deque.h, include/bits/stl_iterator_base_funcs.h,
include/bits/stl_list.h, include/bits/stl_uninitialized.h,
include/bits/stl_vector.h, include/bits/vector.tcc,
include/ext/algorithm, include/ext/slist, include/std/std_bitset.h:
Change _Iter names to _Iterator, and __pos to __position.
* include/bits/stl_relops.h, include/bits/stl_numeric.h,
include/bits/stl_multiset.h, include/bits/stl_set.h:
Remove emacs markers.
* include/bits/stl_threads.h (_STL_auto_lock): Add __unused__.
From-SVN: r67736
2003-06-10 23:52:25 +02:00
|
|
|
template<typename _InputIterator>
|
re PR libstdc++/41773 (Many libstdc++ failures)
2009-10-20 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/41773
Revert:
2009-10-20 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/basic_string.h (_S_construct(const _CharT*, size_type,
const _Alloc&)): New, declare.
(_S_construct(_CharT*, _CharT*, const _Alloc&),
_S_construct(const _CharT*, const _CharT*, const _Alloc&),
_S_construct(iterator, iterator, const _Alloc&),
_S_construct(const_iterator, const_iterator, const _Alloc&)): New,
forward to the latter.
* include/bits/basic_string.tcc (_S_construct(const _CharT*,
size_type, const _Alloc&)): Define.
(basic_string(const basic_string&, size_type, size_type),
basic_string(const basic_string&, size_type, size_type,
const _Alloc&), basic_string(const _CharT*, size_type,
const _Alloc&), basic_string(const _CharT*, const _Alloc&),
basic_string(initializer_list<>, const _Alloc&)): Call the latter.
* config/abi/pre/gnu.ver: Remove recently added exports.
* src/string-inst.cc: Remove instantiations.
From-SVN: r153040
2009-10-20 23:54:22 +02:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
basic_string(_InputIterator __beg, _InputIterator __end, const _Alloc& __a)
|
|
|
|
: _M_dataplus(_S_construct(__beg, __end, __a), __a)
|
|
|
|
{ }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2008-07-21 21:40:39 +02:00
|
|
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
basic_string(initializer_list<_CharT> __l, const _Alloc& __a)
|
re PR libstdc++/41773 (Many libstdc++ failures)
2009-10-20 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/41773
Revert:
2009-10-20 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/basic_string.h (_S_construct(const _CharT*, size_type,
const _Alloc&)): New, declare.
(_S_construct(_CharT*, _CharT*, const _Alloc&),
_S_construct(const _CharT*, const _CharT*, const _Alloc&),
_S_construct(iterator, iterator, const _Alloc&),
_S_construct(const_iterator, const_iterator, const _Alloc&)): New,
forward to the latter.
* include/bits/basic_string.tcc (_S_construct(const _CharT*,
size_type, const _Alloc&)): Define.
(basic_string(const basic_string&, size_type, size_type),
basic_string(const basic_string&, size_type, size_type,
const _Alloc&), basic_string(const _CharT*, size_type,
const _Alloc&), basic_string(const _CharT*, const _Alloc&),
basic_string(initializer_list<>, const _Alloc&)): Call the latter.
* config/abi/pre/gnu.ver: Remove recently added exports.
* src/string-inst.cc: Remove instantiations.
From-SVN: r153040
2009-10-20 23:54:22 +02:00
|
|
|
: _M_dataplus(_S_construct(__l.begin(), __l.end(), __a), __a)
|
2008-07-21 21:40:39 +02:00
|
|
|
{ }
|
|
|
|
#endif
|
|
|
|
|
2004-10-28 03:04:35 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>&
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
assign(const basic_string& __str)
|
|
|
|
{
|
|
|
|
if (_M_rep() != __str._M_rep())
|
|
|
|
{
|
|
|
|
// XXX MT
|
|
|
|
const allocator_type __a = this->get_allocator();
|
|
|
|
_CharT* __tmp = __str._M_rep()->_M_grab(__a, __str.get_allocator());
|
|
|
|
_M_rep()->_M_dispose(__a);
|
|
|
|
_M_data(__tmp);
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>&
|
Avoid multi-processor bus contention on increment/decrement-and- test of the reference count in the empty-string object...
2003-06-13 Nathan C. Myers <ncm-nospam@cantrip.org>
Avoid multi-processor bus contention on increment/decrement-and-
test of the reference count in the empty-string object, by comparing
addresses first, and never touching the reference count of the empty-
string object.
* include/bits/basic_string.h:
(_S_empty_rep_storage): Move into basic_string<>::_Rep for use by its
members.
(_Rep::_S_empty_rep()): New accessor.
(_Rep::_M_length, _Rep::_M_capacity, _Rep::_M_references): Move to
a base class _Rep_base.
(_Rep::_M_dispose, _Rep::_M_refcopy): Check for the empty string.
(basic_string()): Change to use _M_refdata() in place of _M_refcopy(),
since no longer must increment its refcount.
* include/bits/basic_string.tcc:
(_Rep::_M_destroy, _M_leak_hard): Check for the empty string and
return immediately. The former might be unnecessary. The latter
prevents begin() and end() from cloning it unnecessarily.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
input_iterator_tag), _S_construct(_InIterator, _InIterator,
const _Alloc&, forward_iterator_tag), _S_construct(size_type, _CharT,
const _Alloc&)): Change to use _M_refdata() in place of _M_refcopy().
(_M_mutate): Check for the empty string and treat it as shared.
This is necessary here because _M_mutate is sometimes called with
all-zero arguments; in all other uses of _M_is_shared, the test comes
out right anyhow.
From-SVN: r67912
2003-06-13 22:59:42 +02:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
assign(const _CharT* __s, size_type __n)
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
__glibcxx_requires_string_len(__s, __n);
|
|
|
|
_M_check_length(this->size(), __n, "basic_string::assign");
|
2004-10-25 17:16:49 +02:00
|
|
|
if (_M_disjunct(__s) || _M_rep()->_M_is_shared())
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
return _M_replace_safe(size_type(0), this->size(), __s, __n);
|
|
|
|
else
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
// Work in-place.
|
|
|
|
const size_type __pos = __s - _M_data();
|
|
|
|
if (__pos >= __n)
|
2004-10-25 12:43:59 +02:00
|
|
|
_M_copy(_M_data(), __s, __n);
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
else if (__pos)
|
2004-10-25 12:43:59 +02:00
|
|
|
_M_move(_M_data(), __s, __n);
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
_M_rep()->_M_set_length_and_sharable(__n);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-27 03:02:47 +02:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
_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;
|
|
|
|
}
|
|
|
|
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>&
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
append(const _CharT* __s, size_type __n)
|
|
|
|
{
|
|
|
|
__glibcxx_requires_string_len(__s, __n);
|
|
|
|
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())
|
|
|
|
{
|
2004-10-25 17:16:49 +02:00
|
|
|
if (_M_disjunct(__s))
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
this->reserve(__len);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const size_type __off = __s - _M_data();
|
|
|
|
this->reserve(__len);
|
|
|
|
__s = _M_data() + __off;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_M_copy(_M_data() + this->size(), __s, __n);
|
|
|
|
_M_rep()->_M_set_length_and_sharable(__len);
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
Move some basic_string members out of line because they are too big to reasonably be inline.
2003-04-27 Nathan Myers <ncm@cantrip.org>
Move some basic_string members out of line because
they are too big to reasonably be inline.
* include/bits/basic_string.h
(assign(const basic_string&, size_type, size_type),
assign(const _CharT*, size_type),
insert(size_type, const basic_string&, size_type, size_type),
insert(size_type, const _CharT*, size_type),
replace(size_type, size_type, const _CharT*, size_type)):
Move from here to...
* include/bits/basic_string.tcc: ...here.
From-SVN: r66132
2003-04-27 19:20:42 +02:00
|
|
|
|
2004-10-27 03:02:47 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>&
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
append(const basic_string& __str, size_type __pos, size_type __n)
|
|
|
|
{
|
|
|
|
__str._M_check(__pos, "basic_string::append");
|
|
|
|
__n = __str._M_limit(__pos, __n);
|
|
|
|
if (__n)
|
|
|
|
{
|
|
|
|
const size_type __len = __n + this->size();
|
|
|
|
if (__len > this->capacity() || _M_rep()->_M_is_shared())
|
|
|
|
this->reserve(__len);
|
|
|
|
_M_copy(_M_data() + this->size(), __str._M_data() + __pos, __n);
|
|
|
|
_M_rep()->_M_set_length_and_sharable(__len);
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
Move some basic_string members out of line because they are too big to reasonably be inline.
2003-04-27 Nathan Myers <ncm@cantrip.org>
Move some basic_string members out of line because
they are too big to reasonably be inline.
* include/bits/basic_string.h
(assign(const basic_string&, size_type, size_type),
assign(const _CharT*, size_type),
insert(size_type, const basic_string&, size_type, size_type),
insert(size_type, const _CharT*, size_type),
replace(size_type, size_type, const _CharT*, size_type)):
Move from here to...
* include/bits/basic_string.tcc: ...here.
From-SVN: r66132
2003-04-27 19:20:42 +02:00
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>&
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
insert(size_type __pos, const _CharT* __s, size_type __n)
|
|
|
|
{
|
2003-11-11 21:09:16 +01:00
|
|
|
__glibcxx_requires_string_len(__s, __n);
|
basic_string.tcc (rfind(_CharT, size_type)): Revert last change to use std::min: machine language is worse.
2004-01-24 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.tcc (rfind(_CharT, size_type)):
Revert last change to use std::min: machine language is worse.
(find_last_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(_CharT, size_type)): Ditto.
* include/bits/basic_string.tcc (insert(size_type, const _CharT*,
size_type)): Discard the value returned by _M_check.
(replace(size_type, size_type, const _CharT*, size_type)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76514
2004-01-24 17:52:04 +01:00
|
|
|
_M_check(__pos, "basic_string::insert");
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
_M_check_length(size_type(0), __n, "basic_string::insert");
|
2004-10-25 17:16:49 +02:00
|
|
|
if (_M_disjunct(__s) || _M_rep()->_M_is_shared())
|
basic_string.h (_M_replace_safe): Change signatures to take size_types and const _CharT*.
2004-01-22 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_M_replace_safe): Change
signatures to take size_types and const _CharT*.
(_M_replace_aux): Likewise, takes size_types instead of
iterators.
(append(size_type, _CharT)): Update call.
(assign(size_type, _CharT)): Ditto.
(replace(iterator, iterator, size_type, _CharT)): Ditto.
(_M_replace_dispatch(iterator, iterator, _Integer,
_Integer, __true_type)): Ditto.
* include/bits/basic_string.tcc (assign(const _CharT*,
size_type)): Ditto.
(insert(size_type, const _CharT*, size_type)): Ditto.
(replace(size_type, size_type, const _CharT*,
size_type)): Ditto.
(_M_replace(iterator, iterator, _InputIterator,
_InputIterator)): Ditto.
(append(const basic_string&)): Ditto.
(append(const basic_string&, size_type, size_type): Ditto.
(append(const _CharT*, size_type): Ditto.
(_M_replace_safe, _M_replace_safe): Change definitions
accordingly, simplify.
* string-inst.cc (_M_replace_safe): Don't instantiate.
From-SVN: r76353
2004-01-22 13:46:28 +01:00
|
|
|
return _M_replace_safe(__pos, size_type(0), __s, __n);
|
Move some basic_string members out of line because they are too big to reasonably be inline.
2003-04-27 Nathan Myers <ncm@cantrip.org>
Move some basic_string members out of line because
they are too big to reasonably be inline.
* include/bits/basic_string.h
(assign(const basic_string&, size_type, size_type),
assign(const _CharT*, size_type),
insert(size_type, const basic_string&, size_type, size_type),
insert(size_type, const _CharT*, size_type),
replace(size_type, size_type, const _CharT*, size_type)):
Move from here to...
* include/bits/basic_string.tcc: ...here.
From-SVN: r66132
2003-04-27 19:20:42 +02:00
|
|
|
else
|
|
|
|
{
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
// Work in-place.
|
Move some basic_string members out of line because they are too big to reasonably be inline.
2003-04-27 Nathan Myers <ncm@cantrip.org>
Move some basic_string members out of line because
they are too big to reasonably be inline.
* include/bits/basic_string.h
(assign(const basic_string&, size_type, size_type),
assign(const _CharT*, size_type),
insert(size_type, const basic_string&, size_type, size_type),
insert(size_type, const _CharT*, size_type),
replace(size_type, size_type, const _CharT*, size_type)):
Move from here to...
* include/bits/basic_string.tcc: ...here.
From-SVN: r66132
2003-04-27 19:20:42 +02:00
|
|
|
const size_type __off = __s - _M_data();
|
|
|
|
_M_mutate(__pos, 0, __n);
|
|
|
|
__s = _M_data() + __off;
|
|
|
|
_CharT* __p = _M_data() + __pos;
|
|
|
|
if (__s + __n <= __p)
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
_M_copy(__p, __s, __n);
|
Move some basic_string members out of line because they are too big to reasonably be inline.
2003-04-27 Nathan Myers <ncm@cantrip.org>
Move some basic_string members out of line because
they are too big to reasonably be inline.
* include/bits/basic_string.h
(assign(const basic_string&, size_type, size_type),
assign(const _CharT*, size_type),
insert(size_type, const basic_string&, size_type, size_type),
insert(size_type, const _CharT*, size_type),
replace(size_type, size_type, const _CharT*, size_type)):
Move from here to...
* include/bits/basic_string.tcc: ...here.
From-SVN: r66132
2003-04-27 19:20:42 +02:00
|
|
|
else if (__s >= __p)
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
_M_copy(__p, __s + __n, __n);
|
Move some basic_string members out of line because they are too big to reasonably be inline.
2003-04-27 Nathan Myers <ncm@cantrip.org>
Move some basic_string members out of line because
they are too big to reasonably be inline.
* include/bits/basic_string.h
(assign(const basic_string&, size_type, size_type),
assign(const _CharT*, size_type),
insert(size_type, const basic_string&, size_type, size_type),
insert(size_type, const _CharT*, size_type),
replace(size_type, size_type, const _CharT*, size_type)):
Move from here to...
* include/bits/basic_string.tcc: ...here.
From-SVN: r66132
2003-04-27 19:20:42 +02:00
|
|
|
else
|
|
|
|
{
|
2004-01-26 10:07:18 +01:00
|
|
|
const size_type __nleft = __p - __s;
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
_M_copy(__p, __s, __nleft);
|
|
|
|
_M_copy(__p + __nleft, __p + __n, __n - __nleft);
|
Move some basic_string members out of line because they are too big to reasonably be inline.
2003-04-27 Nathan Myers <ncm@cantrip.org>
Move some basic_string members out of line because
they are too big to reasonably be inline.
* include/bits/basic_string.h
(assign(const basic_string&, size_type, size_type),
assign(const _CharT*, size_type),
insert(size_type, const basic_string&, size_type, size_type),
insert(size_type, const _CharT*, size_type),
replace(size_type, size_type, const _CharT*, size_type)):
Move from here to...
* include/bits/basic_string.tcc: ...here.
From-SVN: r66132
2003-04-27 19:20:42 +02:00
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
}
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2009-06-23 14:36:43 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
typename basic_string<_CharT, _Traits, _Alloc>::iterator
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
erase(iterator __first, iterator __last)
|
|
|
|
{
|
|
|
|
_GLIBCXX_DEBUG_PEDASSERT(__first >= _M_ibegin() && __first <= __last
|
|
|
|
&& __last <= _M_iend());
|
|
|
|
|
|
|
|
// NB: This isn't just an optimization (bail out early when
|
|
|
|
// there is nothing to do, really), it's also a correctness
|
|
|
|
// issue vs MT, see libstdc++/40518.
|
|
|
|
const size_type __size = __last - __first;
|
|
|
|
if (__size)
|
|
|
|
{
|
|
|
|
const size_type __pos = __first - _M_ibegin();
|
|
|
|
_M_mutate(__pos, __size, size_type(0));
|
|
|
|
_M_rep()->_M_set_leaked();
|
|
|
|
return iterator(_M_data() + __pos);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return __first;
|
|
|
|
}
|
|
|
|
|
Move some basic_string members out of line because they are too big to reasonably be inline.
2003-04-27 Nathan Myers <ncm@cantrip.org>
Move some basic_string members out of line because
they are too big to reasonably be inline.
* include/bits/basic_string.h
(assign(const basic_string&, size_type, size_type),
assign(const _CharT*, size_type),
insert(size_type, const basic_string&, size_type, size_type),
insert(size_type, const _CharT*, size_type),
replace(size_type, size_type, const _CharT*, size_type)):
Move from here to...
* include/bits/basic_string.tcc: ...here.
From-SVN: r66132
2003-04-27 19:20:42 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>&
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
replace(size_type __pos, size_type __n1, const _CharT* __s,
|
|
|
|
size_type __n2)
|
|
|
|
{
|
2003-11-11 21:09:16 +01:00
|
|
|
__glibcxx_requires_string_len(__s, __n2);
|
basic_string.tcc (rfind(_CharT, size_type)): Revert last change to use std::min: machine language is worse.
2004-01-24 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.tcc (rfind(_CharT, size_type)):
Revert last change to use std::min: machine language is worse.
(find_last_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(_CharT, size_type)): Ditto.
* include/bits/basic_string.tcc (insert(size_type, const _CharT*,
size_type)): Discard the value returned by _M_check.
(replace(size_type, size_type, const _CharT*, size_type)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76514
2004-01-24 17:52:04 +01:00
|
|
|
_M_check(__pos, "basic_string::replace");
|
basic_string.h (_M_check): Change to return a checked __pos and take an additional const char* argument.
2004-01-21 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_M_check): Change to return
a checked __pos and take an additional const char* argument.
(_M_fold): Rename to _M_limit, change to return a size_type,
corresponding to the __off limited to the actual length.
(insert(size_type, size_type, _CharT)): Update call, call
replace.
(insert(iterator, _CharT)): Call replace(iterator, iterator,
size_type, _CharT) instead.
(erase(size_type, size_type)): Update calls.
(replace(size_type, size_type, size_type, _CharT)): Ditto.
(substr(size_type, size_type)): Use _M_check.
* include/bits/basic_string.tcc (basic_string(const basic_string&,
size_type, size_type)): Update calls.
(basic_string(const basic_string&, size_type, size_type,
const _Alloc&)): Ditto.
(assign(const basic_string&, size_type, size_type)): Use the
new _M_check and _M_limit.
(insert(size_type, const basic_string&, size_type, size_type):
Ditto.
(insert(size_type, const _CharT*, size_type)): Ditto.
(replace(size_type, size_type, const _CharT*, size_type): Ditto.
(replace(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(append(const basic_string&)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,size_type,
size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76274
2004-01-21 12:29:51 +01:00
|
|
|
__n1 = _M_limit(__pos, __n1);
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
_M_check_length(__n1, __n2, "basic_string::replace");
|
2004-01-26 10:07:18 +01:00
|
|
|
bool __left;
|
2004-10-25 17:16:49 +02:00
|
|
|
if (_M_disjunct(__s) || _M_rep()->_M_is_shared())
|
basic_string.h (_M_replace_safe): Change signatures to take size_types and const _CharT*.
2004-01-22 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_M_replace_safe): Change
signatures to take size_types and const _CharT*.
(_M_replace_aux): Likewise, takes size_types instead of
iterators.
(append(size_type, _CharT)): Update call.
(assign(size_type, _CharT)): Ditto.
(replace(iterator, iterator, size_type, _CharT)): Ditto.
(_M_replace_dispatch(iterator, iterator, _Integer,
_Integer, __true_type)): Ditto.
* include/bits/basic_string.tcc (assign(const _CharT*,
size_type)): Ditto.
(insert(size_type, const _CharT*, size_type)): Ditto.
(replace(size_type, size_type, const _CharT*,
size_type)): Ditto.
(_M_replace(iterator, iterator, _InputIterator,
_InputIterator)): Ditto.
(append(const basic_string&)): Ditto.
(append(const basic_string&, size_type, size_type): Ditto.
(append(const _CharT*, size_type): Ditto.
(_M_replace_safe, _M_replace_safe): Change definitions
accordingly, simplify.
* string-inst.cc (_M_replace_safe): Don't instantiate.
From-SVN: r76353
2004-01-22 13:46:28 +01:00
|
|
|
return _M_replace_safe(__pos, __n1, __s, __n2);
|
2004-01-26 10:07:18 +01:00
|
|
|
else if ((__left = __s + __n2 <= _M_data() + __pos)
|
|
|
|
|| _M_data() + __pos + __n1 <= __s)
|
|
|
|
{
|
|
|
|
// Work in-place: non-overlapping case.
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
size_type __off = __s - _M_data();
|
|
|
|
__left ? __off : (__off += __n2 - __n1);
|
2004-01-26 10:07:18 +01:00
|
|
|
_M_mutate(__pos, __n1, __n2);
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
_M_copy(_M_data() + __pos, _M_data() + __off, __n2);
|
2004-01-26 10:07:18 +01:00
|
|
|
return *this;
|
|
|
|
}
|
Move some basic_string members out of line because they are too big to reasonably be inline.
2003-04-27 Nathan Myers <ncm@cantrip.org>
Move some basic_string members out of line because
they are too big to reasonably be inline.
* include/bits/basic_string.h
(assign(const basic_string&, size_type, size_type),
assign(const _CharT*, size_type),
insert(size_type, const basic_string&, size_type, size_type),
insert(size_type, const _CharT*, size_type),
replace(size_type, size_type, const _CharT*, size_type)):
Move from here to...
* include/bits/basic_string.tcc: ...here.
From-SVN: r66132
2003-04-27 19:20:42 +02:00
|
|
|
else
|
basic_string.tcc (insert(size_type, const _CharT*, size_type __n)): Fix length_error check.
2004-01-23 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.tcc (insert(size_type,
const _CharT*, size_type __n)): Fix length_error check.
(replace(size_type, size_type, const _CharT*, size_type):
Ditto; call _M_replace_safe.
(_M_replace_aux(size_type, size_type, size_type, _CharT):
Fix length_error check.
(_M_replace(iterator, iterator, _InputIterator,
_InputIterator)): Ditto, tweak.
(_M_replace_safe(size_type, size_type, const _CharT*,
size_type)): Remove length_error check.
* include/bits/basic_string.tcc (append(const basic_string&),
append(const basic_string&, size_type, size_type)): Tweak
comment.
* include/bits/basic_string.tcc (copy(_CharT*, size_type,
size_type)): If __n == 0 don't call traits::copy.
From-SVN: r76476
2004-01-24 01:27:19 +01:00
|
|
|
{
|
2004-01-26 10:07:18 +01:00
|
|
|
// Todo: overlapping case.
|
basic_string.tcc (insert(size_type, const _CharT*, size_type __n)): Fix length_error check.
2004-01-23 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.tcc (insert(size_type,
const _CharT*, size_type __n)): Fix length_error check.
(replace(size_type, size_type, const _CharT*, size_type):
Ditto; call _M_replace_safe.
(_M_replace_aux(size_type, size_type, size_type, _CharT):
Fix length_error check.
(_M_replace(iterator, iterator, _InputIterator,
_InputIterator)): Ditto, tweak.
(_M_replace_safe(size_type, size_type, const _CharT*,
size_type)): Remove length_error check.
* include/bits/basic_string.tcc (append(const basic_string&),
append(const basic_string&, size_type, size_type)): Tweak
comment.
* include/bits/basic_string.tcc (copy(_CharT*, size_type,
size_type)): If __n == 0 don't call traits::copy.
From-SVN: r76476
2004-01-24 01:27:19 +01:00
|
|
|
const basic_string __tmp(__s, __n2);
|
|
|
|
return _M_replace_safe(__pos, __n1, __tmp._M_data(), __n2);
|
|
|
|
}
|
Move some basic_string members out of line because they are too big to reasonably be inline.
2003-04-27 Nathan Myers <ncm@cantrip.org>
Move some basic_string members out of line because
they are too big to reasonably be inline.
* include/bits/basic_string.h
(assign(const basic_string&, size_type, size_type),
assign(const _CharT*, size_type),
insert(size_type, const basic_string&, size_type, size_type),
insert(size_type, const _CharT*, size_type),
replace(size_type, size_type, const _CharT*, size_type)):
Move from here to...
* include/bits/basic_string.tcc: ...here.
From-SVN: r66132
2003-04-27 19:20:42 +02:00
|
|
|
}
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
void
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>::_Rep::
|
|
|
|
_M_destroy(const _Alloc& __a) throw ()
|
|
|
|
{
|
2005-05-28 23:57:03 +02:00
|
|
|
const size_type __size = sizeof(_Rep_base) +
|
|
|
|
(this->_M_capacity + 1) * sizeof(_CharT);
|
|
|
|
_Raw_bytes_alloc(__a).deallocate(reinterpret_cast<char*>(this), __size);
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
void
|
2004-10-18 10:43:17 +02:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
_M_leak_hard()
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
2011-10-14 08:57:55 +02:00
|
|
|
#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
|
Avoid multi-processor bus contention on increment/decrement-and- test of the reference count in the empty-string object...
2003-06-13 Nathan C. Myers <ncm-nospam@cantrip.org>
Avoid multi-processor bus contention on increment/decrement-and-
test of the reference count in the empty-string object, by comparing
addresses first, and never touching the reference count of the empty-
string object.
* include/bits/basic_string.h:
(_S_empty_rep_storage): Move into basic_string<>::_Rep for use by its
members.
(_Rep::_S_empty_rep()): New accessor.
(_Rep::_M_length, _Rep::_M_capacity, _Rep::_M_references): Move to
a base class _Rep_base.
(_Rep::_M_dispose, _Rep::_M_refcopy): Check for the empty string.
(basic_string()): Change to use _M_refdata() in place of _M_refcopy(),
since no longer must increment its refcount.
* include/bits/basic_string.tcc:
(_Rep::_M_destroy, _M_leak_hard): Check for the empty string and
return immediately. The former might be unnecessary. The latter
prevents begin() and end() from cloning it unnecessarily.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
input_iterator_tag), _S_construct(_InIterator, _InIterator,
const _Alloc&, forward_iterator_tag), _S_construct(size_type, _CharT,
const _Alloc&)): Change to use _M_refdata() in place of _M_refcopy().
(_M_mutate): Check for the empty string and treat it as shared.
This is necessary here because _M_mutate is sometimes called with
all-zero arguments; in all other uses of _M_is_shared, the test comes
out right anyhow.
From-SVN: r67912
2003-06-13 22:59:42 +02:00
|
|
|
if (_M_rep() == &_S_empty_rep())
|
2004-09-28 10:58:35 +02:00
|
|
|
return;
|
|
|
|
#endif
|
2004-02-08 05:46:42 +01:00
|
|
|
if (_M_rep()->_M_is_shared())
|
2000-10-05 13:27:02 +02:00
|
|
|
_M_mutate(0, 0, 0);
|
|
|
|
_M_rep()->_M_set_leaked();
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
void
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
_M_mutate(size_type __pos, size_type __len1, size_type __len2)
|
|
|
|
{
|
basic_string.h (_M_fold, [...]): Constify various variables.
2003-06-04 Paolo Carlini <pcarlini@unitus.it>
* include/bits/basic_string.h (_M_fold, insert(iterator, _CharT),
erase(iterator), erase(iterator, iterator), c_str,
compare(const basic_string&)): Constify various variables.
* include/bits/basic_string.tcc (_S_construct(_InIter, _InIter,
const _Alloc&, input_iterator_tag), _M_destroy, _M_mutate,
_S_create, resize, _M_replace, _M_replace_safe,
append(const basic_string&), append(const basic_string&, size_type,
size_type), append(const _CharT*, size_type), append(size_type,
_CharT), operator+(const _CharT*, const basic_string&),
operator+(_CharT, const basic_string&), replace(iterator, iterator,
size_type, _CharT), find(const _CharT*, size_type, size_type),
find(_CharT, size_type), rfind(const _CharT*, size_type, size_type),
rfind(_CharT, size_type), compare(size_type, size_type,
const basic_string&), compare(size_type, size_type,
const basic_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
From-SVN: r67468
2003-06-05 00:53:05 +02:00
|
|
|
const size_type __old_size = this->size();
|
2000-10-05 13:27:02 +02:00
|
|
|
const size_type __new_size = __old_size + __len2 - __len1;
|
|
|
|
const size_type __how_much = __old_size - __pos - __len1;
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2004-10-18 10:43:17 +02:00
|
|
|
if (__new_size > this->capacity() || _M_rep()->_M_is_shared())
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
|
|
|
// Must reallocate.
|
2004-01-25 23:43:07 +01:00
|
|
|
const allocator_type __a = get_allocator();
|
2004-10-18 10:43:17 +02:00
|
|
|
_Rep* __r = _Rep::_S_create(__new_size, this->capacity(), __a);
|
2004-01-19 09:53:32 +01:00
|
|
|
|
|
|
|
if (__pos)
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
_M_copy(__r->_M_refdata(), _M_data(), __pos);
|
2004-01-19 09:53:32 +01:00
|
|
|
if (__how_much)
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
_M_copy(__r->_M_refdata() + __pos + __len2,
|
|
|
|
_M_data() + __pos + __len1, __how_much);
|
2004-01-19 09:53:32 +01:00
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
_M_rep()->_M_dispose(__a);
|
|
|
|
_M_data(__r->_M_refdata());
|
Avoid multi-processor bus contention on increment/decrement-and- test of the reference count in the empty-string object...
2003-06-13 Nathan C. Myers <ncm-nospam@cantrip.org>
Avoid multi-processor bus contention on increment/decrement-and-
test of the reference count in the empty-string object, by comparing
addresses first, and never touching the reference count of the empty-
string object.
* include/bits/basic_string.h:
(_S_empty_rep_storage): Move into basic_string<>::_Rep for use by its
members.
(_Rep::_S_empty_rep()): New accessor.
(_Rep::_M_length, _Rep::_M_capacity, _Rep::_M_references): Move to
a base class _Rep_base.
(_Rep::_M_dispose, _Rep::_M_refcopy): Check for the empty string.
(basic_string()): Change to use _M_refdata() in place of _M_refcopy(),
since no longer must increment its refcount.
* include/bits/basic_string.tcc:
(_Rep::_M_destroy, _M_leak_hard): Check for the empty string and
return immediately. The former might be unnecessary. The latter
prevents begin() and end() from cloning it unnecessarily.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
input_iterator_tag), _S_construct(_InIterator, _InIterator,
const _Alloc&, forward_iterator_tag), _S_construct(size_type, _CharT,
const _Alloc&)): Change to use _M_refdata() in place of _M_refcopy().
(_M_mutate): Check for the empty string and treat it as shared.
This is necessary here because _M_mutate is sometimes called with
all-zero arguments; in all other uses of _M_is_shared, the test comes
out right anyhow.
From-SVN: r67912
2003-06-13 22:59:42 +02:00
|
|
|
}
|
2000-10-05 13:27:02 +02:00
|
|
|
else if (__how_much && __len1 != __len2)
|
|
|
|
{
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
// Work in-place.
|
|
|
|
_M_move(_M_data() + __pos + __len2,
|
|
|
|
_M_data() + __pos + __len1, __how_much);
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
2004-10-22 00:01:41 +02:00
|
|
|
_M_rep()->_M_set_length_and_sharable(__new_size);
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
void
|
2004-10-18 10:43:17 +02:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
reserve(size_type __res)
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
2003-12-11 23:29:12 +01:00
|
|
|
if (__res != this->capacity() || _M_rep()->_M_is_shared())
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
2001-11-21 23:04:53 +01:00
|
|
|
// Make sure we don't shrink below the current size
|
|
|
|
if (__res < this->size())
|
|
|
|
__res = this->size();
|
2004-01-25 23:43:07 +01:00
|
|
|
const allocator_type __a = get_allocator();
|
2000-10-05 13:27:02 +02:00
|
|
|
_CharT* __tmp = _M_rep()->_M_clone(__a, __res - this->size());
|
|
|
|
_M_rep()->_M_dispose(__a);
|
|
|
|
_M_data(__tmp);
|
|
|
|
}
|
|
|
|
}
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
2004-10-18 10:43:17 +02:00
|
|
|
void
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
swap(basic_string& __s)
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
2004-02-08 05:46:42 +01:00
|
|
|
if (_M_rep()->_M_is_leaked())
|
2000-10-05 13:27:02 +02:00
|
|
|
_M_rep()->_M_set_sharable();
|
2004-02-08 05:46:42 +01:00
|
|
|
if (__s._M_rep()->_M_is_leaked())
|
2000-10-05 13:27:02 +02:00
|
|
|
__s._M_rep()->_M_set_sharable();
|
|
|
|
if (this->get_allocator() == __s.get_allocator())
|
|
|
|
{
|
|
|
|
_CharT* __tmp = _M_data();
|
|
|
|
_M_data(__s._M_data());
|
|
|
|
__s._M_data(__tmp);
|
|
|
|
}
|
|
|
|
// The code below can usually be optimized away.
|
2004-02-08 05:46:42 +01:00
|
|
|
else
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
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
2004-01-26 21:23:20 +01:00
|
|
|
const basic_string __tmp1(_M_ibegin(), _M_iend(),
|
|
|
|
__s.get_allocator());
|
2004-02-08 05:46:42 +01:00
|
|
|
const basic_string __tmp2(__s._M_ibegin(), __s._M_iend(),
|
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
2004-01-26 21:23:20 +01:00
|
|
|
this->get_allocator());
|
2000-10-05 13:27:02 +02:00
|
|
|
*this = __tmp2;
|
|
|
|
__s = __tmp1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
2001-07-20 02:09:31 +02:00
|
|
|
typename basic_string<_CharT, _Traits, _Alloc>::_Rep*
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>::_Rep::
|
basic_string.h (_S_create(size_t, const _Alloc&): Change signature to take two size_type arguments.
2004-01-28 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_S_create(size_t,
const _Alloc&): Change signature to take two size_type
arguments.
* include/bits/basic_string.tcc (_S_construct(_InIterator,
_InIterator, const _Alloc&, input_iterator_tag)): Update
call, tweak a bit.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
forward_iterator_tag)): Likewise.
(_S_construct(size_type, _CharT, const _Alloc&)): Likewise.
(_M_mutate(size_type, size_type, size_type)): Don't
implement the exponential growth policy, demand it to
_S_create, update call and simplify.
(_M_clone(const _Alloc&, size_type)): Likewise.
(_S_create(size_type, size_type, const _Alloc&)): Implement
the growth policy, simplify otherwise.
* include/bits/basic_string.h (_Rep::operator[]): Tweak
signature to take a size_type, consistently with the other
members.
From-SVN: r76786
2004-01-28 11:37:32 +01:00
|
|
|
_S_create(size_type __capacity, size_type __old_capacity,
|
|
|
|
const _Alloc& __alloc)
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
2003-10-12 12:12:09 +02:00
|
|
|
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
2000-10-05 13:27:02 +02:00
|
|
|
// 83. String::npos vs. string::max_size()
|
2001-02-16 01:44:44 +01:00
|
|
|
if (__capacity > _S_max_size)
|
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
2004-01-26 21:23:20 +01:00
|
|
|
__throw_length_error(__N("basic_string::_S_create"));
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2001-11-28 06:17:59 +01:00
|
|
|
// The standard places no restriction on allocating more memory
|
|
|
|
// than is strictly needed within this layer at the moment or as
|
basic_string.h (_S_create(size_t, const _Alloc&): Change signature to take two size_type arguments.
2004-01-28 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_S_create(size_t,
const _Alloc&): Change signature to take two size_type
arguments.
* include/bits/basic_string.tcc (_S_construct(_InIterator,
_InIterator, const _Alloc&, input_iterator_tag)): Update
call, tweak a bit.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
forward_iterator_tag)): Likewise.
(_S_construct(size_type, _CharT, const _Alloc&)): Likewise.
(_M_mutate(size_type, size_type, size_type)): Don't
implement the exponential growth policy, demand it to
_S_create, update call and simplify.
(_M_clone(const _Alloc&, size_type)): Likewise.
(_S_create(size_type, size_type, const _Alloc&)): Implement
the growth policy, simplify otherwise.
* include/bits/basic_string.h (_Rep::operator[]): Tweak
signature to take a size_type, consistently with the other
members.
From-SVN: r76786
2004-01-28 11:37:32 +01:00
|
|
|
// requested by an explicit application call to reserve().
|
|
|
|
|
|
|
|
// Many malloc implementations perform quite poorly when an
|
2001-11-28 06:17:59 +01:00
|
|
|
// application attempts to allocate memory in a stepwise fashion
|
|
|
|
// growing each allocation size by only 1 char. Additionally,
|
|
|
|
// it makes little sense to allocate less linear memory than the
|
|
|
|
// natural blocking size of the malloc implementation.
|
|
|
|
// Unfortunately, we would need a somewhat low-level calculation
|
|
|
|
// with tuned parameters to get this perfect for any particular
|
|
|
|
// malloc implementation. Fortunately, generalizations about
|
|
|
|
// common features seen among implementations seems to suffice.
|
|
|
|
|
|
|
|
// __pagesize need not match the actual VM page size for good
|
|
|
|
// results in practice, thus we pick a common value on the low
|
|
|
|
// side. __malloc_header_size is an estimate of the amount of
|
|
|
|
// overhead per memory allocation (in practice seen N * sizeof
|
|
|
|
// (void*) where N is 0, 2 or 4). According to folklore,
|
|
|
|
// picking this value on the high side is better than
|
|
|
|
// low-balling it (especially when this algorithm is used with
|
|
|
|
// malloc implementations that allocate memory blocks rounded up
|
|
|
|
// to a size which is a power of 2).
|
2004-10-13 10:58:41 +02:00
|
|
|
const size_type __pagesize = 4096;
|
|
|
|
const size_type __malloc_header_size = 4 * sizeof(void*);
|
basic_string.h (_S_create(size_t, const _Alloc&): Change signature to take two size_type arguments.
2004-01-28 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_S_create(size_t,
const _Alloc&): Change signature to take two size_type
arguments.
* include/bits/basic_string.tcc (_S_construct(_InIterator,
_InIterator, const _Alloc&, input_iterator_tag)): Update
call, tweak a bit.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
forward_iterator_tag)): Likewise.
(_S_construct(size_type, _CharT, const _Alloc&)): Likewise.
(_M_mutate(size_type, size_type, size_type)): Don't
implement the exponential growth policy, demand it to
_S_create, update call and simplify.
(_M_clone(const _Alloc&, size_type)): Likewise.
(_S_create(size_type, size_type, const _Alloc&)): Implement
the growth policy, simplify otherwise.
* include/bits/basic_string.h (_Rep::operator[]): Tweak
signature to take a size_type, consistently with the other
members.
From-SVN: r76786
2004-01-28 11:37:32 +01:00
|
|
|
|
|
|
|
// The below implements an exponential growth policy, necessary to
|
|
|
|
// meet amortized linear time requirements of the library: see
|
|
|
|
// http://gcc.gnu.org/ml/libstdc++/2001-07/msg00085.html.
|
|
|
|
// It's active for allocations requiring an amount of memory above
|
|
|
|
// system pagesize. This is consistent with the requirements of the
|
|
|
|
// standard: http://gcc.gnu.org/ml/libstdc++/2001-07/msg00130.html
|
2004-10-13 10:58:41 +02:00
|
|
|
if (__capacity > __old_capacity && __capacity < 2 * __old_capacity)
|
basic_string.h (_S_create(size_t, const _Alloc&): Change signature to take two size_type arguments.
2004-01-28 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_S_create(size_t,
const _Alloc&): Change signature to take two size_type
arguments.
* include/bits/basic_string.tcc (_S_construct(_InIterator,
_InIterator, const _Alloc&, input_iterator_tag)): Update
call, tweak a bit.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
forward_iterator_tag)): Likewise.
(_S_construct(size_type, _CharT, const _Alloc&)): Likewise.
(_M_mutate(size_type, size_type, size_type)): Don't
implement the exponential growth policy, demand it to
_S_create, update call and simplify.
(_M_clone(const _Alloc&, size_type)): Likewise.
(_S_create(size_type, size_type, const _Alloc&)): Implement
the growth policy, simplify otherwise.
* include/bits/basic_string.h (_Rep::operator[]): Tweak
signature to take a size_type, consistently with the other
members.
From-SVN: r76786
2004-01-28 11:37:32 +01:00
|
|
|
__capacity = 2 * __old_capacity;
|
|
|
|
|
|
|
|
// NB: Need an array of char_type[__capacity], plus a terminating
|
2005-05-28 23:57:03 +02:00
|
|
|
// null char_type() element, plus enough for the _Rep data structure.
|
basic_string.h (_S_create(size_t, const _Alloc&): Change signature to take two size_type arguments.
2004-01-28 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_S_create(size_t,
const _Alloc&): Change signature to take two size_type
arguments.
* include/bits/basic_string.tcc (_S_construct(_InIterator,
_InIterator, const _Alloc&, input_iterator_tag)): Update
call, tweak a bit.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
forward_iterator_tag)): Likewise.
(_S_construct(size_type, _CharT, const _Alloc&)): Likewise.
(_M_mutate(size_type, size_type, size_type)): Don't
implement the exponential growth policy, demand it to
_S_create, update call and simplify.
(_M_clone(const _Alloc&, size_type)): Likewise.
(_S_create(size_type, size_type, const _Alloc&)): Implement
the growth policy, simplify otherwise.
* include/bits/basic_string.h (_Rep::operator[]): Tweak
signature to take a size_type, consistently with the other
members.
From-SVN: r76786
2004-01-28 11:37:32 +01:00
|
|
|
// Whew. Seemingly so needy, yet so elemental.
|
2005-05-28 23:57:03 +02:00
|
|
|
size_type __size = (__capacity + 1) * sizeof(_CharT) + sizeof(_Rep);
|
basic_string.h (_S_create(size_t, const _Alloc&): Change signature to take two size_type arguments.
2004-01-28 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_S_create(size_t,
const _Alloc&): Change signature to take two size_type
arguments.
* include/bits/basic_string.tcc (_S_construct(_InIterator,
_InIterator, const _Alloc&, input_iterator_tag)): Update
call, tweak a bit.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
forward_iterator_tag)): Likewise.
(_S_construct(size_type, _CharT, const _Alloc&)): Likewise.
(_M_mutate(size_type, size_type, size_type)): Don't
implement the exponential growth policy, demand it to
_S_create, update call and simplify.
(_M_clone(const _Alloc&, size_type)): Likewise.
(_S_create(size_type, size_type, const _Alloc&)): Implement
the growth policy, simplify otherwise.
* include/bits/basic_string.h (_Rep::operator[]): Tweak
signature to take a size_type, consistently with the other
members.
From-SVN: r76786
2004-01-28 11:37:32 +01:00
|
|
|
|
2004-01-31 16:39:52 +01:00
|
|
|
const size_type __adj_size = __size + __malloc_header_size;
|
2004-11-29 13:59:53 +01:00
|
|
|
if (__adj_size > __pagesize && __capacity > __old_capacity)
|
2001-11-28 06:17:59 +01:00
|
|
|
{
|
2004-01-31 16:39:52 +01:00
|
|
|
const size_type __extra = __pagesize - __adj_size % __pagesize;
|
2001-11-28 06:17:59 +01:00
|
|
|
__capacity += __extra / sizeof(_CharT);
|
2004-01-30 14:23:42 +01:00
|
|
|
// Never allocate a string bigger than _S_max_size.
|
|
|
|
if (__capacity > _S_max_size)
|
|
|
|
__capacity = _S_max_size;
|
2005-05-28 23:57:03 +02:00
|
|
|
__size = (__capacity + 1) * sizeof(_CharT) + sizeof(_Rep);
|
2001-11-28 06:17:59 +01:00
|
|
|
}
|
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
// NB: Might throw, but no worries about a leak, mate: _Rep()
|
|
|
|
// does not throw.
|
2005-05-28 23:57:03 +02:00
|
|
|
void* __place = _Raw_bytes_alloc(__alloc).allocate(__size);
|
2000-10-05 13:27:02 +02:00
|
|
|
_Rep *__p = new (__place) _Rep;
|
|
|
|
__p->_M_capacity = __capacity;
|
2006-10-16 11:51:14 +02:00
|
|
|
// ABI compatibility - 3.4.x set in _S_create both
|
|
|
|
// _M_refcount and _M_length. All callers of _S_create
|
|
|
|
// in basic_string.tcc then set just _M_length.
|
|
|
|
// In 4.0.x and later both _M_refcount and _M_length
|
|
|
|
// are initialized in the callers, unfortunately we can
|
|
|
|
// have 3.4.x compiled code with _S_create callers inlined
|
|
|
|
// calling 4.0.x+ _S_create.
|
|
|
|
__p->_M_set_sharable();
|
2000-10-05 13:27:02 +02:00
|
|
|
return __p;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
_CharT*
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>::_Rep::
|
|
|
|
_M_clone(const _Alloc& __alloc, size_type __res)
|
|
|
|
{
|
2001-12-07 10:07:55 +01:00
|
|
|
// Requested capacity of the clone.
|
Avoid multi-processor bus contention on increment/decrement-and- test of the reference count in the empty-string object...
2003-06-13 Nathan C. Myers <ncm-nospam@cantrip.org>
Avoid multi-processor bus contention on increment/decrement-and-
test of the reference count in the empty-string object, by comparing
addresses first, and never touching the reference count of the empty-
string object.
* include/bits/basic_string.h:
(_S_empty_rep_storage): Move into basic_string<>::_Rep for use by its
members.
(_Rep::_S_empty_rep()): New accessor.
(_Rep::_M_length, _Rep::_M_capacity, _Rep::_M_references): Move to
a base class _Rep_base.
(_Rep::_M_dispose, _Rep::_M_refcopy): Check for the empty string.
(basic_string()): Change to use _M_refdata() in place of _M_refcopy(),
since no longer must increment its refcount.
* include/bits/basic_string.tcc:
(_Rep::_M_destroy, _M_leak_hard): Check for the empty string and
return immediately. The former might be unnecessary. The latter
prevents begin() and end() from cloning it unnecessarily.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
input_iterator_tag), _S_construct(_InIterator, _InIterator,
const _Alloc&, forward_iterator_tag), _S_construct(size_type, _CharT,
const _Alloc&)): Change to use _M_refdata() in place of _M_refcopy().
(_M_mutate): Check for the empty string and treat it as shared.
This is necessary here because _M_mutate is sometimes called with
all-zero arguments; in all other uses of _M_is_shared, the test comes
out right anyhow.
From-SVN: r67912
2003-06-13 22:59:42 +02:00
|
|
|
const size_type __requested_cap = this->_M_length + __res;
|
basic_string.h (_S_create(size_t, const _Alloc&): Change signature to take two size_type arguments.
2004-01-28 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_S_create(size_t,
const _Alloc&): Change signature to take two size_type
arguments.
* include/bits/basic_string.tcc (_S_construct(_InIterator,
_InIterator, const _Alloc&, input_iterator_tag)): Update
call, tweak a bit.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
forward_iterator_tag)): Likewise.
(_S_construct(size_type, _CharT, const _Alloc&)): Likewise.
(_M_mutate(size_type, size_type, size_type)): Don't
implement the exponential growth policy, demand it to
_S_create, update call and simplify.
(_M_clone(const _Alloc&, size_type)): Likewise.
(_S_create(size_type, size_type, const _Alloc&)): Implement
the growth policy, simplify otherwise.
* include/bits/basic_string.h (_Rep::operator[]): Tweak
signature to take a size_type, consistently with the other
members.
From-SVN: r76786
2004-01-28 11:37:32 +01:00
|
|
|
_Rep* __r = _Rep::_S_create(__requested_cap, this->_M_capacity,
|
|
|
|
__alloc);
|
Avoid multi-processor bus contention on increment/decrement-and- test of the reference count in the empty-string object...
2003-06-13 Nathan C. Myers <ncm-nospam@cantrip.org>
Avoid multi-processor bus contention on increment/decrement-and-
test of the reference count in the empty-string object, by comparing
addresses first, and never touching the reference count of the empty-
string object.
* include/bits/basic_string.h:
(_S_empty_rep_storage): Move into basic_string<>::_Rep for use by its
members.
(_Rep::_S_empty_rep()): New accessor.
(_Rep::_M_length, _Rep::_M_capacity, _Rep::_M_references): Move to
a base class _Rep_base.
(_Rep::_M_dispose, _Rep::_M_refcopy): Check for the empty string.
(basic_string()): Change to use _M_refdata() in place of _M_refcopy(),
since no longer must increment its refcount.
* include/bits/basic_string.tcc:
(_Rep::_M_destroy, _M_leak_hard): Check for the empty string and
return immediately. The former might be unnecessary. The latter
prevents begin() and end() from cloning it unnecessarily.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
input_iterator_tag), _S_construct(_InIterator, _InIterator,
const _Alloc&, forward_iterator_tag), _S_construct(size_type, _CharT,
const _Alloc&)): Change to use _M_refdata() in place of _M_refcopy().
(_M_mutate): Check for the empty string and treat it as shared.
This is necessary here because _M_mutate is sometimes called with
all-zero arguments; in all other uses of _M_is_shared, the test comes
out right anyhow.
From-SVN: r67912
2003-06-13 22:59:42 +02:00
|
|
|
if (this->_M_length)
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
_M_copy(__r->_M_refdata(), _M_refdata(), this->_M_length);
|
2004-01-19 09:53:32 +01:00
|
|
|
|
2004-10-22 00:01:41 +02:00
|
|
|
__r->_M_set_length_and_sharable(this->_M_length);
|
2000-10-05 13:27:02 +02:00
|
|
|
return __r->_M_refdata();
|
|
|
|
}
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
void
|
2004-10-18 10:43:17 +02:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
resize(size_type __n, _CharT __c)
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
basic_string.h (_M_fold, [...]): Constify various variables.
2003-06-04 Paolo Carlini <pcarlini@unitus.it>
* include/bits/basic_string.h (_M_fold, insert(iterator, _CharT),
erase(iterator), erase(iterator, iterator), c_str,
compare(const basic_string&)): Constify various variables.
* include/bits/basic_string.tcc (_S_construct(_InIter, _InIter,
const _Alloc&, input_iterator_tag), _M_destroy, _M_mutate,
_S_create, resize, _M_replace, _M_replace_safe,
append(const basic_string&), append(const basic_string&, size_type,
size_type), append(const _CharT*, size_type), append(size_type,
_CharT), operator+(const _CharT*, const basic_string&),
operator+(_CharT, const basic_string&), replace(iterator, iterator,
size_type, _CharT), find(const _CharT*, size_type, size_type),
find(_CharT, size_type), rfind(const _CharT*, size_type, size_type),
rfind(_CharT, size_type), compare(size_type, size_type,
const basic_string&), compare(size_type, size_type,
const basic_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
From-SVN: r67468
2003-06-05 00:53:05 +02:00
|
|
|
const size_type __size = this->size();
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
_M_check_length(__size, __n, "basic_string::resize");
|
2000-10-05 13:27:02 +02:00
|
|
|
if (__size < __n)
|
|
|
|
this->append(__n - __size, __c);
|
|
|
|
else if (__n < __size)
|
|
|
|
this->erase(__n);
|
|
|
|
// else nothing (in particular, avoid calling _M_mutate() unnecessarily.)
|
|
|
|
}
|
basic_string.h (replace(i1, i2, _CharT* k1, _CharT* k2), [...]): New specializations to optimize for the common cases of pointers and iterators.
2002-04-02 Paolo Carlini <pcarlini@unitus.it>
Nathan Myers <ncm@cantrip.org>
Philip Martin <philip@codematters.co.uk>
* include/bits/basic_string.h
(replace(i1, i2, _CharT* k1, _CharT* k2),
replace(i2, i2, const _CharT* k1, const _CharT* k2),
replace(i1, i2, iterator k1, iterator k2,
replace(i1, i2, const_iterator k1, const_iterator k2):
New specializations to optimize for the common cases of
pointers and iterators.
(replace(pos, n1, s, n2)): Tweak.
* include/bits/basic_string.tcc: Tweak comments.
* testsuite/21_strings/replace.cc (test04): New tests.
Co-Authored-By: Nathan Myers <ncm@cantrip.org>
Co-Authored-By: Philip Martin <philip@codematters.co.uk>
From-SVN: r51746
2002-04-02 14:07:07 +02:00
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
BUGS: Update from 2.90.8 snapshot.
2003-06-10 Phil Edwards <pme@gcc.gnu.org>
* docs/html/17_intro/BUGS: Update from 2.90.8 snapshot.
* docs/html/17_intro/CHECKLIST: Bring up to date with respect to
correctness of container::iterator typedefs. Fix whitespace.
* docs/html/20_util/howto.html, docs/html/ext/howto.html: Add links
to allocator docs.
* docs/html/documentation.html: Regenerate.
* include/bits/basic_string.h, include/bits/basic_string.tcc,
include/bits/deque.tcc, include/bits/list.tcc, include/bits/stl_algo.h,
include/bits/stl_algobase.h, include/bits/stl_bvector.h,
include/bits/stl_deque.h, include/bits/stl_iterator_base_funcs.h,
include/bits/stl_list.h, include/bits/stl_uninitialized.h,
include/bits/stl_vector.h, include/bits/vector.tcc,
include/ext/algorithm, include/ext/slist, include/std/std_bitset.h:
Change _Iter names to _Iterator, and __pos to __position.
* include/bits/stl_relops.h, include/bits/stl_numeric.h,
include/bits/stl_multiset.h, include/bits/stl_set.h:
Remove emacs markers.
* include/bits/stl_threads.h (_STL_auto_lock): Add __unused__.
From-SVN: r67736
2003-06-10 23:52:25 +02:00
|
|
|
template<typename _InputIterator>
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>&
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
2004-02-08 05:46:42 +01:00
|
|
|
_M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
|
basic_string.h (assign(const basic_string&, size_type, size_type)): Define inline here.
2004-01-24 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (assign(const basic_string&,
size_type, size_type)): Define inline here.
(replace(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(_M_replace_dispatch(iterator, iterator, _InputIterator,
_InputIterator, __false_type)): Only declare.
(_M_replace(iterator, iterator, _InputIterator,
_InputIterator)): Remove.
* include/bits/basic_string.tcc (assign(const basic_string&,
size_type, size_type)): Move inline.
(replace(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(_M_replace_dispatch(iterator, iterator, _InputIterator,
_InputIterator, __false_type)): Define, now does also what
_M_replace did before.
* src/string-inst.cc (_M_replace): Don't instantiate.
* include/bits/basic_string.tcc (find(const _CharT*,
size_type, size_type)): Tidy.
(rfind(_CharT, size_type)): Ditto.
(find_first_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_first_not_of(_CharT, size_type)): Ditto.
(find_last_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(_CharT, size_type)): Ditto.
From-SVN: r76508
2004-01-24 12:34:06 +01:00
|
|
|
_InputIterator __k2, __false_type)
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
basic_string.h (_M_fold, [...]): Constify various variables.
2003-06-04 Paolo Carlini <pcarlini@unitus.it>
* include/bits/basic_string.h (_M_fold, insert(iterator, _CharT),
erase(iterator), erase(iterator, iterator), c_str,
compare(const basic_string&)): Constify various variables.
* include/bits/basic_string.tcc (_S_construct(_InIter, _InIter,
const _Alloc&, input_iterator_tag), _M_destroy, _M_mutate,
_S_create, resize, _M_replace, _M_replace_safe,
append(const basic_string&), append(const basic_string&, size_type,
size_type), append(const _CharT*, size_type), append(size_type,
_CharT), operator+(const _CharT*, const basic_string&),
operator+(_CharT, const basic_string&), replace(iterator, iterator,
size_type, _CharT), find(const _CharT*, size_type, size_type),
find(_CharT, size_type), rfind(const _CharT*, size_type, size_type),
rfind(_CharT, size_type), compare(size_type, size_type,
const basic_string&), compare(size_type, size_type,
const basic_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
From-SVN: r67468
2003-06-05 00:53:05 +02:00
|
|
|
const basic_string __s(__k1, __k2);
|
basic_string.tcc (insert(size_type, const _CharT*, size_type __n)): Fix length_error check.
2004-01-23 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.tcc (insert(size_type,
const _CharT*, size_type __n)): Fix length_error check.
(replace(size_type, size_type, const _CharT*, size_type):
Ditto; call _M_replace_safe.
(_M_replace_aux(size_type, size_type, size_type, _CharT):
Fix length_error check.
(_M_replace(iterator, iterator, _InputIterator,
_InputIterator)): Ditto, tweak.
(_M_replace_safe(size_type, size_type, const _CharT*,
size_type)): Remove length_error check.
* include/bits/basic_string.tcc (append(const basic_string&),
append(const basic_string&, size_type, size_type)): Tweak
comment.
* include/bits/basic_string.tcc (copy(_CharT*, size_type,
size_type)): If __n == 0 don't call traits::copy.
From-SVN: r76476
2004-01-24 01:27:19 +01:00
|
|
|
const size_type __n1 = __i2 - __i1;
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
_M_check_length(__n1, __s.size(), "basic_string::_M_replace_dispatch");
|
basic_string.tcc (insert(size_type, const _CharT*, size_type __n)): Fix length_error check.
2004-01-23 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.tcc (insert(size_type,
const _CharT*, size_type __n)): Fix length_error check.
(replace(size_type, size_type, const _CharT*, size_type):
Ditto; call _M_replace_safe.
(_M_replace_aux(size_type, size_type, size_type, _CharT):
Fix length_error check.
(_M_replace(iterator, iterator, _InputIterator,
_InputIterator)): Ditto, tweak.
(_M_replace_safe(size_type, size_type, const _CharT*,
size_type)): Remove length_error check.
* include/bits/basic_string.tcc (append(const basic_string&),
append(const basic_string&, size_type, size_type)): Tweak
comment.
* include/bits/basic_string.tcc (copy(_CharT*, size_type,
size_type)): If __n == 0 don't call traits::copy.
From-SVN: r76476
2004-01-24 01:27:19 +01:00
|
|
|
return _M_replace_safe(__i1 - _M_ibegin(), __n1, __s._M_data(),
|
basic_string.h (_M_replace_safe): Change signatures to take size_types and const _CharT*.
2004-01-22 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_M_replace_safe): Change
signatures to take size_types and const _CharT*.
(_M_replace_aux): Likewise, takes size_types instead of
iterators.
(append(size_type, _CharT)): Update call.
(assign(size_type, _CharT)): Ditto.
(replace(iterator, iterator, size_type, _CharT)): Ditto.
(_M_replace_dispatch(iterator, iterator, _Integer,
_Integer, __true_type)): Ditto.
* include/bits/basic_string.tcc (assign(const _CharT*,
size_type)): Ditto.
(insert(size_type, const _CharT*, size_type)): Ditto.
(replace(size_type, size_type, const _CharT*,
size_type)): Ditto.
(_M_replace(iterator, iterator, _InputIterator,
_InputIterator)): Ditto.
(append(const basic_string&)): Ditto.
(append(const basic_string&, size_type, size_type): Ditto.
(append(const _CharT*, size_type): Ditto.
(_M_replace_safe, _M_replace_safe): Change definitions
accordingly, simplify.
* string-inst.cc (_M_replace_safe): Don't instantiate.
From-SVN: r76353
2004-01-22 13:46:28 +01:00
|
|
|
__s.size());
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
2004-10-27 14:02:37 +02:00
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>&
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
_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_mutate(__pos1, __n1, __n2);
|
|
|
|
if (__n2)
|
|
|
|
_M_assign(_M_data() + __pos1, __n2, __c);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>&
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
_M_replace_safe(size_type __pos1, size_type __n1, const _CharT* __s,
|
|
|
|
size_type __n2)
|
|
|
|
{
|
|
|
|
_M_mutate(__pos1, __n1, __n2);
|
|
|
|
if (__n2)
|
|
|
|
_M_copy(_M_data() + __pos1, __s, __n2);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
2001-10-31 09:27:20 +01:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>
|
2000-10-05 13:27:02 +02:00
|
|
|
operator+(const _CharT* __lhs,
|
2001-10-31 09:27:20 +01:00
|
|
|
const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
2003-11-11 21:09:16 +01:00
|
|
|
__glibcxx_requires_string(__lhs);
|
2001-10-31 09:27:20 +01:00
|
|
|
typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
|
2000-10-05 13:27:02 +02:00
|
|
|
typedef typename __string_type::size_type __size_type;
|
basic_string.h (_M_fold, [...]): Constify various variables.
2003-06-04 Paolo Carlini <pcarlini@unitus.it>
* include/bits/basic_string.h (_M_fold, insert(iterator, _CharT),
erase(iterator), erase(iterator, iterator), c_str,
compare(const basic_string&)): Constify various variables.
* include/bits/basic_string.tcc (_S_construct(_InIter, _InIter,
const _Alloc&, input_iterator_tag), _M_destroy, _M_mutate,
_S_create, resize, _M_replace, _M_replace_safe,
append(const basic_string&), append(const basic_string&, size_type,
size_type), append(const _CharT*, size_type), append(size_type,
_CharT), operator+(const _CharT*, const basic_string&),
operator+(_CharT, const basic_string&), replace(iterator, iterator,
size_type, _CharT), find(const _CharT*, size_type, size_type),
find(_CharT, size_type), rfind(const _CharT*, size_type, size_type),
rfind(_CharT, size_type), compare(size_type, size_type,
const basic_string&), compare(size_type, size_type,
const basic_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
From-SVN: r67468
2003-06-05 00:53:05 +02:00
|
|
|
const __size_type __len = _Traits::length(__lhs);
|
2000-10-05 13:27:02 +02:00
|
|
|
__string_type __str;
|
|
|
|
__str.reserve(__len + __rhs.size());
|
2004-01-24 19:54:23 +01:00
|
|
|
__str.append(__lhs, __len);
|
2000-10-05 13:27:02 +02:00
|
|
|
__str.append(__rhs);
|
|
|
|
return __str;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
2001-10-31 09:27:20 +01:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>
|
|
|
|
operator+(_CharT __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
2001-10-31 09:27:20 +01:00
|
|
|
typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
|
2000-10-05 13:27:02 +02:00
|
|
|
typedef typename __string_type::size_type __size_type;
|
|
|
|
__string_type __str;
|
basic_string.h (_M_fold, [...]): Constify various variables.
2003-06-04 Paolo Carlini <pcarlini@unitus.it>
* include/bits/basic_string.h (_M_fold, insert(iterator, _CharT),
erase(iterator), erase(iterator, iterator), c_str,
compare(const basic_string&)): Constify various variables.
* include/bits/basic_string.tcc (_S_construct(_InIter, _InIter,
const _Alloc&, input_iterator_tag), _M_destroy, _M_mutate,
_S_create, resize, _M_replace, _M_replace_safe,
append(const basic_string&), append(const basic_string&, size_type,
size_type), append(const _CharT*, size_type), append(size_type,
_CharT), operator+(const _CharT*, const basic_string&),
operator+(_CharT, const basic_string&), replace(iterator, iterator,
size_type, _CharT), find(const _CharT*, size_type, size_type),
find(_CharT, size_type), rfind(const _CharT*, size_type, size_type),
rfind(_CharT, size_type), compare(size_type, size_type,
const basic_string&), compare(size_type, size_type,
const basic_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
From-SVN: r67468
2003-06-05 00:53:05 +02:00
|
|
|
const __size_type __len = __rhs.size();
|
2000-10-05 13:27:02 +02:00
|
|
|
__str.reserve(__len + 1);
|
2001-03-15 09:46:23 +01:00
|
|
|
__str.append(__size_type(1), __lhs);
|
2000-10-05 13:27:02 +02:00
|
|
|
__str.append(__rhs);
|
|
|
|
return __str;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
2001-07-20 02:09:31 +02:00
|
|
|
typename basic_string<_CharT, _Traits, _Alloc>::size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
copy(_CharT* __s, size_type __n, size_type __pos) const
|
|
|
|
{
|
basic_string.tcc (rfind(_CharT, size_type)): Revert last change to use std::min: machine language is worse.
2004-01-24 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.tcc (rfind(_CharT, size_type)):
Revert last change to use std::min: machine language is worse.
(find_last_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(_CharT, size_type)): Ditto.
* include/bits/basic_string.tcc (insert(size_type, const _CharT*,
size_type)): Discard the value returned by _M_check.
(replace(size_type, size_type, const _CharT*, size_type)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76514
2004-01-24 17:52:04 +01:00
|
|
|
_M_check(__pos, "basic_string::copy");
|
basic_string.h (_M_check): Change to return a checked __pos and take an additional const char* argument.
2004-01-21 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_M_check): Change to return
a checked __pos and take an additional const char* argument.
(_M_fold): Rename to _M_limit, change to return a size_type,
corresponding to the __off limited to the actual length.
(insert(size_type, size_type, _CharT)): Update call, call
replace.
(insert(iterator, _CharT)): Call replace(iterator, iterator,
size_type, _CharT) instead.
(erase(size_type, size_type)): Update calls.
(replace(size_type, size_type, size_type, _CharT)): Ditto.
(substr(size_type, size_type)): Use _M_check.
* include/bits/basic_string.tcc (basic_string(const basic_string&,
size_type, size_type)): Update calls.
(basic_string(const basic_string&, size_type, size_type,
const _Alloc&)): Ditto.
(assign(const basic_string&, size_type, size_type)): Use the
new _M_check and _M_limit.
(insert(size_type, const basic_string&, size_type, size_type):
Ditto.
(insert(size_type, const _CharT*, size_type)): Ditto.
(replace(size_type, size_type, const _CharT*, size_type): Ditto.
(replace(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(append(const basic_string&)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,size_type,
size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76274
2004-01-21 12:29:51 +01:00
|
|
|
__n = _M_limit(__pos, __n);
|
2003-11-11 21:09:16 +01:00
|
|
|
__glibcxx_requires_string_len(__s, __n);
|
basic_string.tcc (insert(size_type, const _CharT*, size_type __n)): Fix length_error check.
2004-01-23 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.tcc (insert(size_type,
const _CharT*, size_type __n)): Fix length_error check.
(replace(size_type, size_type, const _CharT*, size_type):
Ditto; call _M_replace_safe.
(_M_replace_aux(size_type, size_type, size_type, _CharT):
Fix length_error check.
(_M_replace(iterator, iterator, _InputIterator,
_InputIterator)): Ditto, tweak.
(_M_replace_safe(size_type, size_type, const _CharT*,
size_type)): Remove length_error check.
* include/bits/basic_string.tcc (append(const basic_string&),
append(const basic_string&, size_type, size_type)): Tweak
comment.
* include/bits/basic_string.tcc (copy(_CharT*, size_type,
size_type)): If __n == 0 don't call traits::copy.
From-SVN: r76476
2004-01-24 01:27:19 +01:00
|
|
|
if (__n)
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
_M_copy(__s, _M_data() + __pos, __n);
|
2000-10-05 13:27:02 +02:00
|
|
|
// 21.3.5.7 par 3: do not append null. (good.)
|
|
|
|
return __n;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
2001-07-20 02:09:31 +02:00
|
|
|
typename basic_string<_CharT, _Traits, _Alloc>::size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
find(const _CharT* __s, size_type __pos, size_type __n) const
|
|
|
|
{
|
2003-11-11 21:09:16 +01:00
|
|
|
__glibcxx_requires_string_len(__s, __n);
|
basic_string.h (_M_fold, [...]): Constify various variables.
2003-06-04 Paolo Carlini <pcarlini@unitus.it>
* include/bits/basic_string.h (_M_fold, insert(iterator, _CharT),
erase(iterator), erase(iterator, iterator), c_str,
compare(const basic_string&)): Constify various variables.
* include/bits/basic_string.tcc (_S_construct(_InIter, _InIter,
const _Alloc&, input_iterator_tag), _M_destroy, _M_mutate,
_S_create, resize, _M_replace, _M_replace_safe,
append(const basic_string&), append(const basic_string&, size_type,
size_type), append(const _CharT*, size_type), append(size_type,
_CharT), operator+(const _CharT*, const basic_string&),
operator+(_CharT, const basic_string&), replace(iterator, iterator,
size_type, _CharT), find(const _CharT*, size_type, size_type),
find(_CharT, size_type), rfind(const _CharT*, size_type, size_type),
rfind(_CharT, size_type), compare(size_type, size_type,
const basic_string&), compare(size_type, size_type,
const basic_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
From-SVN: r67468
2003-06-05 00:53:05 +02:00
|
|
|
const size_type __size = this->size();
|
2006-09-05 17:43:47 +02:00
|
|
|
const _CharT* __data = _M_data();
|
|
|
|
|
|
|
|
if (__n == 0)
|
|
|
|
return __pos <= __size ? __pos : npos;
|
|
|
|
|
2006-09-05 19:38:44 +02:00
|
|
|
if (__n <= __size)
|
|
|
|
{
|
2007-03-30 19:10:50 +02:00
|
|
|
for (; __pos <= __size - __n; ++__pos)
|
2006-09-05 19:38:44 +02:00
|
|
|
if (traits_type::eq(__data[__pos], __s[0])
|
|
|
|
&& traits_type::compare(__data + __pos + 1,
|
|
|
|
__s + 1, __n - 1) == 0)
|
|
|
|
return __pos;
|
|
|
|
}
|
2006-09-05 17:43:47 +02:00
|
|
|
return npos;
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
2001-07-20 02:09:31 +02:00
|
|
|
typename basic_string<_CharT, _Traits, _Alloc>::size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
2011-05-31 14:50:31 +02:00
|
|
|
find(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
|
|
|
size_type __ret = npos;
|
2004-06-12 10:10:24 +02:00
|
|
|
const size_type __size = this->size();
|
2000-10-05 13:27:02 +02:00
|
|
|
if (__pos < __size)
|
|
|
|
{
|
|
|
|
const _CharT* __data = _M_data();
|
basic_string.h (_M_fold, [...]): Constify various variables.
2003-06-04 Paolo Carlini <pcarlini@unitus.it>
* include/bits/basic_string.h (_M_fold, insert(iterator, _CharT),
erase(iterator), erase(iterator, iterator), c_str,
compare(const basic_string&)): Constify various variables.
* include/bits/basic_string.tcc (_S_construct(_InIter, _InIter,
const _Alloc&, input_iterator_tag), _M_destroy, _M_mutate,
_S_create, resize, _M_replace, _M_replace_safe,
append(const basic_string&), append(const basic_string&, size_type,
size_type), append(const _CharT*, size_type), append(size_type,
_CharT), operator+(const _CharT*, const basic_string&),
operator+(_CharT, const basic_string&), replace(iterator, iterator,
size_type, _CharT), find(const _CharT*, size_type, size_type),
find(_CharT, size_type), rfind(const _CharT*, size_type, size_type),
rfind(_CharT, size_type), compare(size_type, size_type,
const basic_string&), compare(size_type, size_type,
const basic_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
From-SVN: r67468
2003-06-05 00:53:05 +02:00
|
|
|
const size_type __n = __size - __pos;
|
2001-01-12 22:24:15 +01:00
|
|
|
const _CharT* __p = traits_type::find(__data + __pos, __n, __c);
|
|
|
|
if (__p)
|
2000-10-05 13:27:02 +02:00
|
|
|
__ret = __p - __data;
|
|
|
|
}
|
|
|
|
return __ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
2001-07-20 02:09:31 +02:00
|
|
|
typename basic_string<_CharT, _Traits, _Alloc>::size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
rfind(const _CharT* __s, size_type __pos, size_type __n) const
|
|
|
|
{
|
2003-11-11 21:09:16 +01:00
|
|
|
__glibcxx_requires_string_len(__s, __n);
|
basic_string.h (_M_fold, [...]): Constify various variables.
2003-06-04 Paolo Carlini <pcarlini@unitus.it>
* include/bits/basic_string.h (_M_fold, insert(iterator, _CharT),
erase(iterator), erase(iterator, iterator), c_str,
compare(const basic_string&)): Constify various variables.
* include/bits/basic_string.tcc (_S_construct(_InIter, _InIter,
const _Alloc&, input_iterator_tag), _M_destroy, _M_mutate,
_S_create, resize, _M_replace, _M_replace_safe,
append(const basic_string&), append(const basic_string&, size_type,
size_type), append(const _CharT*, size_type), append(size_type,
_CharT), operator+(const _CharT*, const basic_string&),
operator+(_CharT, const basic_string&), replace(iterator, iterator,
size_type, _CharT), find(const _CharT*, size_type, size_type),
find(_CharT, size_type), rfind(const _CharT*, size_type, size_type),
rfind(_CharT, size_type), compare(size_type, size_type,
const basic_string&), compare(size_type, size_type,
const basic_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
From-SVN: r67468
2003-06-05 00:53:05 +02:00
|
|
|
const size_type __size = this->size();
|
2000-10-05 13:27:02 +02:00
|
|
|
if (__n <= __size)
|
|
|
|
{
|
2003-03-05 23:24:56 +01:00
|
|
|
__pos = std::min(size_type(__size - __n), __pos);
|
2000-10-05 13:27:02 +02:00
|
|
|
const _CharT* __data = _M_data();
|
2004-02-08 05:46:42 +01:00
|
|
|
do
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
|
|
|
if (traits_type::compare(__data + __pos, __s, __n) == 0)
|
|
|
|
return __pos;
|
2004-02-08 05:46:42 +01:00
|
|
|
}
|
2000-10-05 13:27:02 +02:00
|
|
|
while (__pos-- > 0);
|
|
|
|
}
|
|
|
|
return npos;
|
|
|
|
}
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
2001-07-20 02:09:31 +02:00
|
|
|
typename basic_string<_CharT, _Traits, _Alloc>::size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
2011-05-31 14:50:31 +02:00
|
|
|
rfind(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
basic_string.tcc (rfind(_CharT, size_type)): Revert last change to use std::min: machine language is worse.
2004-01-24 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.tcc (rfind(_CharT, size_type)):
Revert last change to use std::min: machine language is worse.
(find_last_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(_CharT, size_type)): Ditto.
* include/bits/basic_string.tcc (insert(size_type, const _CharT*,
size_type)): Discard the value returned by _M_check.
(replace(size_type, size_type, const _CharT*, size_type)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76514
2004-01-24 17:52:04 +01:00
|
|
|
size_type __size = this->size();
|
2000-10-05 13:27:02 +02:00
|
|
|
if (__size)
|
|
|
|
{
|
basic_string.tcc (rfind(_CharT, size_type)): Revert last change to use std::min: machine language is worse.
2004-01-24 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.tcc (rfind(_CharT, size_type)):
Revert last change to use std::min: machine language is worse.
(find_last_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(_CharT, size_type)): Ditto.
* include/bits/basic_string.tcc (insert(size_type, const _CharT*,
size_type)): Discard the value returned by _M_check.
(replace(size_type, size_type, const _CharT*, size_type)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76514
2004-01-24 17:52:04 +01:00
|
|
|
if (--__size > __pos)
|
|
|
|
__size = __pos;
|
|
|
|
for (++__size; __size-- > 0; )
|
|
|
|
if (traits_type::eq(_M_data()[__size], __c))
|
|
|
|
return __size;
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
|
|
|
return npos;
|
|
|
|
}
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
2001-07-20 02:09:31 +02:00
|
|
|
typename basic_string<_CharT, _Traits, _Alloc>::size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
|
|
|
|
{
|
2003-11-11 21:09:16 +01:00
|
|
|
__glibcxx_requires_string_len(__s, __n);
|
2000-10-05 13:27:02 +02:00
|
|
|
for (; __n && __pos < this->size(); ++__pos)
|
|
|
|
{
|
2001-01-12 22:24:15 +01:00
|
|
|
const _CharT* __p = traits_type::find(__s, __n, _M_data()[__pos]);
|
|
|
|
if (__p)
|
2000-10-05 13:27:02 +02:00
|
|
|
return __pos;
|
|
|
|
}
|
|
|
|
return npos;
|
|
|
|
}
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
2001-07-20 02:09:31 +02:00
|
|
|
typename basic_string<_CharT, _Traits, _Alloc>::size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
|
|
|
|
{
|
2003-11-11 21:09:16 +01:00
|
|
|
__glibcxx_requires_string_len(__s, __n);
|
2000-10-05 13:27:02 +02:00
|
|
|
size_type __size = this->size();
|
|
|
|
if (__size && __n)
|
2004-02-08 05:46:42 +01:00
|
|
|
{
|
|
|
|
if (--__size > __pos)
|
2000-10-05 13:27:02 +02:00
|
|
|
__size = __pos;
|
|
|
|
do
|
|
|
|
{
|
2001-01-12 22:24:15 +01:00
|
|
|
if (traits_type::find(__s, __n, _M_data()[__size]))
|
2000-10-05 13:27:02 +02:00
|
|
|
return __size;
|
2004-02-08 05:46:42 +01:00
|
|
|
}
|
2000-10-05 13:27:02 +02:00
|
|
|
while (__size-- != 0);
|
|
|
|
}
|
|
|
|
return npos;
|
|
|
|
}
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
2001-07-20 02:09:31 +02:00
|
|
|
typename basic_string<_CharT, _Traits, _Alloc>::size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
|
|
|
|
{
|
2003-11-11 21:09:16 +01:00
|
|
|
__glibcxx_requires_string_len(__s, __n);
|
basic_string.h (assign(const basic_string&, size_type, size_type)): Define inline here.
2004-01-24 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (assign(const basic_string&,
size_type, size_type)): Define inline here.
(replace(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(_M_replace_dispatch(iterator, iterator, _InputIterator,
_InputIterator, __false_type)): Only declare.
(_M_replace(iterator, iterator, _InputIterator,
_InputIterator)): Remove.
* include/bits/basic_string.tcc (assign(const basic_string&,
size_type, size_type)): Move inline.
(replace(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(_M_replace_dispatch(iterator, iterator, _InputIterator,
_InputIterator, __false_type)): Define, now does also what
_M_replace did before.
* src/string-inst.cc (_M_replace): Don't instantiate.
* include/bits/basic_string.tcc (find(const _CharT*,
size_type, size_type)): Tidy.
(rfind(_CharT, size_type)): Ditto.
(find_first_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_first_not_of(_CharT, size_type)): Ditto.
(find_last_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(_CharT, size_type)): Ditto.
From-SVN: r76508
2004-01-24 12:34:06 +01:00
|
|
|
for (; __pos < this->size(); ++__pos)
|
|
|
|
if (!traits_type::find(__s, __n, _M_data()[__pos]))
|
|
|
|
return __pos;
|
2000-10-05 13:27:02 +02:00
|
|
|
return npos;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
2001-07-20 02:09:31 +02:00
|
|
|
typename basic_string<_CharT, _Traits, _Alloc>::size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
2011-05-31 14:50:31 +02:00
|
|
|
find_first_not_of(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
basic_string.h (assign(const basic_string&, size_type, size_type)): Define inline here.
2004-01-24 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (assign(const basic_string&,
size_type, size_type)): Define inline here.
(replace(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(_M_replace_dispatch(iterator, iterator, _InputIterator,
_InputIterator, __false_type)): Only declare.
(_M_replace(iterator, iterator, _InputIterator,
_InputIterator)): Remove.
* include/bits/basic_string.tcc (assign(const basic_string&,
size_type, size_type)): Move inline.
(replace(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(_M_replace_dispatch(iterator, iterator, _InputIterator,
_InputIterator, __false_type)): Define, now does also what
_M_replace did before.
* src/string-inst.cc (_M_replace): Don't instantiate.
* include/bits/basic_string.tcc (find(const _CharT*,
size_type, size_type)): Tidy.
(rfind(_CharT, size_type)): Ditto.
(find_first_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_first_not_of(_CharT, size_type)): Ditto.
(find_last_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(_CharT, size_type)): Ditto.
From-SVN: r76508
2004-01-24 12:34:06 +01:00
|
|
|
for (; __pos < this->size(); ++__pos)
|
|
|
|
if (!traits_type::eq(_M_data()[__pos], __c))
|
|
|
|
return __pos;
|
2000-10-05 13:27:02 +02:00
|
|
|
return npos;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
2001-07-20 02:09:31 +02:00
|
|
|
typename basic_string<_CharT, _Traits, _Alloc>::size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
|
|
|
|
{
|
2003-11-11 21:09:16 +01:00
|
|
|
__glibcxx_requires_string_len(__s, __n);
|
basic_string.tcc (rfind(_CharT, size_type)): Revert last change to use std::min: machine language is worse.
2004-01-24 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.tcc (rfind(_CharT, size_type)):
Revert last change to use std::min: machine language is worse.
(find_last_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(_CharT, size_type)): Ditto.
* include/bits/basic_string.tcc (insert(size_type, const _CharT*,
size_type)): Discard the value returned by _M_check.
(replace(size_type, size_type, const _CharT*, size_type)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76514
2004-01-24 17:52:04 +01:00
|
|
|
size_type __size = this->size();
|
2001-10-19 20:39:00 +02:00
|
|
|
if (__size)
|
basic_string.tcc (rfind(_CharT, size_type)): Revert last change to use std::min: machine language is worse.
2004-01-24 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.tcc (rfind(_CharT, size_type)):
Revert last change to use std::min: machine language is worse.
(find_last_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(_CharT, size_type)): Ditto.
* include/bits/basic_string.tcc (insert(size_type, const _CharT*,
size_type)): Discard the value returned by _M_check.
(replace(size_type, size_type, const _CharT*, size_type)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76514
2004-01-24 17:52:04 +01:00
|
|
|
{
|
|
|
|
if (--__size > __pos)
|
|
|
|
__size = __pos;
|
2004-02-08 05:46:42 +01:00
|
|
|
do
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
basic_string.tcc (rfind(_CharT, size_type)): Revert last change to use std::min: machine language is worse.
2004-01-24 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.tcc (rfind(_CharT, size_type)):
Revert last change to use std::min: machine language is worse.
(find_last_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(_CharT, size_type)): Ditto.
* include/bits/basic_string.tcc (insert(size_type, const _CharT*,
size_type)): Discard the value returned by _M_check.
(replace(size_type, size_type, const _CharT*, size_type)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76514
2004-01-24 17:52:04 +01:00
|
|
|
if (!traits_type::find(__s, __n, _M_data()[__size]))
|
|
|
|
return __size;
|
2004-02-08 05:46:42 +01:00
|
|
|
}
|
basic_string.tcc (rfind(_CharT, size_type)): Revert last change to use std::min: machine language is worse.
2004-01-24 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.tcc (rfind(_CharT, size_type)):
Revert last change to use std::min: machine language is worse.
(find_last_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(_CharT, size_type)): Ditto.
* include/bits/basic_string.tcc (insert(size_type, const _CharT*,
size_type)): Discard the value returned by _M_check.
(replace(size_type, size_type, const _CharT*, size_type)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76514
2004-01-24 17:52:04 +01:00
|
|
|
while (__size--);
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
|
|
|
return npos;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
2001-07-20 02:09:31 +02:00
|
|
|
typename basic_string<_CharT, _Traits, _Alloc>::size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
2011-05-31 14:50:31 +02:00
|
|
|
find_last_not_of(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
basic_string.tcc (rfind(_CharT, size_type)): Revert last change to use std::min: machine language is worse.
2004-01-24 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.tcc (rfind(_CharT, size_type)):
Revert last change to use std::min: machine language is worse.
(find_last_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(_CharT, size_type)): Ditto.
* include/bits/basic_string.tcc (insert(size_type, const _CharT*,
size_type)): Discard the value returned by _M_check.
(replace(size_type, size_type, const _CharT*, size_type)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76514
2004-01-24 17:52:04 +01:00
|
|
|
size_type __size = this->size();
|
2000-10-05 13:27:02 +02:00
|
|
|
if (__size)
|
basic_string.h (assign(const basic_string&, size_type, size_type)): Define inline here.
2004-01-24 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (assign(const basic_string&,
size_type, size_type)): Define inline here.
(replace(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(_M_replace_dispatch(iterator, iterator, _InputIterator,
_InputIterator, __false_type)): Only declare.
(_M_replace(iterator, iterator, _InputIterator,
_InputIterator)): Remove.
* include/bits/basic_string.tcc (assign(const basic_string&,
size_type, size_type)): Move inline.
(replace(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(_M_replace_dispatch(iterator, iterator, _InputIterator,
_InputIterator, __false_type)): Define, now does also what
_M_replace did before.
* src/string-inst.cc (_M_replace): Don't instantiate.
* include/bits/basic_string.tcc (find(const _CharT*,
size_type, size_type)): Tidy.
(rfind(_CharT, size_type)): Ditto.
(find_first_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_first_not_of(_CharT, size_type)): Ditto.
(find_last_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(_CharT, size_type)): Ditto.
From-SVN: r76508
2004-01-24 12:34:06 +01:00
|
|
|
{
|
basic_string.tcc (rfind(_CharT, size_type)): Revert last change to use std::min: machine language is worse.
2004-01-24 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.tcc (rfind(_CharT, size_type)):
Revert last change to use std::min: machine language is worse.
(find_last_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(_CharT, size_type)): Ditto.
* include/bits/basic_string.tcc (insert(size_type, const _CharT*,
size_type)): Discard the value returned by _M_check.
(replace(size_type, size_type, const _CharT*, size_type)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76514
2004-01-24 17:52:04 +01:00
|
|
|
if (--__size > __pos)
|
2004-02-08 05:46:42 +01:00
|
|
|
__size = __pos;
|
2000-10-05 13:27:02 +02:00
|
|
|
do
|
|
|
|
{
|
basic_string.tcc (rfind(_CharT, size_type)): Revert last change to use std::min: machine language is worse.
2004-01-24 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.tcc (rfind(_CharT, size_type)):
Revert last change to use std::min: machine language is worse.
(find_last_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(_CharT, size_type)): Ditto.
* include/bits/basic_string.tcc (insert(size_type, const _CharT*,
size_type)): Discard the value returned by _M_check.
(replace(size_type, size_type, const _CharT*, size_type)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76514
2004-01-24 17:52:04 +01:00
|
|
|
if (!traits_type::eq(_M_data()[__size], __c))
|
|
|
|
return __size;
|
2004-02-08 05:46:42 +01:00
|
|
|
}
|
basic_string.tcc (rfind(_CharT, size_type)): Revert last change to use std::min: machine language is worse.
2004-01-24 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.tcc (rfind(_CharT, size_type)):
Revert last change to use std::min: machine language is worse.
(find_last_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(_CharT, size_type)): Ditto.
* include/bits/basic_string.tcc (insert(size_type, const _CharT*,
size_type)): Discard the value returned by _M_check.
(replace(size_type, size_type, const _CharT*, size_type)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76514
2004-01-24 17:52:04 +01:00
|
|
|
while (__size--);
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
|
|
|
return npos;
|
|
|
|
}
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
int
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
compare(size_type __pos, size_type __n, const basic_string& __str) const
|
|
|
|
{
|
basic_string.tcc (rfind(_CharT, size_type)): Revert last change to use std::min: machine language is worse.
2004-01-24 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.tcc (rfind(_CharT, size_type)):
Revert last change to use std::min: machine language is worse.
(find_last_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(_CharT, size_type)): Ditto.
* include/bits/basic_string.tcc (insert(size_type, const _CharT*,
size_type)): Discard the value returned by _M_check.
(replace(size_type, size_type, const _CharT*, size_type)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76514
2004-01-24 17:52:04 +01:00
|
|
|
_M_check(__pos, "basic_string::compare");
|
basic_string.h (_M_check): Change to return a checked __pos and take an additional const char* argument.
2004-01-21 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_M_check): Change to return
a checked __pos and take an additional const char* argument.
(_M_fold): Rename to _M_limit, change to return a size_type,
corresponding to the __off limited to the actual length.
(insert(size_type, size_type, _CharT)): Update call, call
replace.
(insert(iterator, _CharT)): Call replace(iterator, iterator,
size_type, _CharT) instead.
(erase(size_type, size_type)): Update calls.
(replace(size_type, size_type, size_type, _CharT)): Ditto.
(substr(size_type, size_type)): Use _M_check.
* include/bits/basic_string.tcc (basic_string(const basic_string&,
size_type, size_type)): Update calls.
(basic_string(const basic_string&, size_type, size_type,
const _Alloc&)): Ditto.
(assign(const basic_string&, size_type, size_type)): Use the
new _M_check and _M_limit.
(insert(size_type, const basic_string&, size_type, size_type):
Ditto.
(insert(size_type, const _CharT*, size_type)): Ditto.
(replace(size_type, size_type, const _CharT*, size_type): Ditto.
(replace(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(append(const basic_string&)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,size_type,
size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76274
2004-01-21 12:29:51 +01:00
|
|
|
__n = _M_limit(__pos, __n);
|
basic_string.h (_M_fold, [...]): Constify various variables.
2003-06-04 Paolo Carlini <pcarlini@unitus.it>
* include/bits/basic_string.h (_M_fold, insert(iterator, _CharT),
erase(iterator), erase(iterator, iterator), c_str,
compare(const basic_string&)): Constify various variables.
* include/bits/basic_string.tcc (_S_construct(_InIter, _InIter,
const _Alloc&, input_iterator_tag), _M_destroy, _M_mutate,
_S_create, resize, _M_replace, _M_replace_safe,
append(const basic_string&), append(const basic_string&, size_type,
size_type), append(const _CharT*, size_type), append(size_type,
_CharT), operator+(const _CharT*, const basic_string&),
operator+(_CharT, const basic_string&), replace(iterator, iterator,
size_type, _CharT), find(const _CharT*, size_type, size_type),
find(_CharT, size_type), rfind(const _CharT*, size_type, size_type),
rfind(_CharT, size_type), compare(size_type, size_type,
const basic_string&), compare(size_type, size_type,
const basic_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
From-SVN: r67468
2003-06-05 00:53:05 +02:00
|
|
|
const size_type __osize = __str.size();
|
basic_string.h (_M_check): Change to return a checked __pos and take an additional const char* argument.
2004-01-21 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_M_check): Change to return
a checked __pos and take an additional const char* argument.
(_M_fold): Rename to _M_limit, change to return a size_type,
corresponding to the __off limited to the actual length.
(insert(size_type, size_type, _CharT)): Update call, call
replace.
(insert(iterator, _CharT)): Call replace(iterator, iterator,
size_type, _CharT) instead.
(erase(size_type, size_type)): Update calls.
(replace(size_type, size_type, size_type, _CharT)): Ditto.
(substr(size_type, size_type)): Use _M_check.
* include/bits/basic_string.tcc (basic_string(const basic_string&,
size_type, size_type)): Update calls.
(basic_string(const basic_string&, size_type, size_type,
const _Alloc&)): Ditto.
(assign(const basic_string&, size_type, size_type)): Use the
new _M_check and _M_limit.
(insert(size_type, const basic_string&, size_type, size_type):
Ditto.
(insert(size_type, const _CharT*, size_type)): Ditto.
(replace(size_type, size_type, const _CharT*, size_type): Ditto.
(replace(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(append(const basic_string&)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,size_type,
size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76274
2004-01-21 12:29:51 +01:00
|
|
|
const size_type __len = std::min(__n, __osize);
|
2000-10-05 13:27:02 +02:00
|
|
|
int __r = traits_type::compare(_M_data() + __pos, __str.data(), __len);
|
|
|
|
if (!__r)
|
basic_string.h (basic_string<>::_S_compare): Add.
2007-01-18 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (basic_string<>::_S_compare): Add.
(compare(const basic_string&)): Use it.
* include/bits/basic_string.tcc (compare(size_type, size_type,
const basic_string&), compare(size_type, size_type,
const basic_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
* include/ext/vstring_util.h (__vstring_utility<>::_S_compare): Add.
* include/ext/vstring.h (compare(const __versa_string&)): Use it.
* include/ext/vstring.tcc (compare(size_type, size_type,
const __versa_string&), compare(size_type, size_type,
const __versa_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
From-SVN: r120896
2007-01-18 13:03:35 +01:00
|
|
|
__r = _S_compare(__n, __osize);
|
2000-10-05 13:27:02 +02:00
|
|
|
return __r;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
int
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
compare(size_type __pos1, size_type __n1, const basic_string& __str,
|
|
|
|
size_type __pos2, size_type __n2) const
|
|
|
|
{
|
basic_string.tcc (rfind(_CharT, size_type)): Revert last change to use std::min: machine language is worse.
2004-01-24 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.tcc (rfind(_CharT, size_type)):
Revert last change to use std::min: machine language is worse.
(find_last_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(_CharT, size_type)): Ditto.
* include/bits/basic_string.tcc (insert(size_type, const _CharT*,
size_type)): Discard the value returned by _M_check.
(replace(size_type, size_type, const _CharT*, size_type)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76514
2004-01-24 17:52:04 +01:00
|
|
|
_M_check(__pos1, "basic_string::compare");
|
|
|
|
__str._M_check(__pos2, "basic_string::compare");
|
basic_string.h (_M_check): Change to return a checked __pos and take an additional const char* argument.
2004-01-21 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_M_check): Change to return
a checked __pos and take an additional const char* argument.
(_M_fold): Rename to _M_limit, change to return a size_type,
corresponding to the __off limited to the actual length.
(insert(size_type, size_type, _CharT)): Update call, call
replace.
(insert(iterator, _CharT)): Call replace(iterator, iterator,
size_type, _CharT) instead.
(erase(size_type, size_type)): Update calls.
(replace(size_type, size_type, size_type, _CharT)): Ditto.
(substr(size_type, size_type)): Use _M_check.
* include/bits/basic_string.tcc (basic_string(const basic_string&,
size_type, size_type)): Update calls.
(basic_string(const basic_string&, size_type, size_type,
const _Alloc&)): Ditto.
(assign(const basic_string&, size_type, size_type)): Use the
new _M_check and _M_limit.
(insert(size_type, const basic_string&, size_type, size_type):
Ditto.
(insert(size_type, const _CharT*, size_type)): Ditto.
(replace(size_type, size_type, const _CharT*, size_type): Ditto.
(replace(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(append(const basic_string&)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,size_type,
size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76274
2004-01-21 12:29:51 +01:00
|
|
|
__n1 = _M_limit(__pos1, __n1);
|
|
|
|
__n2 = __str._M_limit(__pos2, __n2);
|
|
|
|
const size_type __len = std::min(__n1, __n2);
|
2004-02-08 05:46:42 +01:00
|
|
|
int __r = traits_type::compare(_M_data() + __pos1,
|
2000-10-05 13:27:02 +02:00
|
|
|
__str.data() + __pos2, __len);
|
|
|
|
if (!__r)
|
basic_string.h (basic_string<>::_S_compare): Add.
2007-01-18 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (basic_string<>::_S_compare): Add.
(compare(const basic_string&)): Use it.
* include/bits/basic_string.tcc (compare(size_type, size_type,
const basic_string&), compare(size_type, size_type,
const basic_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
* include/ext/vstring_util.h (__vstring_utility<>::_S_compare): Add.
* include/ext/vstring.h (compare(const __versa_string&)): Use it.
* include/ext/vstring.tcc (compare(size_type, size_type,
const __versa_string&), compare(size_type, size_type,
const __versa_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
From-SVN: r120896
2007-01-18 13:03:35 +01:00
|
|
|
__r = _S_compare(__n1, __n2);
|
2000-10-05 13:27:02 +02:00
|
|
|
return __r;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
int
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>::
|
|
|
|
compare(const _CharT* __s) const
|
|
|
|
{
|
2003-11-11 21:09:16 +01:00
|
|
|
__glibcxx_requires_string(__s);
|
basic_string.h (_M_fold, [...]): Constify various variables.
2003-06-04 Paolo Carlini <pcarlini@unitus.it>
* include/bits/basic_string.h (_M_fold, insert(iterator, _CharT),
erase(iterator), erase(iterator, iterator), c_str,
compare(const basic_string&)): Constify various variables.
* include/bits/basic_string.tcc (_S_construct(_InIter, _InIter,
const _Alloc&, input_iterator_tag), _M_destroy, _M_mutate,
_S_create, resize, _M_replace, _M_replace_safe,
append(const basic_string&), append(const basic_string&, size_type,
size_type), append(const _CharT*, size_type), append(size_type,
_CharT), operator+(const _CharT*, const basic_string&),
operator+(_CharT, const basic_string&), replace(iterator, iterator,
size_type, _CharT), find(const _CharT*, size_type, size_type),
find(_CharT, size_type), rfind(const _CharT*, size_type, size_type),
rfind(_CharT, size_type), compare(size_type, size_type,
const basic_string&), compare(size_type, size_type,
const basic_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
From-SVN: r67468
2003-06-05 00:53:05 +02:00
|
|
|
const size_type __size = this->size();
|
|
|
|
const size_type __osize = traits_type::length(__s);
|
|
|
|
const size_type __len = std::min(__size, __osize);
|
2002-11-01 16:21:17 +01:00
|
|
|
int __r = traits_type::compare(_M_data(), __s, __len);
|
2000-10-05 13:27:02 +02:00
|
|
|
if (!__r)
|
basic_string.h (basic_string<>::_S_compare): Add.
2007-01-18 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (basic_string<>::_S_compare): Add.
(compare(const basic_string&)): Use it.
* include/bits/basic_string.tcc (compare(size_type, size_type,
const basic_string&), compare(size_type, size_type,
const basic_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
* include/ext/vstring_util.h (__vstring_utility<>::_S_compare): Add.
* include/ext/vstring.h (compare(const __versa_string&)): Use it.
* include/ext/vstring.tcc (compare(size_type, size_type,
const __versa_string&), compare(size_type, size_type,
const __versa_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
From-SVN: r120896
2007-01-18 13:03:35 +01:00
|
|
|
__r = _S_compare(__size, __osize);
|
2000-10-05 13:27:02 +02:00
|
|
|
return __r;
|
|
|
|
}
|
|
|
|
|
2001-06-12 04:30:37 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
int
|
2001-10-31 09:27:20 +01:00
|
|
|
basic_string <_CharT, _Traits, _Alloc>::
|
2001-06-12 04:30:37 +02:00
|
|
|
compare(size_type __pos, size_type __n1, const _CharT* __s) const
|
|
|
|
{
|
2003-11-11 21:09:16 +01:00
|
|
|
__glibcxx_requires_string(__s);
|
basic_string.tcc (rfind(_CharT, size_type)): Revert last change to use std::min: machine language is worse.
2004-01-24 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.tcc (rfind(_CharT, size_type)):
Revert last change to use std::min: machine language is worse.
(find_last_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(_CharT, size_type)): Ditto.
* include/bits/basic_string.tcc (insert(size_type, const _CharT*,
size_type)): Discard the value returned by _M_check.
(replace(size_type, size_type, const _CharT*, size_type)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76514
2004-01-24 17:52:04 +01:00
|
|
|
_M_check(__pos, "basic_string::compare");
|
basic_string.h (_M_check): Change to return a checked __pos and take an additional const char* argument.
2004-01-21 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_M_check): Change to return
a checked __pos and take an additional const char* argument.
(_M_fold): Rename to _M_limit, change to return a size_type,
corresponding to the __off limited to the actual length.
(insert(size_type, size_type, _CharT)): Update call, call
replace.
(insert(iterator, _CharT)): Call replace(iterator, iterator,
size_type, _CharT) instead.
(erase(size_type, size_type)): Update calls.
(replace(size_type, size_type, size_type, _CharT)): Ditto.
(substr(size_type, size_type)): Use _M_check.
* include/bits/basic_string.tcc (basic_string(const basic_string&,
size_type, size_type)): Update calls.
(basic_string(const basic_string&, size_type, size_type,
const _Alloc&)): Ditto.
(assign(const basic_string&, size_type, size_type)): Use the
new _M_check and _M_limit.
(insert(size_type, const basic_string&, size_type, size_type):
Ditto.
(insert(size_type, const _CharT*, size_type)): Ditto.
(replace(size_type, size_type, const _CharT*, size_type): Ditto.
(replace(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(append(const basic_string&)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,size_type,
size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76274
2004-01-21 12:29:51 +01:00
|
|
|
__n1 = _M_limit(__pos, __n1);
|
basic_string.h (_M_fold, [...]): Constify various variables.
2003-06-04 Paolo Carlini <pcarlini@unitus.it>
* include/bits/basic_string.h (_M_fold, insert(iterator, _CharT),
erase(iterator), erase(iterator, iterator), c_str,
compare(const basic_string&)): Constify various variables.
* include/bits/basic_string.tcc (_S_construct(_InIter, _InIter,
const _Alloc&, input_iterator_tag), _M_destroy, _M_mutate,
_S_create, resize, _M_replace, _M_replace_safe,
append(const basic_string&), append(const basic_string&, size_type,
size_type), append(const _CharT*, size_type), append(size_type,
_CharT), operator+(const _CharT*, const basic_string&),
operator+(_CharT, const basic_string&), replace(iterator, iterator,
size_type, _CharT), find(const _CharT*, size_type, size_type),
find(_CharT, size_type), rfind(const _CharT*, size_type, size_type),
rfind(_CharT, size_type), compare(size_type, size_type,
const basic_string&), compare(size_type, size_type,
const basic_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
From-SVN: r67468
2003-06-05 00:53:05 +02:00
|
|
|
const size_type __osize = traits_type::length(__s);
|
basic_string.h (_M_check): Change to return a checked __pos and take an additional const char* argument.
2004-01-21 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_M_check): Change to return
a checked __pos and take an additional const char* argument.
(_M_fold): Rename to _M_limit, change to return a size_type,
corresponding to the __off limited to the actual length.
(insert(size_type, size_type, _CharT)): Update call, call
replace.
(insert(iterator, _CharT)): Call replace(iterator, iterator,
size_type, _CharT) instead.
(erase(size_type, size_type)): Update calls.
(replace(size_type, size_type, size_type, _CharT)): Ditto.
(substr(size_type, size_type)): Use _M_check.
* include/bits/basic_string.tcc (basic_string(const basic_string&,
size_type, size_type)): Update calls.
(basic_string(const basic_string&, size_type, size_type,
const _Alloc&)): Ditto.
(assign(const basic_string&, size_type, size_type)): Use the
new _M_check and _M_limit.
(insert(size_type, const basic_string&, size_type, size_type):
Ditto.
(insert(size_type, const _CharT*, size_type)): Ditto.
(replace(size_type, size_type, const _CharT*, size_type): Ditto.
(replace(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(append(const basic_string&)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,size_type,
size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76274
2004-01-21 12:29:51 +01:00
|
|
|
const size_type __len = std::min(__n1, __osize);
|
2001-06-12 04:30:37 +02:00
|
|
|
int __r = traits_type::compare(_M_data() + __pos, __s, __len);
|
|
|
|
if (!__r)
|
basic_string.h (basic_string<>::_S_compare): Add.
2007-01-18 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (basic_string<>::_S_compare): Add.
(compare(const basic_string&)): Use it.
* include/bits/basic_string.tcc (compare(size_type, size_type,
const basic_string&), compare(size_type, size_type,
const basic_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
* include/ext/vstring_util.h (__vstring_utility<>::_S_compare): Add.
* include/ext/vstring.h (compare(const __versa_string&)): Use it.
* include/ext/vstring.tcc (compare(size_type, size_type,
const __versa_string&), compare(size_type, size_type,
const __versa_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
From-SVN: r120896
2007-01-18 13:03:35 +01:00
|
|
|
__r = _S_compare(__n1, __osize);
|
2001-06-12 04:30:37 +02:00
|
|
|
return __r;
|
|
|
|
}
|
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
int
|
2001-10-31 09:27:20 +01:00
|
|
|
basic_string <_CharT, _Traits, _Alloc>::
|
2004-02-08 05:46:42 +01:00
|
|
|
compare(size_type __pos, size_type __n1, const _CharT* __s,
|
2000-10-05 13:27:02 +02:00
|
|
|
size_type __n2) const
|
|
|
|
{
|
2003-11-11 21:09:16 +01:00
|
|
|
__glibcxx_requires_string_len(__s, __n2);
|
basic_string.tcc (rfind(_CharT, size_type)): Revert last change to use std::min: machine language is worse.
2004-01-24 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.tcc (rfind(_CharT, size_type)):
Revert last change to use std::min: machine language is worse.
(find_last_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(_CharT, size_type)): Ditto.
* include/bits/basic_string.tcc (insert(size_type, const _CharT*,
size_type)): Discard the value returned by _M_check.
(replace(size_type, size_type, const _CharT*, size_type)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76514
2004-01-24 17:52:04 +01:00
|
|
|
_M_check(__pos, "basic_string::compare");
|
basic_string.h (_M_check): Change to return a checked __pos and take an additional const char* argument.
2004-01-21 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_M_check): Change to return
a checked __pos and take an additional const char* argument.
(_M_fold): Rename to _M_limit, change to return a size_type,
corresponding to the __off limited to the actual length.
(insert(size_type, size_type, _CharT)): Update call, call
replace.
(insert(iterator, _CharT)): Call replace(iterator, iterator,
size_type, _CharT) instead.
(erase(size_type, size_type)): Update calls.
(replace(size_type, size_type, size_type, _CharT)): Ditto.
(substr(size_type, size_type)): Use _M_check.
* include/bits/basic_string.tcc (basic_string(const basic_string&,
size_type, size_type)): Update calls.
(basic_string(const basic_string&, size_type, size_type,
const _Alloc&)): Ditto.
(assign(const basic_string&, size_type, size_type)): Use the
new _M_check and _M_limit.
(insert(size_type, const basic_string&, size_type, size_type):
Ditto.
(insert(size_type, const _CharT*, size_type)): Ditto.
(replace(size_type, size_type, const _CharT*, size_type): Ditto.
(replace(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(append(const basic_string&)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,size_type,
size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76274
2004-01-21 12:29:51 +01:00
|
|
|
__n1 = _M_limit(__pos, __n1);
|
|
|
|
const size_type __len = std::min(__n1, __n2);
|
2000-10-05 13:27:02 +02:00
|
|
|
int __r = traits_type::compare(_M_data() + __pos, __s, __len);
|
|
|
|
if (!__r)
|
basic_string.h (basic_string<>::_S_compare): Add.
2007-01-18 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (basic_string<>::_S_compare): Add.
(compare(const basic_string&)): Use it.
* include/bits/basic_string.tcc (compare(size_type, size_type,
const basic_string&), compare(size_type, size_type,
const basic_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
* include/ext/vstring_util.h (__vstring_utility<>::_S_compare): Add.
* include/ext/vstring.h (compare(const __versa_string&)): Use it.
* include/ext/vstring.tcc (compare(size_type, size_type,
const __versa_string&), compare(size_type, size_type,
const __versa_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
From-SVN: r120896
2007-01-18 13:03:35 +01:00
|
|
|
__r = _S_compare(__n1, __n2);
|
2000-10-05 13:27:02 +02:00
|
|
|
return __r;
|
|
|
|
}
|
|
|
|
|
PR libstdc++/28277 (partial: vstring bits)
2007-04-10 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/28277 (partial: vstring bits)
* include/bits/ostream_insert.h: New.
* include/Makefile.am: Add.
* include/ext/vstring.h (operator<<(basic_ostream<>&,
const __versa_string<>&): Forward to __ostream_insert.
* include/bits/basic_string.h (operator<<(basic_ostream<>&,
const string<>&)): Likewise.
* include/std/ostream (operator<<(basic_ostream<>&, _CharT),
operator<<(basic_ostream<char,>&, char), operator<<(basic_ostream<>&,
const _CharT*), operator<<(basic_ostream<char,>&, const char*)):
Likewise.
* include/ext/vstring.tcc (operator<<(basic_ostream<>&,
const __versa_string<>&)): Remove.
(class basic_ostream): Remove friend declarations.
(basic_ostream<>::_M_write(char_type, streamsize),
_M_insert(const char_type*, streamsize)): Remove.
* include/bits/ostream.tcc (_M_insert(const char_type*, streamsize)):
Remove definition.
(operator<<(basic_ostream<>&, const char*)): Use __ostream_insert.
* config/abi/pre/gnu.ver: Adjust.
* src/ostream-inst.cc: Add __ostream_insert instantiations.
* include/bits/locale_facets.h (__pad<>::_S_pad): Remove __num
parameter.
* include/bits/locale_facets.tcc (__pad<>::_S_pad): Adjust.
(num_put<>::_M_pad(_CharT, streamsize, ios_base&, _CharT*,
const _CharT*, int&)): Likewise.
* include/Makefile.in: Rebuild.
* testsuite/ext/vstring/inserters_extractors/char/28277.cc: New.
* testsuite/ext/vstring/inserters_extractors/wchar_t/28277.cc: New.
* include/ext/vstring_util.h: Do not include the whole <locale>.
* include/ext/vstring.tcc (operator>>(basic_istream<>&,
__versa_string<>&, getline(basic_istream<>&, __versa_string<>&,
_CharT)): Tweak to refer to ios_base as a base of istream; do not
refer to non-standard types of istream.
* include/bits/istream.tcc (operator>>(basic_istream<>&, _CharT*),
ws(basic_istream<>&)): Do not refer to non-standard types of istream.
* include/std/bitset (operator>>(std::basic_istream<>&, bitset<>&)):
Avoid using basic_streambuf<>*.
* include/bits/istream.tcc (operator>>(basic_istream<>&,
basic_string<>&), getline(basic_istream<>&, basic_string<>&, _CharT)):
Move...
* include/bits/basic_string.tcc: ... here; tweak to refer to ios_base
as a base of istream; do not refer to non-standard types of istream.
* include/std/string: Tweak includes.
* include/ext/type_traits.h (__is_null_pointer): Add.
* include/ext/rc_string_base.h: Use it.
* include/ext/sso_string_base.h: Likewise.
* include/bits/basic_string.tcc (__is_null_pointer): Remove, use
the above.
* include/ext/vstring_util.h (__vstring_utility<>::_S_is_null_pointer):
Remove.
From-SVN: r123692
2007-04-10 12:38:50 +02:00
|
|
|
// 21.3.7.9 basic_string::getline and operators
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
basic_istream<_CharT, _Traits>&
|
|
|
|
operator>>(basic_istream<_CharT, _Traits>& __in,
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>& __str)
|
|
|
|
{
|
|
|
|
typedef basic_istream<_CharT, _Traits> __istream_type;
|
|
|
|
typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
|
|
|
|
typedef typename __istream_type::ios_base __ios_base;
|
|
|
|
typedef typename __istream_type::int_type __int_type;
|
|
|
|
typedef typename __string_type::size_type __size_type;
|
|
|
|
typedef ctype<_CharT> __ctype_type;
|
|
|
|
typedef typename __ctype_type::ctype_base __ctype_base;
|
|
|
|
|
|
|
|
__size_type __extracted = 0;
|
|
|
|
typename __ios_base::iostate __err = __ios_base::goodbit;
|
|
|
|
typename __istream_type::sentry __cerb(__in, false);
|
2009-09-05 02:18:07 +02:00
|
|
|
if (__cerb)
|
PR libstdc++/28277 (partial: vstring bits)
2007-04-10 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/28277 (partial: vstring bits)
* include/bits/ostream_insert.h: New.
* include/Makefile.am: Add.
* include/ext/vstring.h (operator<<(basic_ostream<>&,
const __versa_string<>&): Forward to __ostream_insert.
* include/bits/basic_string.h (operator<<(basic_ostream<>&,
const string<>&)): Likewise.
* include/std/ostream (operator<<(basic_ostream<>&, _CharT),
operator<<(basic_ostream<char,>&, char), operator<<(basic_ostream<>&,
const _CharT*), operator<<(basic_ostream<char,>&, const char*)):
Likewise.
* include/ext/vstring.tcc (operator<<(basic_ostream<>&,
const __versa_string<>&)): Remove.
(class basic_ostream): Remove friend declarations.
(basic_ostream<>::_M_write(char_type, streamsize),
_M_insert(const char_type*, streamsize)): Remove.
* include/bits/ostream.tcc (_M_insert(const char_type*, streamsize)):
Remove definition.
(operator<<(basic_ostream<>&, const char*)): Use __ostream_insert.
* config/abi/pre/gnu.ver: Adjust.
* src/ostream-inst.cc: Add __ostream_insert instantiations.
* include/bits/locale_facets.h (__pad<>::_S_pad): Remove __num
parameter.
* include/bits/locale_facets.tcc (__pad<>::_S_pad): Adjust.
(num_put<>::_M_pad(_CharT, streamsize, ios_base&, _CharT*,
const _CharT*, int&)): Likewise.
* include/Makefile.in: Rebuild.
* testsuite/ext/vstring/inserters_extractors/char/28277.cc: New.
* testsuite/ext/vstring/inserters_extractors/wchar_t/28277.cc: New.
* include/ext/vstring_util.h: Do not include the whole <locale>.
* include/ext/vstring.tcc (operator>>(basic_istream<>&,
__versa_string<>&, getline(basic_istream<>&, __versa_string<>&,
_CharT)): Tweak to refer to ios_base as a base of istream; do not
refer to non-standard types of istream.
* include/bits/istream.tcc (operator>>(basic_istream<>&, _CharT*),
ws(basic_istream<>&)): Do not refer to non-standard types of istream.
* include/std/bitset (operator>>(std::basic_istream<>&, bitset<>&)):
Avoid using basic_streambuf<>*.
* include/bits/istream.tcc (operator>>(basic_istream<>&,
basic_string<>&), getline(basic_istream<>&, basic_string<>&, _CharT)):
Move...
* include/bits/basic_string.tcc: ... here; tweak to refer to ios_base
as a base of istream; do not refer to non-standard types of istream.
* include/std/string: Tweak includes.
* include/ext/type_traits.h (__is_null_pointer): Add.
* include/ext/rc_string_base.h: Use it.
* include/ext/sso_string_base.h: Likewise.
* include/bits/basic_string.tcc (__is_null_pointer): Remove, use
the above.
* include/ext/vstring_util.h (__vstring_utility<>::_S_is_null_pointer):
Remove.
From-SVN: r123692
2007-04-10 12:38:50 +02:00
|
|
|
{
|
2009-02-04 00:44:53 +01:00
|
|
|
__try
|
PR libstdc++/28277 (partial: vstring bits)
2007-04-10 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/28277 (partial: vstring bits)
* include/bits/ostream_insert.h: New.
* include/Makefile.am: Add.
* include/ext/vstring.h (operator<<(basic_ostream<>&,
const __versa_string<>&): Forward to __ostream_insert.
* include/bits/basic_string.h (operator<<(basic_ostream<>&,
const string<>&)): Likewise.
* include/std/ostream (operator<<(basic_ostream<>&, _CharT),
operator<<(basic_ostream<char,>&, char), operator<<(basic_ostream<>&,
const _CharT*), operator<<(basic_ostream<char,>&, const char*)):
Likewise.
* include/ext/vstring.tcc (operator<<(basic_ostream<>&,
const __versa_string<>&)): Remove.
(class basic_ostream): Remove friend declarations.
(basic_ostream<>::_M_write(char_type, streamsize),
_M_insert(const char_type*, streamsize)): Remove.
* include/bits/ostream.tcc (_M_insert(const char_type*, streamsize)):
Remove definition.
(operator<<(basic_ostream<>&, const char*)): Use __ostream_insert.
* config/abi/pre/gnu.ver: Adjust.
* src/ostream-inst.cc: Add __ostream_insert instantiations.
* include/bits/locale_facets.h (__pad<>::_S_pad): Remove __num
parameter.
* include/bits/locale_facets.tcc (__pad<>::_S_pad): Adjust.
(num_put<>::_M_pad(_CharT, streamsize, ios_base&, _CharT*,
const _CharT*, int&)): Likewise.
* include/Makefile.in: Rebuild.
* testsuite/ext/vstring/inserters_extractors/char/28277.cc: New.
* testsuite/ext/vstring/inserters_extractors/wchar_t/28277.cc: New.
* include/ext/vstring_util.h: Do not include the whole <locale>.
* include/ext/vstring.tcc (operator>>(basic_istream<>&,
__versa_string<>&, getline(basic_istream<>&, __versa_string<>&,
_CharT)): Tweak to refer to ios_base as a base of istream; do not
refer to non-standard types of istream.
* include/bits/istream.tcc (operator>>(basic_istream<>&, _CharT*),
ws(basic_istream<>&)): Do not refer to non-standard types of istream.
* include/std/bitset (operator>>(std::basic_istream<>&, bitset<>&)):
Avoid using basic_streambuf<>*.
* include/bits/istream.tcc (operator>>(basic_istream<>&,
basic_string<>&), getline(basic_istream<>&, basic_string<>&, _CharT)):
Move...
* include/bits/basic_string.tcc: ... here; tweak to refer to ios_base
as a base of istream; do not refer to non-standard types of istream.
* include/std/string: Tweak includes.
* include/ext/type_traits.h (__is_null_pointer): Add.
* include/ext/rc_string_base.h: Use it.
* include/ext/sso_string_base.h: Likewise.
* include/bits/basic_string.tcc (__is_null_pointer): Remove, use
the above.
* include/ext/vstring_util.h (__vstring_utility<>::_S_is_null_pointer):
Remove.
From-SVN: r123692
2007-04-10 12:38:50 +02:00
|
|
|
{
|
|
|
|
// Avoid reallocation for common case.
|
|
|
|
__str.erase();
|
|
|
|
_CharT __buf[128];
|
|
|
|
__size_type __len = 0;
|
|
|
|
const streamsize __w = __in.width();
|
|
|
|
const __size_type __n = __w > 0 ? static_cast<__size_type>(__w)
|
|
|
|
: __str.max_size();
|
|
|
|
const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc());
|
|
|
|
const __int_type __eof = _Traits::eof();
|
|
|
|
__int_type __c = __in.rdbuf()->sgetc();
|
|
|
|
|
|
|
|
while (__extracted < __n
|
|
|
|
&& !_Traits::eq_int_type(__c, __eof)
|
|
|
|
&& !__ct.is(__ctype_base::space,
|
|
|
|
_Traits::to_char_type(__c)))
|
|
|
|
{
|
|
|
|
if (__len == sizeof(__buf) / sizeof(_CharT))
|
|
|
|
{
|
|
|
|
__str.append(__buf, sizeof(__buf) / sizeof(_CharT));
|
|
|
|
__len = 0;
|
|
|
|
}
|
|
|
|
__buf[__len++] = _Traits::to_char_type(__c);
|
|
|
|
++__extracted;
|
|
|
|
__c = __in.rdbuf()->snextc();
|
|
|
|
}
|
|
|
|
__str.append(__buf, __len);
|
|
|
|
|
|
|
|
if (_Traits::eq_int_type(__c, __eof))
|
|
|
|
__err |= __ios_base::eofbit;
|
|
|
|
__in.width(0);
|
|
|
|
}
|
2009-02-04 00:44:53 +01:00
|
|
|
__catch(__cxxabiv1::__forced_unwind&)
|
2007-05-07 23:27:54 +02:00
|
|
|
{
|
|
|
|
__in._M_setstate(__ios_base::badbit);
|
|
|
|
__throw_exception_again;
|
|
|
|
}
|
2009-02-04 00:44:53 +01:00
|
|
|
__catch(...)
|
PR libstdc++/28277 (partial: vstring bits)
2007-04-10 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/28277 (partial: vstring bits)
* include/bits/ostream_insert.h: New.
* include/Makefile.am: Add.
* include/ext/vstring.h (operator<<(basic_ostream<>&,
const __versa_string<>&): Forward to __ostream_insert.
* include/bits/basic_string.h (operator<<(basic_ostream<>&,
const string<>&)): Likewise.
* include/std/ostream (operator<<(basic_ostream<>&, _CharT),
operator<<(basic_ostream<char,>&, char), operator<<(basic_ostream<>&,
const _CharT*), operator<<(basic_ostream<char,>&, const char*)):
Likewise.
* include/ext/vstring.tcc (operator<<(basic_ostream<>&,
const __versa_string<>&)): Remove.
(class basic_ostream): Remove friend declarations.
(basic_ostream<>::_M_write(char_type, streamsize),
_M_insert(const char_type*, streamsize)): Remove.
* include/bits/ostream.tcc (_M_insert(const char_type*, streamsize)):
Remove definition.
(operator<<(basic_ostream<>&, const char*)): Use __ostream_insert.
* config/abi/pre/gnu.ver: Adjust.
* src/ostream-inst.cc: Add __ostream_insert instantiations.
* include/bits/locale_facets.h (__pad<>::_S_pad): Remove __num
parameter.
* include/bits/locale_facets.tcc (__pad<>::_S_pad): Adjust.
(num_put<>::_M_pad(_CharT, streamsize, ios_base&, _CharT*,
const _CharT*, int&)): Likewise.
* include/Makefile.in: Rebuild.
* testsuite/ext/vstring/inserters_extractors/char/28277.cc: New.
* testsuite/ext/vstring/inserters_extractors/wchar_t/28277.cc: New.
* include/ext/vstring_util.h: Do not include the whole <locale>.
* include/ext/vstring.tcc (operator>>(basic_istream<>&,
__versa_string<>&, getline(basic_istream<>&, __versa_string<>&,
_CharT)): Tweak to refer to ios_base as a base of istream; do not
refer to non-standard types of istream.
* include/bits/istream.tcc (operator>>(basic_istream<>&, _CharT*),
ws(basic_istream<>&)): Do not refer to non-standard types of istream.
* include/std/bitset (operator>>(std::basic_istream<>&, bitset<>&)):
Avoid using basic_streambuf<>*.
* include/bits/istream.tcc (operator>>(basic_istream<>&,
basic_string<>&), getline(basic_istream<>&, basic_string<>&, _CharT)):
Move...
* include/bits/basic_string.tcc: ... here; tweak to refer to ios_base
as a base of istream; do not refer to non-standard types of istream.
* include/std/string: Tweak includes.
* include/ext/type_traits.h (__is_null_pointer): Add.
* include/ext/rc_string_base.h: Use it.
* include/ext/sso_string_base.h: Likewise.
* include/bits/basic_string.tcc (__is_null_pointer): Remove, use
the above.
* include/ext/vstring_util.h (__vstring_utility<>::_S_is_null_pointer):
Remove.
From-SVN: r123692
2007-04-10 12:38:50 +02:00
|
|
|
{
|
|
|
|
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
|
|
// 91. Description of operator>> and getline() for string<>
|
|
|
|
// might cause endless loop
|
|
|
|
__in._M_setstate(__ios_base::badbit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 211. operator>>(istream&, string&) doesn't set failbit
|
|
|
|
if (!__extracted)
|
|
|
|
__err |= __ios_base::failbit;
|
|
|
|
if (__err)
|
|
|
|
__in.setstate(__err);
|
|
|
|
return __in;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
basic_istream<_CharT, _Traits>&
|
|
|
|
getline(basic_istream<_CharT, _Traits>& __in,
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim)
|
|
|
|
{
|
|
|
|
typedef basic_istream<_CharT, _Traits> __istream_type;
|
|
|
|
typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
|
|
|
|
typedef typename __istream_type::ios_base __ios_base;
|
|
|
|
typedef typename __istream_type::int_type __int_type;
|
|
|
|
typedef typename __string_type::size_type __size_type;
|
|
|
|
|
|
|
|
__size_type __extracted = 0;
|
|
|
|
const __size_type __n = __str.max_size();
|
|
|
|
typename __ios_base::iostate __err = __ios_base::goodbit;
|
|
|
|
typename __istream_type::sentry __cerb(__in, true);
|
2009-09-05 02:18:07 +02:00
|
|
|
if (__cerb)
|
PR libstdc++/28277 (partial: vstring bits)
2007-04-10 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/28277 (partial: vstring bits)
* include/bits/ostream_insert.h: New.
* include/Makefile.am: Add.
* include/ext/vstring.h (operator<<(basic_ostream<>&,
const __versa_string<>&): Forward to __ostream_insert.
* include/bits/basic_string.h (operator<<(basic_ostream<>&,
const string<>&)): Likewise.
* include/std/ostream (operator<<(basic_ostream<>&, _CharT),
operator<<(basic_ostream<char,>&, char), operator<<(basic_ostream<>&,
const _CharT*), operator<<(basic_ostream<char,>&, const char*)):
Likewise.
* include/ext/vstring.tcc (operator<<(basic_ostream<>&,
const __versa_string<>&)): Remove.
(class basic_ostream): Remove friend declarations.
(basic_ostream<>::_M_write(char_type, streamsize),
_M_insert(const char_type*, streamsize)): Remove.
* include/bits/ostream.tcc (_M_insert(const char_type*, streamsize)):
Remove definition.
(operator<<(basic_ostream<>&, const char*)): Use __ostream_insert.
* config/abi/pre/gnu.ver: Adjust.
* src/ostream-inst.cc: Add __ostream_insert instantiations.
* include/bits/locale_facets.h (__pad<>::_S_pad): Remove __num
parameter.
* include/bits/locale_facets.tcc (__pad<>::_S_pad): Adjust.
(num_put<>::_M_pad(_CharT, streamsize, ios_base&, _CharT*,
const _CharT*, int&)): Likewise.
* include/Makefile.in: Rebuild.
* testsuite/ext/vstring/inserters_extractors/char/28277.cc: New.
* testsuite/ext/vstring/inserters_extractors/wchar_t/28277.cc: New.
* include/ext/vstring_util.h: Do not include the whole <locale>.
* include/ext/vstring.tcc (operator>>(basic_istream<>&,
__versa_string<>&, getline(basic_istream<>&, __versa_string<>&,
_CharT)): Tweak to refer to ios_base as a base of istream; do not
refer to non-standard types of istream.
* include/bits/istream.tcc (operator>>(basic_istream<>&, _CharT*),
ws(basic_istream<>&)): Do not refer to non-standard types of istream.
* include/std/bitset (operator>>(std::basic_istream<>&, bitset<>&)):
Avoid using basic_streambuf<>*.
* include/bits/istream.tcc (operator>>(basic_istream<>&,
basic_string<>&), getline(basic_istream<>&, basic_string<>&, _CharT)):
Move...
* include/bits/basic_string.tcc: ... here; tweak to refer to ios_base
as a base of istream; do not refer to non-standard types of istream.
* include/std/string: Tweak includes.
* include/ext/type_traits.h (__is_null_pointer): Add.
* include/ext/rc_string_base.h: Use it.
* include/ext/sso_string_base.h: Likewise.
* include/bits/basic_string.tcc (__is_null_pointer): Remove, use
the above.
* include/ext/vstring_util.h (__vstring_utility<>::_S_is_null_pointer):
Remove.
From-SVN: r123692
2007-04-10 12:38:50 +02:00
|
|
|
{
|
2009-02-04 00:44:53 +01:00
|
|
|
__try
|
PR libstdc++/28277 (partial: vstring bits)
2007-04-10 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/28277 (partial: vstring bits)
* include/bits/ostream_insert.h: New.
* include/Makefile.am: Add.
* include/ext/vstring.h (operator<<(basic_ostream<>&,
const __versa_string<>&): Forward to __ostream_insert.
* include/bits/basic_string.h (operator<<(basic_ostream<>&,
const string<>&)): Likewise.
* include/std/ostream (operator<<(basic_ostream<>&, _CharT),
operator<<(basic_ostream<char,>&, char), operator<<(basic_ostream<>&,
const _CharT*), operator<<(basic_ostream<char,>&, const char*)):
Likewise.
* include/ext/vstring.tcc (operator<<(basic_ostream<>&,
const __versa_string<>&)): Remove.
(class basic_ostream): Remove friend declarations.
(basic_ostream<>::_M_write(char_type, streamsize),
_M_insert(const char_type*, streamsize)): Remove.
* include/bits/ostream.tcc (_M_insert(const char_type*, streamsize)):
Remove definition.
(operator<<(basic_ostream<>&, const char*)): Use __ostream_insert.
* config/abi/pre/gnu.ver: Adjust.
* src/ostream-inst.cc: Add __ostream_insert instantiations.
* include/bits/locale_facets.h (__pad<>::_S_pad): Remove __num
parameter.
* include/bits/locale_facets.tcc (__pad<>::_S_pad): Adjust.
(num_put<>::_M_pad(_CharT, streamsize, ios_base&, _CharT*,
const _CharT*, int&)): Likewise.
* include/Makefile.in: Rebuild.
* testsuite/ext/vstring/inserters_extractors/char/28277.cc: New.
* testsuite/ext/vstring/inserters_extractors/wchar_t/28277.cc: New.
* include/ext/vstring_util.h: Do not include the whole <locale>.
* include/ext/vstring.tcc (operator>>(basic_istream<>&,
__versa_string<>&, getline(basic_istream<>&, __versa_string<>&,
_CharT)): Tweak to refer to ios_base as a base of istream; do not
refer to non-standard types of istream.
* include/bits/istream.tcc (operator>>(basic_istream<>&, _CharT*),
ws(basic_istream<>&)): Do not refer to non-standard types of istream.
* include/std/bitset (operator>>(std::basic_istream<>&, bitset<>&)):
Avoid using basic_streambuf<>*.
* include/bits/istream.tcc (operator>>(basic_istream<>&,
basic_string<>&), getline(basic_istream<>&, basic_string<>&, _CharT)):
Move...
* include/bits/basic_string.tcc: ... here; tweak to refer to ios_base
as a base of istream; do not refer to non-standard types of istream.
* include/std/string: Tweak includes.
* include/ext/type_traits.h (__is_null_pointer): Add.
* include/ext/rc_string_base.h: Use it.
* include/ext/sso_string_base.h: Likewise.
* include/bits/basic_string.tcc (__is_null_pointer): Remove, use
the above.
* include/ext/vstring_util.h (__vstring_utility<>::_S_is_null_pointer):
Remove.
From-SVN: r123692
2007-04-10 12:38:50 +02:00
|
|
|
{
|
|
|
|
__str.erase();
|
|
|
|
const __int_type __idelim = _Traits::to_int_type(__delim);
|
|
|
|
const __int_type __eof = _Traits::eof();
|
|
|
|
__int_type __c = __in.rdbuf()->sgetc();
|
|
|
|
|
|
|
|
while (__extracted < __n
|
|
|
|
&& !_Traits::eq_int_type(__c, __eof)
|
|
|
|
&& !_Traits::eq_int_type(__c, __idelim))
|
|
|
|
{
|
|
|
|
__str += _Traits::to_char_type(__c);
|
|
|
|
++__extracted;
|
|
|
|
__c = __in.rdbuf()->snextc();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_Traits::eq_int_type(__c, __eof))
|
|
|
|
__err |= __ios_base::eofbit;
|
|
|
|
else if (_Traits::eq_int_type(__c, __idelim))
|
|
|
|
{
|
|
|
|
++__extracted;
|
|
|
|
__in.rdbuf()->sbumpc();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
__err |= __ios_base::failbit;
|
|
|
|
}
|
2009-02-04 00:44:53 +01:00
|
|
|
__catch(__cxxabiv1::__forced_unwind&)
|
2007-05-07 23:27:54 +02:00
|
|
|
{
|
|
|
|
__in._M_setstate(__ios_base::badbit);
|
|
|
|
__throw_exception_again;
|
|
|
|
}
|
2009-02-04 00:44:53 +01:00
|
|
|
__catch(...)
|
PR libstdc++/28277 (partial: vstring bits)
2007-04-10 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/28277 (partial: vstring bits)
* include/bits/ostream_insert.h: New.
* include/Makefile.am: Add.
* include/ext/vstring.h (operator<<(basic_ostream<>&,
const __versa_string<>&): Forward to __ostream_insert.
* include/bits/basic_string.h (operator<<(basic_ostream<>&,
const string<>&)): Likewise.
* include/std/ostream (operator<<(basic_ostream<>&, _CharT),
operator<<(basic_ostream<char,>&, char), operator<<(basic_ostream<>&,
const _CharT*), operator<<(basic_ostream<char,>&, const char*)):
Likewise.
* include/ext/vstring.tcc (operator<<(basic_ostream<>&,
const __versa_string<>&)): Remove.
(class basic_ostream): Remove friend declarations.
(basic_ostream<>::_M_write(char_type, streamsize),
_M_insert(const char_type*, streamsize)): Remove.
* include/bits/ostream.tcc (_M_insert(const char_type*, streamsize)):
Remove definition.
(operator<<(basic_ostream<>&, const char*)): Use __ostream_insert.
* config/abi/pre/gnu.ver: Adjust.
* src/ostream-inst.cc: Add __ostream_insert instantiations.
* include/bits/locale_facets.h (__pad<>::_S_pad): Remove __num
parameter.
* include/bits/locale_facets.tcc (__pad<>::_S_pad): Adjust.
(num_put<>::_M_pad(_CharT, streamsize, ios_base&, _CharT*,
const _CharT*, int&)): Likewise.
* include/Makefile.in: Rebuild.
* testsuite/ext/vstring/inserters_extractors/char/28277.cc: New.
* testsuite/ext/vstring/inserters_extractors/wchar_t/28277.cc: New.
* include/ext/vstring_util.h: Do not include the whole <locale>.
* include/ext/vstring.tcc (operator>>(basic_istream<>&,
__versa_string<>&, getline(basic_istream<>&, __versa_string<>&,
_CharT)): Tweak to refer to ios_base as a base of istream; do not
refer to non-standard types of istream.
* include/bits/istream.tcc (operator>>(basic_istream<>&, _CharT*),
ws(basic_istream<>&)): Do not refer to non-standard types of istream.
* include/std/bitset (operator>>(std::basic_istream<>&, bitset<>&)):
Avoid using basic_streambuf<>*.
* include/bits/istream.tcc (operator>>(basic_istream<>&,
basic_string<>&), getline(basic_istream<>&, basic_string<>&, _CharT)):
Move...
* include/bits/basic_string.tcc: ... here; tweak to refer to ios_base
as a base of istream; do not refer to non-standard types of istream.
* include/std/string: Tweak includes.
* include/ext/type_traits.h (__is_null_pointer): Add.
* include/ext/rc_string_base.h: Use it.
* include/ext/sso_string_base.h: Likewise.
* include/bits/basic_string.tcc (__is_null_pointer): Remove, use
the above.
* include/ext/vstring_util.h (__vstring_utility<>::_S_is_null_pointer):
Remove.
From-SVN: r123692
2007-04-10 12:38:50 +02:00
|
|
|
{
|
|
|
|
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
|
|
// 91. Description of operator>> and getline() for string<>
|
|
|
|
// might cause endless loop
|
|
|
|
__in._M_setstate(__ios_base::badbit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!__extracted)
|
|
|
|
__err |= __ios_base::failbit;
|
|
|
|
if (__err)
|
|
|
|
__in.setstate(__err);
|
|
|
|
return __in;
|
|
|
|
}
|
|
|
|
|
Tune for size.
2002-02-15 Benjamin Kosnik <bkoz@redhat.com>
Tune for size.
* src/string-inst.cc (string::_Rep::_S_terminal): Remove redundant
explicit instantiation.
(string::_Rep::_S_max_size): Same.
* include/bits/basic_string.tcc: Add extern explicit
instantiations for string, wstring.
* include/bits/basic_ios.tcc: Add extern explicit instantiations
for ios, wios.
* include/bits/streambuf.tcc: Same, for streambuf, wstreambuf.
* include/bits/istream.tcc: Same, for istream, wistream.
* include/bits/ostream.tcc: Same for ostream, wostream, iostream,
wiostream.
* include/bits/sstream.tcc: Same, for stringbuf, wstringbuf,
istringstream, wistringstream, ostringstream, wostringstream,
stringstream, wstringstream.
* include/bits/fstream.tcc: Same, for filebuf, wfilebuf, ifstream,
wifstream, ofstream, wofstream, fstream, wfstream.
* src/misc-inst.cc: Correct comments.
Add iomanip instantiations for wide streams.
* include/std/std_iomanip.h: Same.
* include/bits/locale_facets.tcc: Same.
* include/std/std_streambuf.h: Correct
_GLIBCPP_FULLY_COMPLIANT_HEADERS guard.
* include/std/std_sstream.h: Same.
* include/std/std_ostream.h: Same.
* include/std/std_istream.h: Same.
* include/std/std_fstream.h: Same.
* include/std/std_streambuf.h: Add definitions for private copy
ctor and assignment operator.
* include/std/std_istream.h: Remove declared but undefined copy
ctor and assignment operator. This is taken care of in ios_base,
so adding it in the derived class as well is superfluous.
* include/std/std_ostream.h: Same.
* include/bits/basic_ios.h (basic_ios::clear): Don't inline.
* include/bits/basic_ios.tcc (basic_ios::clear): Move definition here.
From-SVN: r49798
2002-02-16 01:19:13 +01:00
|
|
|
// Inhibit implicit instantiations for required instantiations,
|
2004-02-08 05:46:42 +01:00
|
|
|
// which are defined via explicit instantiations elsewhere.
|
2008-07-19 21:58:52 +02:00
|
|
|
#if _GLIBCXX_EXTERN_TEMPLATE > 0
|
Tune for size.
2002-02-15 Benjamin Kosnik <bkoz@redhat.com>
Tune for size.
* src/string-inst.cc (string::_Rep::_S_terminal): Remove redundant
explicit instantiation.
(string::_Rep::_S_max_size): Same.
* include/bits/basic_string.tcc: Add extern explicit
instantiations for string, wstring.
* include/bits/basic_ios.tcc: Add extern explicit instantiations
for ios, wios.
* include/bits/streambuf.tcc: Same, for streambuf, wstreambuf.
* include/bits/istream.tcc: Same, for istream, wistream.
* include/bits/ostream.tcc: Same for ostream, wostream, iostream,
wiostream.
* include/bits/sstream.tcc: Same, for stringbuf, wstringbuf,
istringstream, wistringstream, ostringstream, wostringstream,
stringstream, wstringstream.
* include/bits/fstream.tcc: Same, for filebuf, wfilebuf, ifstream,
wifstream, ofstream, wofstream, fstream, wfstream.
* src/misc-inst.cc: Correct comments.
Add iomanip instantiations for wide streams.
* include/std/std_iomanip.h: Same.
* include/bits/locale_facets.tcc: Same.
* include/std/std_streambuf.h: Correct
_GLIBCPP_FULLY_COMPLIANT_HEADERS guard.
* include/std/std_sstream.h: Same.
* include/std/std_ostream.h: Same.
* include/std/std_istream.h: Same.
* include/std/std_fstream.h: Same.
* include/std/std_streambuf.h: Add definitions for private copy
ctor and assignment operator.
* include/std/std_istream.h: Remove declared but undefined copy
ctor and assignment operator. This is taken care of in ios_base,
so adding it in the derived class as well is superfluous.
* include/std/std_ostream.h: Same.
* include/bits/basic_ios.h (basic_ios::clear): Don't inline.
* include/bits/basic_ios.tcc (basic_ios::clear): Move definition here.
From-SVN: r49798
2002-02-16 01:19:13 +01:00
|
|
|
extern template class basic_string<char>;
|
2004-02-08 05:46:42 +01:00
|
|
|
extern template
|
|
|
|
basic_istream<char>&
|
Tune for size.
2002-02-15 Benjamin Kosnik <bkoz@redhat.com>
Tune for size.
* src/string-inst.cc (string::_Rep::_S_terminal): Remove redundant
explicit instantiation.
(string::_Rep::_S_max_size): Same.
* include/bits/basic_string.tcc: Add extern explicit
instantiations for string, wstring.
* include/bits/basic_ios.tcc: Add extern explicit instantiations
for ios, wios.
* include/bits/streambuf.tcc: Same, for streambuf, wstreambuf.
* include/bits/istream.tcc: Same, for istream, wistream.
* include/bits/ostream.tcc: Same for ostream, wostream, iostream,
wiostream.
* include/bits/sstream.tcc: Same, for stringbuf, wstringbuf,
istringstream, wistringstream, ostringstream, wostringstream,
stringstream, wstringstream.
* include/bits/fstream.tcc: Same, for filebuf, wfilebuf, ifstream,
wifstream, ofstream, wofstream, fstream, wfstream.
* src/misc-inst.cc: Correct comments.
Add iomanip instantiations for wide streams.
* include/std/std_iomanip.h: Same.
* include/bits/locale_facets.tcc: Same.
* include/std/std_streambuf.h: Correct
_GLIBCPP_FULLY_COMPLIANT_HEADERS guard.
* include/std/std_sstream.h: Same.
* include/std/std_ostream.h: Same.
* include/std/std_istream.h: Same.
* include/std/std_fstream.h: Same.
* include/std/std_streambuf.h: Add definitions for private copy
ctor and assignment operator.
* include/std/std_istream.h: Remove declared but undefined copy
ctor and assignment operator. This is taken care of in ios_base,
so adding it in the derived class as well is superfluous.
* include/std/std_ostream.h: Same.
* include/bits/basic_ios.h (basic_ios::clear): Don't inline.
* include/bits/basic_ios.tcc (basic_ios::clear): Move definition here.
From-SVN: r49798
2002-02-16 01:19:13 +01:00
|
|
|
operator>>(basic_istream<char>&, string&);
|
2004-02-08 05:46:42 +01:00
|
|
|
extern template
|
|
|
|
basic_ostream<char>&
|
Tune for size.
2002-02-15 Benjamin Kosnik <bkoz@redhat.com>
Tune for size.
* src/string-inst.cc (string::_Rep::_S_terminal): Remove redundant
explicit instantiation.
(string::_Rep::_S_max_size): Same.
* include/bits/basic_string.tcc: Add extern explicit
instantiations for string, wstring.
* include/bits/basic_ios.tcc: Add extern explicit instantiations
for ios, wios.
* include/bits/streambuf.tcc: Same, for streambuf, wstreambuf.
* include/bits/istream.tcc: Same, for istream, wistream.
* include/bits/ostream.tcc: Same for ostream, wostream, iostream,
wiostream.
* include/bits/sstream.tcc: Same, for stringbuf, wstringbuf,
istringstream, wistringstream, ostringstream, wostringstream,
stringstream, wstringstream.
* include/bits/fstream.tcc: Same, for filebuf, wfilebuf, ifstream,
wifstream, ofstream, wofstream, fstream, wfstream.
* src/misc-inst.cc: Correct comments.
Add iomanip instantiations for wide streams.
* include/std/std_iomanip.h: Same.
* include/bits/locale_facets.tcc: Same.
* include/std/std_streambuf.h: Correct
_GLIBCPP_FULLY_COMPLIANT_HEADERS guard.
* include/std/std_sstream.h: Same.
* include/std/std_ostream.h: Same.
* include/std/std_istream.h: Same.
* include/std/std_fstream.h: Same.
* include/std/std_streambuf.h: Add definitions for private copy
ctor and assignment operator.
* include/std/std_istream.h: Remove declared but undefined copy
ctor and assignment operator. This is taken care of in ios_base,
so adding it in the derived class as well is superfluous.
* include/std/std_ostream.h: Same.
* include/bits/basic_ios.h (basic_ios::clear): Don't inline.
* include/bits/basic_ios.tcc (basic_ios::clear): Move definition here.
From-SVN: r49798
2002-02-16 01:19:13 +01:00
|
|
|
operator<<(basic_ostream<char>&, const string&);
|
2004-02-08 05:46:42 +01:00
|
|
|
extern template
|
|
|
|
basic_istream<char>&
|
Tune for size.
2002-02-15 Benjamin Kosnik <bkoz@redhat.com>
Tune for size.
* src/string-inst.cc (string::_Rep::_S_terminal): Remove redundant
explicit instantiation.
(string::_Rep::_S_max_size): Same.
* include/bits/basic_string.tcc: Add extern explicit
instantiations for string, wstring.
* include/bits/basic_ios.tcc: Add extern explicit instantiations
for ios, wios.
* include/bits/streambuf.tcc: Same, for streambuf, wstreambuf.
* include/bits/istream.tcc: Same, for istream, wistream.
* include/bits/ostream.tcc: Same for ostream, wostream, iostream,
wiostream.
* include/bits/sstream.tcc: Same, for stringbuf, wstringbuf,
istringstream, wistringstream, ostringstream, wostringstream,
stringstream, wstringstream.
* include/bits/fstream.tcc: Same, for filebuf, wfilebuf, ifstream,
wifstream, ofstream, wofstream, fstream, wfstream.
* src/misc-inst.cc: Correct comments.
Add iomanip instantiations for wide streams.
* include/std/std_iomanip.h: Same.
* include/bits/locale_facets.tcc: Same.
* include/std/std_streambuf.h: Correct
_GLIBCPP_FULLY_COMPLIANT_HEADERS guard.
* include/std/std_sstream.h: Same.
* include/std/std_ostream.h: Same.
* include/std/std_istream.h: Same.
* include/std/std_fstream.h: Same.
* include/std/std_streambuf.h: Add definitions for private copy
ctor and assignment operator.
* include/std/std_istream.h: Remove declared but undefined copy
ctor and assignment operator. This is taken care of in ios_base,
so adding it in the derived class as well is superfluous.
* include/std/std_ostream.h: Same.
* include/bits/basic_ios.h (basic_ios::clear): Don't inline.
* include/bits/basic_ios.tcc (basic_ios::clear): Move definition here.
From-SVN: r49798
2002-02-16 01:19:13 +01:00
|
|
|
getline(basic_istream<char>&, string&, char);
|
2004-02-08 05:46:42 +01:00
|
|
|
extern template
|
|
|
|
basic_istream<char>&
|
Tune for size.
2002-02-15 Benjamin Kosnik <bkoz@redhat.com>
Tune for size.
* src/string-inst.cc (string::_Rep::_S_terminal): Remove redundant
explicit instantiation.
(string::_Rep::_S_max_size): Same.
* include/bits/basic_string.tcc: Add extern explicit
instantiations for string, wstring.
* include/bits/basic_ios.tcc: Add extern explicit instantiations
for ios, wios.
* include/bits/streambuf.tcc: Same, for streambuf, wstreambuf.
* include/bits/istream.tcc: Same, for istream, wistream.
* include/bits/ostream.tcc: Same for ostream, wostream, iostream,
wiostream.
* include/bits/sstream.tcc: Same, for stringbuf, wstringbuf,
istringstream, wistringstream, ostringstream, wostringstream,
stringstream, wstringstream.
* include/bits/fstream.tcc: Same, for filebuf, wfilebuf, ifstream,
wifstream, ofstream, wofstream, fstream, wfstream.
* src/misc-inst.cc: Correct comments.
Add iomanip instantiations for wide streams.
* include/std/std_iomanip.h: Same.
* include/bits/locale_facets.tcc: Same.
* include/std/std_streambuf.h: Correct
_GLIBCPP_FULLY_COMPLIANT_HEADERS guard.
* include/std/std_sstream.h: Same.
* include/std/std_ostream.h: Same.
* include/std/std_istream.h: Same.
* include/std/std_fstream.h: Same.
* include/std/std_streambuf.h: Add definitions for private copy
ctor and assignment operator.
* include/std/std_istream.h: Remove declared but undefined copy
ctor and assignment operator. This is taken care of in ios_base,
so adding it in the derived class as well is superfluous.
* include/std/std_ostream.h: Same.
* include/bits/basic_ios.h (basic_ios::clear): Don't inline.
* include/bits/basic_ios.tcc (basic_ios::clear): Move definition here.
From-SVN: r49798
2002-02-16 01:19:13 +01:00
|
|
|
getline(basic_istream<char>&, string&);
|
|
|
|
|
2003-07-05 06:05:45 +02:00
|
|
|
#ifdef _GLIBCXX_USE_WCHAR_T
|
Tune for size.
2002-02-15 Benjamin Kosnik <bkoz@redhat.com>
Tune for size.
* src/string-inst.cc (string::_Rep::_S_terminal): Remove redundant
explicit instantiation.
(string::_Rep::_S_max_size): Same.
* include/bits/basic_string.tcc: Add extern explicit
instantiations for string, wstring.
* include/bits/basic_ios.tcc: Add extern explicit instantiations
for ios, wios.
* include/bits/streambuf.tcc: Same, for streambuf, wstreambuf.
* include/bits/istream.tcc: Same, for istream, wistream.
* include/bits/ostream.tcc: Same for ostream, wostream, iostream,
wiostream.
* include/bits/sstream.tcc: Same, for stringbuf, wstringbuf,
istringstream, wistringstream, ostringstream, wostringstream,
stringstream, wstringstream.
* include/bits/fstream.tcc: Same, for filebuf, wfilebuf, ifstream,
wifstream, ofstream, wofstream, fstream, wfstream.
* src/misc-inst.cc: Correct comments.
Add iomanip instantiations for wide streams.
* include/std/std_iomanip.h: Same.
* include/bits/locale_facets.tcc: Same.
* include/std/std_streambuf.h: Correct
_GLIBCPP_FULLY_COMPLIANT_HEADERS guard.
* include/std/std_sstream.h: Same.
* include/std/std_ostream.h: Same.
* include/std/std_istream.h: Same.
* include/std/std_fstream.h: Same.
* include/std/std_streambuf.h: Add definitions for private copy
ctor and assignment operator.
* include/std/std_istream.h: Remove declared but undefined copy
ctor and assignment operator. This is taken care of in ios_base,
so adding it in the derived class as well is superfluous.
* include/std/std_ostream.h: Same.
* include/bits/basic_ios.h (basic_ios::clear): Don't inline.
* include/bits/basic_ios.tcc (basic_ios::clear): Move definition here.
From-SVN: r49798
2002-02-16 01:19:13 +01:00
|
|
|
extern template class basic_string<wchar_t>;
|
2004-02-08 05:46:42 +01:00
|
|
|
extern template
|
|
|
|
basic_istream<wchar_t>&
|
Tune for size.
2002-02-15 Benjamin Kosnik <bkoz@redhat.com>
Tune for size.
* src/string-inst.cc (string::_Rep::_S_terminal): Remove redundant
explicit instantiation.
(string::_Rep::_S_max_size): Same.
* include/bits/basic_string.tcc: Add extern explicit
instantiations for string, wstring.
* include/bits/basic_ios.tcc: Add extern explicit instantiations
for ios, wios.
* include/bits/streambuf.tcc: Same, for streambuf, wstreambuf.
* include/bits/istream.tcc: Same, for istream, wistream.
* include/bits/ostream.tcc: Same for ostream, wostream, iostream,
wiostream.
* include/bits/sstream.tcc: Same, for stringbuf, wstringbuf,
istringstream, wistringstream, ostringstream, wostringstream,
stringstream, wstringstream.
* include/bits/fstream.tcc: Same, for filebuf, wfilebuf, ifstream,
wifstream, ofstream, wofstream, fstream, wfstream.
* src/misc-inst.cc: Correct comments.
Add iomanip instantiations for wide streams.
* include/std/std_iomanip.h: Same.
* include/bits/locale_facets.tcc: Same.
* include/std/std_streambuf.h: Correct
_GLIBCPP_FULLY_COMPLIANT_HEADERS guard.
* include/std/std_sstream.h: Same.
* include/std/std_ostream.h: Same.
* include/std/std_istream.h: Same.
* include/std/std_fstream.h: Same.
* include/std/std_streambuf.h: Add definitions for private copy
ctor and assignment operator.
* include/std/std_istream.h: Remove declared but undefined copy
ctor and assignment operator. This is taken care of in ios_base,
so adding it in the derived class as well is superfluous.
* include/std/std_ostream.h: Same.
* include/bits/basic_ios.h (basic_ios::clear): Don't inline.
* include/bits/basic_ios.tcc (basic_ios::clear): Move definition here.
From-SVN: r49798
2002-02-16 01:19:13 +01:00
|
|
|
operator>>(basic_istream<wchar_t>&, wstring&);
|
2004-02-08 05:46:42 +01:00
|
|
|
extern template
|
|
|
|
basic_ostream<wchar_t>&
|
Tune for size.
2002-02-15 Benjamin Kosnik <bkoz@redhat.com>
Tune for size.
* src/string-inst.cc (string::_Rep::_S_terminal): Remove redundant
explicit instantiation.
(string::_Rep::_S_max_size): Same.
* include/bits/basic_string.tcc: Add extern explicit
instantiations for string, wstring.
* include/bits/basic_ios.tcc: Add extern explicit instantiations
for ios, wios.
* include/bits/streambuf.tcc: Same, for streambuf, wstreambuf.
* include/bits/istream.tcc: Same, for istream, wistream.
* include/bits/ostream.tcc: Same for ostream, wostream, iostream,
wiostream.
* include/bits/sstream.tcc: Same, for stringbuf, wstringbuf,
istringstream, wistringstream, ostringstream, wostringstream,
stringstream, wstringstream.
* include/bits/fstream.tcc: Same, for filebuf, wfilebuf, ifstream,
wifstream, ofstream, wofstream, fstream, wfstream.
* src/misc-inst.cc: Correct comments.
Add iomanip instantiations for wide streams.
* include/std/std_iomanip.h: Same.
* include/bits/locale_facets.tcc: Same.
* include/std/std_streambuf.h: Correct
_GLIBCPP_FULLY_COMPLIANT_HEADERS guard.
* include/std/std_sstream.h: Same.
* include/std/std_ostream.h: Same.
* include/std/std_istream.h: Same.
* include/std/std_fstream.h: Same.
* include/std/std_streambuf.h: Add definitions for private copy
ctor and assignment operator.
* include/std/std_istream.h: Remove declared but undefined copy
ctor and assignment operator. This is taken care of in ios_base,
so adding it in the derived class as well is superfluous.
* include/std/std_ostream.h: Same.
* include/bits/basic_ios.h (basic_ios::clear): Don't inline.
* include/bits/basic_ios.tcc (basic_ios::clear): Move definition here.
From-SVN: r49798
2002-02-16 01:19:13 +01:00
|
|
|
operator<<(basic_ostream<wchar_t>&, const wstring&);
|
2004-02-08 05:46:42 +01:00
|
|
|
extern template
|
|
|
|
basic_istream<wchar_t>&
|
Tune for size.
2002-02-15 Benjamin Kosnik <bkoz@redhat.com>
Tune for size.
* src/string-inst.cc (string::_Rep::_S_terminal): Remove redundant
explicit instantiation.
(string::_Rep::_S_max_size): Same.
* include/bits/basic_string.tcc: Add extern explicit
instantiations for string, wstring.
* include/bits/basic_ios.tcc: Add extern explicit instantiations
for ios, wios.
* include/bits/streambuf.tcc: Same, for streambuf, wstreambuf.
* include/bits/istream.tcc: Same, for istream, wistream.
* include/bits/ostream.tcc: Same for ostream, wostream, iostream,
wiostream.
* include/bits/sstream.tcc: Same, for stringbuf, wstringbuf,
istringstream, wistringstream, ostringstream, wostringstream,
stringstream, wstringstream.
* include/bits/fstream.tcc: Same, for filebuf, wfilebuf, ifstream,
wifstream, ofstream, wofstream, fstream, wfstream.
* src/misc-inst.cc: Correct comments.
Add iomanip instantiations for wide streams.
* include/std/std_iomanip.h: Same.
* include/bits/locale_facets.tcc: Same.
* include/std/std_streambuf.h: Correct
_GLIBCPP_FULLY_COMPLIANT_HEADERS guard.
* include/std/std_sstream.h: Same.
* include/std/std_ostream.h: Same.
* include/std/std_istream.h: Same.
* include/std/std_fstream.h: Same.
* include/std/std_streambuf.h: Add definitions for private copy
ctor and assignment operator.
* include/std/std_istream.h: Remove declared but undefined copy
ctor and assignment operator. This is taken care of in ios_base,
so adding it in the derived class as well is superfluous.
* include/std/std_ostream.h: Same.
* include/bits/basic_ios.h (basic_ios::clear): Don't inline.
* include/bits/basic_ios.tcc (basic_ios::clear): Move definition here.
From-SVN: r49798
2002-02-16 01:19:13 +01:00
|
|
|
getline(basic_istream<wchar_t>&, wstring&, wchar_t);
|
2004-02-08 05:46:42 +01:00
|
|
|
extern template
|
|
|
|
basic_istream<wchar_t>&
|
Tune for size.
2002-02-15 Benjamin Kosnik <bkoz@redhat.com>
Tune for size.
* src/string-inst.cc (string::_Rep::_S_terminal): Remove redundant
explicit instantiation.
(string::_Rep::_S_max_size): Same.
* include/bits/basic_string.tcc: Add extern explicit
instantiations for string, wstring.
* include/bits/basic_ios.tcc: Add extern explicit instantiations
for ios, wios.
* include/bits/streambuf.tcc: Same, for streambuf, wstreambuf.
* include/bits/istream.tcc: Same, for istream, wistream.
* include/bits/ostream.tcc: Same for ostream, wostream, iostream,
wiostream.
* include/bits/sstream.tcc: Same, for stringbuf, wstringbuf,
istringstream, wistringstream, ostringstream, wostringstream,
stringstream, wstringstream.
* include/bits/fstream.tcc: Same, for filebuf, wfilebuf, ifstream,
wifstream, ofstream, wofstream, fstream, wfstream.
* src/misc-inst.cc: Correct comments.
Add iomanip instantiations for wide streams.
* include/std/std_iomanip.h: Same.
* include/bits/locale_facets.tcc: Same.
* include/std/std_streambuf.h: Correct
_GLIBCPP_FULLY_COMPLIANT_HEADERS guard.
* include/std/std_sstream.h: Same.
* include/std/std_ostream.h: Same.
* include/std/std_istream.h: Same.
* include/std/std_fstream.h: Same.
* include/std/std_streambuf.h: Add definitions for private copy
ctor and assignment operator.
* include/std/std_istream.h: Remove declared but undefined copy
ctor and assignment operator. This is taken care of in ios_base,
so adding it in the derived class as well is superfluous.
* include/std/std_ostream.h: Same.
* include/bits/basic_ios.h (basic_ios::clear): Don't inline.
* include/bits/basic_ios.tcc (basic_ios::clear): Move definition here.
From-SVN: r49798
2002-02-16 01:19:13 +01:00
|
|
|
getline(basic_istream<wchar_t>&, wstring&);
|
2002-11-01 18:30:36 +01:00
|
|
|
#endif
|
2003-02-13 22:39:03 +01:00
|
|
|
#endif
|
2005-12-19 01:56:05 +01:00
|
|
|
|
PR libstdc++/36104 part four
2011-01-30 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/36104 part four
* include/bits/c++config (_GLIBCXX_STD): Remove.
(_GLIBCXX_STD_D, _GLIBCXX_PR): Now _GLIBCXX_STD_C.
(_GLIBCXX_P): Now _GLIBCXX_STD_A.
(_GLIBCXX_NAMESPACE_DEBUG, _GLIBCXX_NAMESPACE_PARALLEL,
_GLIBCXX_NAMESPACE_PROFILE, _GLIBCXX_NAMESPACE_VERSION): Remove.
(_GLIBCXX_INLINE_DEBUG, _GLIBCXX_INLINE_PARALLEL,
_GLIBCXX_INLINE_PROFILE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE(X)): Remove.
(_GLIBCXX_END_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NESTED_NAMESPACE(X, Y)): Remove.
(_GLIBCXX_END_NESTED_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE_ALGO): Add.
(_GLIBCXX_END_NAMESPACE_ALGO): Add.
(_GLIBCXX_BEGIN_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_END_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_BEGIN_NAMESPACE_VERSION): Add.
(_GLIBCXX_END_NAMESPACE_VERSION): Add.
(_GLIBCXX_BEGIN_LDBL_NAMESPACE): To _GLIBCXX_BEGIN_NAMESPACE_LDBL.
(_GLIBCXX_END_LDBL_NAMESPACE): To _GLIBCXX_END_NAMESPACE_LDBL.
(_GLIBCXX_VISIBILITY_ATTR): Revert to _GLIBCXX_VISIBILITY.
* include/*: Use new macros for namespace scope.
* config/*: Same.
* src/*: Same.
* src/Makefile.am (sources): Remove debug_list.cc, add
compatibility-debug_list-2.cc.
(parallel_sources): Remove parallel_list.cc, add
compatibility-parallel_list-2.cc.
(compatibility-parallel_list-2.[o,lo]): New rule.
* src/Makefile.in: Regenerate.
* src/debug_list.cc: Remove.
* src/parallel_list.cc: Remove.
* src/compatibility-list-2.cc: New.
* src/compatibility-debug_list-2.cc: New.
* src/compatibility-parallel_list-2.cc: New.
* doc/doxygen/user.cfg.in: Adjust macros.
* testsuite/20_util/auto_ptr/assign_neg.cc: Adjust line numbers, macros.
* testsuite/20_util/declval/requirements/1_neg.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg1.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg2.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg3.cc: Same.
* testsuite/20_util/forward/c_neg.cc: Same.
* testsuite/20_util/forward/f_neg.cc: Same.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Same.
* testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Same.
* testsuite/20_util/shared_ptr/cons/43820_neg.cc: Same.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/forward_list/capacity/1.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
assign_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
insert_neg.cc: Same.
* testsuite/23_containers/list/capacity/29134.cc: Same.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/vector/bool/capacity/29134.cc: Same.
* testsuite/23_containers/vector/bool/modifiers/insert/31370.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc: Same.
* testsuite/25_algorithms/sort/35588.cc: Same.
* testsuite/27_io/ios_base/cons/assign_neg.cc: Same.
* testsuite/27_io/ios_base/cons/copy_neg.cc: Same.
* testsuite/ext/profile/mutex_extensions_neg.cc: Same.
* testsuite/ext/profile/profiler_algos.cc: Same.
* testsuite/ext/type_traits/add_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/add_unsigned_integer_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_integer_neg.cc: Same.
* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc: Same.
From-SVN: r169421
2011-01-30 23:39:36 +01:00
|
|
|
_GLIBCXX_END_NAMESPACE_VERSION
|
2011-03-04 22:51:56 +01:00
|
|
|
} // namespace std
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2001-06-12 04:30:37 +02:00
|
|
|
#endif
|