gcc/libstdc++-v3/include/ext/rc_string_base.h

718 lines
23 KiB
C
Raw Normal View History

// Reference-counted versatile string base -*- C++ -*-
// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
//
// 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
// Free Software Foundation; either version 2, or (at your option)
// 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.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
/** @file ext/rc_string_base.h
* This file is a GNU extension to the Standard C++ Library.
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
#ifndef _RC_STRING_BASE_H
#define _RC_STRING_BASE_H 1
atomicity.h: Move to... 2006-09-13 Benjamin Kosnik <bkoz@redhat.com> * include/bits/atomicity.h: Move to... * include/ext/atomicity.h: ...here. * include/bits/concurrence.h: Move to... * include/ext/concurrence.h: ...here. * include/Makefile.am (ext_headers): Additions. (bits_headers): Subtractions. * include/Makefile.in: Regenerate. * include/ext/bitmap_allocator.h (_Mutex), __threads_enabled, _Lock, _Auto_Lock): Subsume into... * include/bits/concurrence.h (__mutex): ..this. Error check locking and unlocking. (lock): Uglify to... (__scoped_lock): Use __mutex. (__glibcxx_mutex_define_initialized): Remove. (__glibcxx_mutex_type): Remove. * include/tr1/boost_shared_ptr.h: Formating tweaks, adjustments. (_Lock_policy): Move from here... * include/ext/concurrence.h: ... to here. (__shared_ptr_default_lock_mode): To __default_lock_policy. (_S_lockfree): To _S_atomic. Document. * libsupc++/guard.cc (static_mutex): Subsume into and fixup for... * include/ext/concurrence.h (__recursive_mutex): ...this. Error check locking and unlocking. * libsupc++/eh_alloc.cc: Use __scoped_lock. * config/os/aix/atomicity.h: Fixups for include paths, mutex to __scoped_mutex change, removal of locking defines. * config/os/irix/atomicity.h: Same. * config/cpu/cris/atomicity.h: Same. * config/cpu/m68k/atomicity.h: Same. * config/cpu/hppa/atomicity.h: Same. * config/cpu/mips/atomicity.h: Same. * config/cpu/sparc/atomicity.h: Same. * config/cpu/i386/atomicity.h: Same. * config/cpu/i486/atomicity.h: Same. * config/cpu/sh/atomicity.h: Same. * config/cpu/generic/atomicity_mutex/atomicity.h: Same. * include/ext/pool_allocator.h: Same. * include/ext/bitmap_allocator.h: Same. * include/ext/rc_string_base.h: Same. * include/ext/mt_allocator.h: Same. * include/bits/locale_classes.h: Same. * include/bits/basic_string.h: Same. * include/bits/ios_base.h: Same. * include/tr1/memory: Same. * src/pool_allocator.cc: Same. * src/mt_allocator.cc: Same. * src/locale_init.cc: Same. * src/ios.cc: Same. * src/locale.cc: Same. * src/bitmap_allocator.cc: Same. * src/ios_init.cc: Same. * src/debug.cc: Same. From-SVN: r116942
2006-09-14 11:48:15 +02:00
#include <ext/atomicity.h>
c++config: Add in revised namespace associations. 2005-12-18 Benjamin Kosnik <bkoz@redhat.com> * include/bits/c++config: Add in revised namespace associations. _GLIBCXX_BEGIN_NAMESPACE: New macro. _GLIBCXX_END_NAMESPACE: Same. _GLIBCXX_BEGIN_NESTED_NAMESPACE: Same. _GLIBCXX_END_NESTED_NAMESPACE: Same. * acinclude.m4 (GLIBCXX_ENABLE_SYMVERS]): Add gnu-versioned-namespace. * configure: Regenerated. * config.h.in: Same. * config/abi/pre/gnu-versioned-namespace.ver: New. * config/abi/pre/gnu.ver (GLIBCXX_3.4.7): Add exports for nested debug mode items. * include/Makefile.am (${host_builddir}/c++config.h): Fill in values for __GLIBCXX__ and _GLIBCXX_NAMESPACE_ASSOCIATION_VERSION. * include/Makefile.in: Regnerate. * src/compatibility.cc: Alias new, nested definitions to exported symbols from non-nested __gnu_debug. * src/Makefile.am: Add in ENABLE_SYMVERS_GNU_NAMESPACE. * src/Makefile.in: Regenerate. * docs/html/debug_mode.html: Revise for nested design. * docs/html/debug.html: Use debug qualifications instead of __gnu_debug. * docs/html/configopts.html: Revise documentation for --enable-symvers. * include/debug/formatter: Simplify namespace qualifications for current, nested-only reality. Add top-level namespace alias, namespace debug, for debug-mode containers. * include/debug/safe_iterator.h: Same. * include/debug/set.h: Same. * include/debug/hash_multimap.h: Same. * include/debug/hash_set.h: Same. * include/debug/bitset * include/debug/safe_sequence.h: Same. * include/debug/multiset.h: Same. * include/debug/safe_base.h: Same. * include/debug/functions.h: Same. * include/debug/safe_iterator.tcc * include/debug/hash_multiset.h: Same. * include/debug/vector * include/debug/map.h: Same. * include/debug/deque * include/debug/hash_map.h: Same. * include/debug/string * include/debug/macros.h: Same. * include/debug/list * include/debug/debug.h: Same. * include/debug/multimap.h: Same. * src/debug.cc: Same. * testsuite/23_containers/vector/invalidation/1.cc: Cleanups. * testsuite/23_containers/vector/invalidation/2.cc: Same. * testsuite/23_containers/vector/invalidation/3.cc: Same. * testsuite/23_containers/vector/invalidation/4.cc: Same. * testsuite/23_containers/deque/invalidation/1.cc: Same. * testsuite/23_containers/deque/invalidation/2.cc: Same. * testsuite/23_containers/deque/invalidation/3.cc: Same. * testsuite/23_containers/deque/invalidation/4.cc: Same. * testsuite/23_containers/multiset/invalidation/1.cc: Same. * testsuite/23_containers/multiset/invalidation/2.cc: Same. * testsuite/23_containers/multimap/invalidation/1.cc: Same. * testsuite/23_containers/multimap/invalidation/2.cc: Same. * testsuite/23_containers/bitset/invalidation/1.cc: Same. * testsuite/23_containers/bitset/cons/16020.cc: Same. * testsuite/23_containers/bitset/operations/13838.cc: Same. * testsuite/23_containers/list/invalidation/1.cc: Same. * testsuite/23_containers/list/invalidation/2.cc: Same. * testsuite/23_containers/list/invalidation/3.cc: Same. * testsuite/23_containers/list/invalidation/4.cc: Same. * testsuite/23_containers/set/invalidation/1.cc: Same. * testsuite/23_containers/set/invalidation/2.cc: Same. * testsuite/23_containers/map/invalidation/1.cc: Same. * testsuite/23_containers/map/invalidation/2.cc: Same. * testsuite/23_containers/map/insert/16813.cc: Same. * include/bits/basic_ios.h: Use _GLIBCXX_BEGIN_NAMESPACE(std) and friends. * include/bits/stl_list.h: Same. * include/bits/stl_map.h: Same. * include/bits/stl_algobase.h: Same. * include/bits/localefwd.h: Same. * include/bits/valarray_array.tcc: Same. * include/bits/valarray_after.h: Same. * include/bits/gslice_array.h: Same. * include/bits/stl_queue.h: Same. * include/bits/gslice.h: Same. * include/bits/locale_facets.tcc: Same. * include/bits/locale_classes.h: Same. * include/bits/stl_set.h: Same. * include/bits/locale_facets.h: Same. * include/bits/stl_stack.h: Same. * include/bits/stl_iterator_base_types.h: Same. * include/bits/stl_heap.h: Same. * include/bits/indirect_array.h: Same. * include/bits/atomicity.h: Same. * include/bits/stream_iterator.h: Same. * include/bits/concurrence.h: Same. * include/bits/basic_string.h: Same. * include/bits/stl_multimap.h: Same. * include/bits/stl_pair.h: Same. * include/bits/basic_ios.tcc: Same. * include/bits/stl_raw_storage_iter.h: Same. * include/bits/stl_vector.h: Same. * include/bits/stl_numeric.h: Same. * include/bits/ios_base.h: Same. * include/bits/stl_deque.h: Same. * include/bits/istream.tcc: Same. * include/bits/postypes.h: Same. * include/bits/stl_multiset.h: Same. * include/bits/mask_array.h: Same. * include/bits/stl_uninitialized.h: Same. * include/bits/ostream.tcc: Same. * include/bits/slice_array.h: Same. * include/bits/boost_concept_check.h: Same. * include/bits/sstream.tcc: Same. * include/bits/stl_iterator_base_funcs.h: Same. * include/bits/char_traits.h: Same. * include/bits/stl_algo.h: Same. * include/bits/stringfwd.h: Same. * include/bits/c++config * include/bits/stl_iterator.h: Same. * include/bits/valarray_array.h: Same. * include/bits/stl_tempbuf.h: Same. * include/bits/vector.tcc: Same. * include/bits/deque.tcc: Same. * include/bits/stl_bvector.h: Same. * include/bits/basic_string.tcc: Same. * include/bits/list.tcc: Same. * include/bits/streambuf_iterator.h: Same. * include/bits/valarray_before.h: Same. * include/bits/stl_construct.h: Same. * include/bits/stl_function.h: Same. * include/bits/cpp_type_traits.h: Same. * include/bits/streambuf.tcc: Same. * include/bits/allocator.h: Same. * include/bits/stl_tree.h: Same. * include/bits/fstream.tcc: Same. * include/bits/stl_relops.h: Same. * include/bits/functexcept.h: Same. * include/std/std_valarray.h: Same. * include/std/std_iostream.h: Same. * include/std/std_streambuf.h: Same. * include/std/std_bitset.h: Same. * include/std/std_iosfwd.h: Same. * include/std/std_iomanip.h: Same. * include/std/std_fstream.h: Same. * include/std/std_limits.h: Same. * include/std/std_stdexcept.h: Same. * include/std/std_istream.h: Same. * include/std/std_complex.h: Same. * include/std/std_memory.h: Same. * include/std/std_ostream.h: Same. * include/std/std_sstream.h: Same. * include/c_std/std_csignal.h: Same. * include/c_std/std_cstdlib.h: Same. * include/c_std/std_cstdio.h: Same. * include/c_std/std_cstdarg.h: Same. * include/c_std/std_cctype.h: Same. * include/c_std/std_cmath.h: Same. * include/c_std/std_ctime.h: Same. * include/c_std/std_clocale.h: Same. * include/c_std/std_csetjmp.h: Same. * include/c_std/std_cwchar.h: Same. * include/c_std/std_cstring.h: Same. * include/c_std/std_cstddef.h: Same. * include/c_std/std_cwctype.h: Same. * include/backward/iterator.h: Same. * include/backward/set.h: Same. * include/backward/hashtable.h: Same. * include/backward/fstream.h: Same. * include/backward/tempbuf.h: Same. * include/backward/istream.h: Same. * include/backward/bvector.h: Same. * include/backward/stack.h: Same. * include/backward/rope.h: Same. * include/backward/complex.h: Same. * include/backward/ostream.h: Same. * include/backward/heap.h: Same. * include/backward/iostream.h: Same. * include/backward/function.h: Same. * include/backward/multimap.h: Same. * include/backward/pair.h: Same. * include/backward/stream.h: Same. * include/backward/iomanip.h: Same. * include/backward/strstream * include/backward/slist.h: Same. * include/backward/tree.h: Same. * include/backward/vector.h: Same. * include/backward/deque.h: Same. * include/backward/multiset.h: Same. * include/backward/list.h: Same. * include/backward/map.h: Same. * include/backward/algobase.h: Same. * include/backward/hash_map.h: Same. * include/backward/algo.h: Same. * include/backward/queue.h: Same. * include/backward/streambuf.h: Same. * src/allocator-inst.cc: Same. * src/complex_io.cc: Same. * src/localename.cc: Same. * src/limits.cc: Same. * src/ios_failure.cc: Same. * src/locale-misc-inst.cc: Same. * src/streambuf-inst.cc: Same. * src/misc-inst.cc: Same. * src/concept-inst.cc: Same. * src/ios_locale.cc: Same. * src/pool_allocator.cc: Same. * src/fstream-inst.cc: Same. * src/istream-inst.cc: Same. * src/string-inst.cc: Same. * src/locale_init.cc: Same. * src/ctype.cc: Same. * src/strstream.cc: Same. * src/ostream-inst.cc: Same. * src/functexcept.cc: Same. * src/streambuf.cc: Same. * src/sstream-inst.cc: Same. * src/ios.cc: Same. * src/valarray-inst.cc: Same. * src/locale.cc: Same. * src/tree.cc: Same. * src/stdexcept.cc: Same. * src/istream.cc: Same. * src/compatibility.cc: Same. * src/locale-inst.cc: Same. * src/globals_io.cc: Same. * src/list.cc: Same. * src/ios_init.cc: Same. * src/locale_facets.cc: Same. * src/codecvt.cc: Same. * include/tr1/unordered_map: Use _GLIBCXX_BEGIN_NAMESPACE(tr1). * include/tr1/boost_shared_ptr.h: Same. * include/tr1/tuple * include/tr1/hashtable * include/tr1/type_traits_fwd.h: Same. * include/tr1/unordered_set * include/tr1/functional * include/tr1/ref_fwd.h: Same. * include/tr1/utility * include/tr1/type_traits * include/tr1/array * include/ext/hashtable.h: Use _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx). * include/ext/typelist.h: Same. * include/ext/hash_map: Same. * include/ext/rc_string_base.h: Same. * include/ext/pool_allocator.h: Same. * include/ext/iterator: Same. * include/ext/rb_tree: Same. * include/ext/numeric: Same. * include/ext/vstring.tcc: Same. * include/ext/sso_string_base.h: Same. * include/ext/stdio_filebuf.h: Same. * include/ext/algorithm: Same. * include/ext/codecvt_specializations.h: Same. * include/ext/new_allocator.h: Same. * include/ext/array_allocator.h: Same. * include/ext/vstring_util.h: Same. * include/ext/vstring_fwd.h: Same. * include/ext/mt_allocator.h: Same. * include/ext/debug_allocator.h: Same. * include/ext/slist: Same. * include/ext/stdio_sync_filebuf.h: Same. * include/ext/hash_fun.h: Same. * include/ext/malloc_allocator.h: Same. * include/ext/functional: Same. * include/ext/bitmap_allocator.h: Same. * include/ext/pod_char_traits.h: Same. * include/ext/vstring.h: Same. * include/ext/ropeimpl.h: Same. * include/ext/hash_set: Same. * include/ext/memory: Same. * include/ext/rope: Same. * include/bits/boost_concept_check.h: Same. * include/bits/stl_iterator.h: Same. * include/bits/char_traits.h: Same. * include/bits/cpp_type_traits.h: Same. * include/bits/concurrence.h: Same. * include/bits/atomicity.h: Same. * config/locale/gnu/numeric_members.cc: Same. * config/locale/gnu/collate_members.cc: Same. * config/locale/gnu/ctype_members.cc: Same. * config/locale/gnu/c_locale.cc: Same. * config/locale/gnu/codecvt_members.cc: Same. * config/locale/gnu/messages_members.cc: Same. * config/locale/gnu/c_locale.h: Same. * config/locale/gnu/monetary_members.cc: Same. * config/locale/gnu/time_members.cc: Same. * config/locale/ieee_1003.1-2001/c_locale.h: Same. * config/locale/generic/numeric_members.cc: Same. * config/locale/generic/collate_members.cc: Same. * config/locale/generic/ctype_members.cc: Same. * config/locale/generic/c_locale.cc: Same. * config/locale/generic/codecvt_members.cc: Same. * config/locale/generic/messages_members.cc: Same. * config/locale/generic/c_locale.h: Same. * config/locale/generic/monetary_members.cc: Same. * config/locale/generic/time_members.cc: Same. * config/os/aix/atomicity.h: Same. * config/os/irix/atomicity.h: Same. * config/cpu/powerpc/atomicity.h: Same. * config/cpu/cris/atomicity.h: Same. * config/cpu/ia64/atomicity.h: Same. * config/cpu/alpha/atomicity.h: Same. * config/cpu/m68k/atomicity.h: Same. * config/cpu/hppa/atomicity.h: Same. * config/cpu/mips/atomicity.h: Same. * config/cpu/sparc/atomicity.h: Same. * config/cpu/i386/atomicity.h: Same. * config/cpu/i486/atomicity.h: Same. * config/cpu/sh/atomicity.h: Same. * config/cpu/generic/atomicity.h: Same. * config/cpu/s390/atomicity.h: Same. * config/io/c_io_stdio.h: Same. * config/io/basic_file_stdio.cc: Same. * config/io/basic_file_stdio.h: Same. * src/misc-inst.cc: Same. * src/concept-inst.cc: Same. * src/ext-inst.cc: Same. * src/string-inst.cc: Same. * src/pool_allocator.cc: Same. * src/bitmap_allocator.cc: Same. * src/mt_allocator.cc: Same. * libsupc++/exception: Same. * libsupc++/vterminate.cc: Same. * testsuite/ext/hash_map/1.cc: Explicitly qualify __gnu_cxx::hash_map. * testsuite/ext/hash_map/14648.cc: Same. * libsupc++/eh_alloc.cc: Correct comment line spacing. From-SVN: r108775
2005-12-19 01:56:05 +01:00
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
/**
* @if maint
* Documentation? What's that?
* Nathan Myers <ncm@cantrip.org>.
*
* A string looks like this:
*
* @code
* [_Rep]
* _M_length
* [__rc_string_base<char_type>] _M_capacity
* _M_dataplus _M_refcount
* _M_p ----------------> unnamed array of char_type
* @endcode
*
* Where the _M_p points to the first character in the string, and
* you cast it to a pointer-to-_Rep and subtract 1 to get a
* pointer to the header.
*
* This approach has the enormous advantage that a string object
* requires only one allocation. All the ugliness is confined
* within a single pair of inline functions, which each compile to
* a single "add" instruction: _Rep::_M_refdata(), and
* __rc_string_base::_M_rep(); and the allocation function which gets a
* block of raw bytes and with room enough and constructs a _Rep
* object at the front.
*
* The reason you want _M_data pointing to the character array and
* not the _Rep is so that the debugger can see the string
* contents. (Probably we should add a non-inline member to get
* the _Rep for the debugger to use, so users can check the actual
* string length.)
*
* Note that the _Rep object is a POD so that you can have a
* static "empty string" _Rep object already "constructed" before
* static constructors have run. The reference-count encoding is
* chosen so that a 0 indicates one reference, so you never try to
* destroy the empty-string _Rep object.
*
* All but the last paragraph is considered pretty conventional
* for a C++ string implementation.
* @endif
*/
template<typename _CharT, typename _Traits, typename _Alloc>
class __rc_string_base
: protected __vstring_utility<_CharT, _Traits, _Alloc>
{
public:
typedef _Traits traits_type;
typedef typename _Traits::char_type value_type;
typedef _Alloc allocator_type;
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
typedef __vstring_utility<_CharT, _Traits, _Alloc> _Util_Base;
typedef typename _Util_Base::_CharT_alloc_type _CharT_alloc_type;
typedef typename _CharT_alloc_type::size_type size_type;
private:
// _Rep: string representation
// Invariants:
// 1. String really contains _M_length + 1 characters: due to 21.3.4
// must be kept null-terminated.
// 2. _M_capacity >= _M_length
// Allocated memory is always (_M_capacity + 1) * sizeof(_CharT).
// 3. _M_refcount has three states:
// -1: leaked, one reference, no ref-copies allowed, non-const.
// 0: one reference, non-const.
// n>0: n + 1 references, operations require a lock, const.
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
// 4. All fields == 0 is an empty string, given the extra storage
// beyond-the-end for a null terminator; thus, the shared
// empty string representation needs no constructor.
struct _Rep
{
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
union
{
struct
{
size_type _M_length;
size_type _M_capacity;
_Atomic_word _M_refcount;
} _M_info;
// Only for alignment purposes.
_CharT _M_align;
};
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
typedef typename _Alloc::template rebind<_Rep>::other _Rep_alloc_type;
_CharT*
_M_refdata() throw()
{ return reinterpret_cast<_CharT*>(this + 1); }
_CharT*
_M_refcopy() throw()
{
__atomic_add_dispatch(&_M_info._M_refcount, 1);
return _M_refdata();
} // XXX MT
void
_M_set_length(size_type __n)
{
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
_M_info._M_refcount = 0; // One reference.
_M_info._M_length = __n;
// grrr. (per 21.3.4)
// You cannot leave those LWG people alone for a second.
traits_type::assign(_M_refdata()[__n], _CharT());
}
// Create & Destroy
static _Rep*
_S_create(size_type, size_type, const _Alloc&);
void
_M_destroy(const _Alloc&) throw();
_CharT*
_M_clone(const _Alloc&, size_type __res = 0);
};
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
struct _Rep_empty
: public _Rep
{
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
_CharT _M_terminal;
};
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
static _Rep_empty _S_empty_rep;
// The maximum number of individual char_type elements of an
// individual string is determined by _S_max_size. This is the
// value that will be returned by max_size(). (Whereas npos
// is the maximum number of bytes the allocator can allocate.)
// If one was to divvy up the theoretical largest size string,
// with a terminating character and m _CharT elements, it'd
// look like this:
// npos = sizeof(_Rep) + (m * sizeof(_CharT)) + sizeof(_CharT)
// + sizeof(_Rep) - 1
// (NB: last two terms for rounding reasons, see _M_create below)
// Solving for m:
// m = ((npos - 2 * sizeof(_Rep) + 1) / sizeof(_CharT)) - 1
// In addition, this implementation halfs this amount.
enum { _S_max_size = (((static_cast<size_type>(-1) - 2 * sizeof(_Rep)
+ 1) / sizeof(_CharT)) - 1) / 2 };
// Data Member (private):
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
mutable typename _Util_Base::template _Alloc_hider<_Alloc> _M_dataplus;
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
void
_M_data(_CharT* __p)
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
{ _M_dataplus._M_p = __p; }
_Rep*
_M_rep() const
{ return &((reinterpret_cast<_Rep*>(_M_data()))[-1]); }
_CharT*
_M_grab(const _Alloc& __alloc) const
{
return (!_M_is_leaked() && _M_get_allocator() == __alloc)
? _M_rep()->_M_refcopy() : _M_rep()->_M_clone(__alloc);
}
void
_M_dispose()
{
if (__exchange_and_add_dispatch(&_M_rep()->_M_info._M_refcount,
-1) <= 0)
_M_rep()->_M_destroy(_M_get_allocator());
} // XXX MT
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
bool
_M_is_leaked() const
{ return _M_rep()->_M_info._M_refcount < 0; }
void
_M_set_sharable()
{ _M_rep()->_M_info._M_refcount = 0; }
void
_M_leak_hard();
// _S_construct_aux is used to implement the 21.3.1 para 15 which
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
// requires special behaviour if _InIterator is an integral type
template<typename _InIterator>
static _CharT*
_S_construct_aux(_InIterator __beg, _InIterator __end,
const _Alloc& __a, __false_type)
{
typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
return _S_construct(__beg, __end, __a, _Tag());
}
template<typename _InIterator>
static _CharT*
_S_construct_aux(_InIterator __beg, _InIterator __end,
const _Alloc& __a, __true_type)
{ return _S_construct(static_cast<size_type>(__beg),
static_cast<value_type>(__end), __a); }
template<typename _InIterator>
static _CharT*
_S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a)
{
typedef typename std::__is_integer<_InIterator>::__type _Integral;
return _S_construct_aux(__beg, __end, __a, _Integral());
}
// For Input Iterators, used in istreambuf_iterators, etc.
template<typename _InIterator>
static _CharT*
_S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
std::input_iterator_tag);
// For forward_iterators up to random_access_iterators, used for
// string::iterator, _CharT*, etc.
template<typename _FwdIterator>
static _CharT*
_S_construct(_FwdIterator __beg, _FwdIterator __end, const _Alloc& __a,
std::forward_iterator_tag);
static _CharT*
_S_construct(size_type __req, _CharT __c, const _Alloc& __a);
public:
size_type
_M_max_size() const
{ return size_type(_S_max_size); }
_CharT*
_M_data() const
{ return _M_dataplus._M_p; }
size_type
_M_length() const
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
{ return _M_rep()->_M_info._M_length; }
size_type
_M_capacity() const
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
{ return _M_rep()->_M_info._M_capacity; }
bool
_M_is_shared() const
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
{ return _M_rep()->_M_info._M_refcount > 0; }
void
_M_set_leaked()
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
{ _M_rep()->_M_info._M_refcount = -1; }
void
_M_leak() // for use in begin() & non-const op[]
{
if (!_M_is_leaked())
_M_leak_hard();
}
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
void
_M_set_length(size_type __n)
{ _M_rep()->_M_set_length(__n); }
__rc_string_base()
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
: _M_dataplus(_Alloc(), _S_empty_rep._M_refcopy()) { }
__rc_string_base(const _Alloc& __a);
__rc_string_base(const __rc_string_base& __rcs);
__rc_string_base(size_type __n, _CharT __c, const _Alloc& __a);
template<typename _InputIterator>
__rc_string_base(_InputIterator __beg, _InputIterator __end,
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
const _Alloc& __a);
~__rc_string_base()
{ _M_dispose(); }
vstring.h (__versa_string<>::operator+, [...]): Move out of line... 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.h (__versa_string<>::operator+, all versions): Move out of line... * include/ext/vstring.tcc (__versa_string<>::operator+): ... here; consistently use reserve for the benefit of sso_string_base; prefer push_back to single-char append when appropriate. * include/ext/vstring.h (__versa_string<>::push_back): Don't call _M_reserve, _M_mutate instead. (reserve): Just forward to _M_reserve. * include/ext/vstring.tcc (__versa_string<>::_M_reserve): Remove. * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): Also do the initial checks (first on length, in case __res == capacity). * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve: Likewise; don't call _M_set_length unnecessarily. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.h (__versa_string<>::_M_append): New. (append(const __versa_string&), append(const __versa_string&, size_type, size_type), append(const _CharT*, size_type), append(const _CharT*)): Use it. (append(size_type, _CharT)): Delegate to _M_replace_aux. (assign(const __versa_string&, size_type, size_type), assign(const _CharT*), replace(size_type, size_type, const _CharT*, size_type)): Forward to _M_replace. * include/ext/vstring.tcc (__versa_string<>::_M_append): Define, core append functionality. (_M_replace): Simplify, move __s == 0 case to _M_replace_aux. (_M_replace_aux): Reorganize, don't call _M_replace. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.tcc (__versa_string<>::_M_replace): Perform _M_check_length at the beginning and remove it from ... (replace, _M_replace_dispatch, _M_replace_aux, assign): ... here. (assign): Now move inline. (resize): Don't call _M_check_length redundantly, append does. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/sso_string_base.h (__sso_string_base<>::_M_get_allocator): Add non const version. * include/ext/rc_string_base.h (__rc_string_base<>::_M_get_allocator): Likewise. * include/ext/sso_string_base.h (__sso_string_base<>::_M_erase): Add. * include/ext/rc_string_base.h (__rc_string_base<>::_M_erase): Likewise. (_M_leak_hard): Use it. * include/ext/vstring.h (__versa_string<>::clear, erase, all versions): Use it. * include/ext/vstring.tcc (__versa_string<>::resize): Likewise. * include/ext/vstring.h (__versa_string<>::_M_replace_safe): Remove. * include/ext/vstring.h (__versa_string<>::_M_replace): New, does the in-place work or delegates to _M_mutate in case of reallocation. * include/ext/vstring.tcc (__versa_string<>::_M_replace_safe): Remove. * include/ext/vstring.tcc (__versa_string<>::_M_replace): Define. (assign, replace, _M_replace_dispatch, _M_replace_aux): Use it. * include/ext/sso_string_base.h (__sso_string_base<>::_M_mutate): Change to manage only reallocations. * include/ext/rc_string_base.h (__rc_string_base<>::_M_mutate): Likewise. * include/ext/vstring.h (__versa_string<>::insert(size_type, const __versa_string&), insert(size_type, const __versa_string&, size_type, size_type), insert(size_type, const _CharT*, size_type), insert(size_type, const _CharT*)): Delegate to replace. * include/ext/vstring.h (__versa_string<>::reserve): Move out of line. * include/ext/vstring.tcc (__versa_string<>::reserve): Do the checks and call _M_reserve. * include/ext/vstring.h (__versa_string<>::append): Call _M_reserve instead of reserve. * include/ext/vstring.tcc (__versa_string<>::append, all versions): Likewise. * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): Likewise. From-SVN: r108034
2005-12-05 01:32:31 +01:00
allocator_type&
_M_get_allocator()
{ return _M_dataplus; }
const allocator_type&
_M_get_allocator() const
{ return _M_dataplus; }
void
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
_M_swap(__rc_string_base& __rcs);
void
_M_assign(const __rc_string_base& __rcs);
void
_M_reserve(size_type __res);
void
vstring.h (__versa_string<>::operator+, [...]): Move out of line... 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.h (__versa_string<>::operator+, all versions): Move out of line... * include/ext/vstring.tcc (__versa_string<>::operator+): ... here; consistently use reserve for the benefit of sso_string_base; prefer push_back to single-char append when appropriate. * include/ext/vstring.h (__versa_string<>::push_back): Don't call _M_reserve, _M_mutate instead. (reserve): Just forward to _M_reserve. * include/ext/vstring.tcc (__versa_string<>::_M_reserve): Remove. * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): Also do the initial checks (first on length, in case __res == capacity). * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve: Likewise; don't call _M_set_length unnecessarily. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.h (__versa_string<>::_M_append): New. (append(const __versa_string&), append(const __versa_string&, size_type, size_type), append(const _CharT*, size_type), append(const _CharT*)): Use it. (append(size_type, _CharT)): Delegate to _M_replace_aux. (assign(const __versa_string&, size_type, size_type), assign(const _CharT*), replace(size_type, size_type, const _CharT*, size_type)): Forward to _M_replace. * include/ext/vstring.tcc (__versa_string<>::_M_append): Define, core append functionality. (_M_replace): Simplify, move __s == 0 case to _M_replace_aux. (_M_replace_aux): Reorganize, don't call _M_replace. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.tcc (__versa_string<>::_M_replace): Perform _M_check_length at the beginning and remove it from ... (replace, _M_replace_dispatch, _M_replace_aux, assign): ... here. (assign): Now move inline. (resize): Don't call _M_check_length redundantly, append does. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/sso_string_base.h (__sso_string_base<>::_M_get_allocator): Add non const version. * include/ext/rc_string_base.h (__rc_string_base<>::_M_get_allocator): Likewise. * include/ext/sso_string_base.h (__sso_string_base<>::_M_erase): Add. * include/ext/rc_string_base.h (__rc_string_base<>::_M_erase): Likewise. (_M_leak_hard): Use it. * include/ext/vstring.h (__versa_string<>::clear, erase, all versions): Use it. * include/ext/vstring.tcc (__versa_string<>::resize): Likewise. * include/ext/vstring.h (__versa_string<>::_M_replace_safe): Remove. * include/ext/vstring.h (__versa_string<>::_M_replace): New, does the in-place work or delegates to _M_mutate in case of reallocation. * include/ext/vstring.tcc (__versa_string<>::_M_replace_safe): Remove. * include/ext/vstring.tcc (__versa_string<>::_M_replace): Define. (assign, replace, _M_replace_dispatch, _M_replace_aux): Use it. * include/ext/sso_string_base.h (__sso_string_base<>::_M_mutate): Change to manage only reallocations. * include/ext/rc_string_base.h (__rc_string_base<>::_M_mutate): Likewise. * include/ext/vstring.h (__versa_string<>::insert(size_type, const __versa_string&), insert(size_type, const __versa_string&, size_type, size_type), insert(size_type, const _CharT*, size_type), insert(size_type, const _CharT*)): Delegate to replace. * include/ext/vstring.h (__versa_string<>::reserve): Move out of line. * include/ext/vstring.tcc (__versa_string<>::reserve): Do the checks and call _M_reserve. * include/ext/vstring.h (__versa_string<>::append): Call _M_reserve instead of reserve. * include/ext/vstring.tcc (__versa_string<>::append, all versions): Likewise. * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): Likewise. From-SVN: r108034
2005-12-05 01:32:31 +01:00
_M_mutate(size_type __pos, size_type __len1, const _CharT* __s,
size_type __len2);
void
_M_erase(size_type __pos, size_type __n);
void
_M_clear()
{ _M_erase(size_type(0), _M_length()); }
bool
_M_compare(const __rc_string_base&) const
{ return false; }
};
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
template<typename _CharT, typename _Traits, typename _Alloc>
typename __rc_string_base<_CharT, _Traits, _Alloc>::_Rep_empty
__rc_string_base<_CharT, _Traits, _Alloc>::_S_empty_rep;
template<typename _CharT, typename _Traits, typename _Alloc>
typename __rc_string_base<_CharT, _Traits, _Alloc>::_Rep*
__rc_string_base<_CharT, _Traits, _Alloc>::_Rep::
_S_create(size_type __capacity, size_type __old_capacity,
const _Alloc& __alloc)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 83. String::npos vs. string::max_size()
if (__capacity > size_type(_S_max_size))
std::__throw_length_error(__N("__rc_string_base::_Rep::_S_create"));
// The standard places no restriction on allocating more memory
// than is strictly needed within this layer at the moment or as
// requested by an explicit application call to reserve().
// Many malloc implementations perform quite poorly when an
// 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).
const size_type __pagesize = 4096;
const size_type __malloc_header_size = 4 * sizeof(void*);
// 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.
if (__capacity > __old_capacity && __capacity < 2 * __old_capacity)
{
__capacity = 2 * __old_capacity;
// Never allocate a string bigger than _S_max_size.
if (__capacity > size_type(_S_max_size))
__capacity = size_type(_S_max_size);
}
// NB: Need an array of char_type[__capacity], plus a terminating
// null char_type() element, plus enough for the _Rep data structure,
vstring.h (__versa_string<>::operator+, [...]): Move out of line... 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.h (__versa_string<>::operator+, all versions): Move out of line... * include/ext/vstring.tcc (__versa_string<>::operator+): ... here; consistently use reserve for the benefit of sso_string_base; prefer push_back to single-char append when appropriate. * include/ext/vstring.h (__versa_string<>::push_back): Don't call _M_reserve, _M_mutate instead. (reserve): Just forward to _M_reserve. * include/ext/vstring.tcc (__versa_string<>::_M_reserve): Remove. * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): Also do the initial checks (first on length, in case __res == capacity). * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve: Likewise; don't call _M_set_length unnecessarily. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.h (__versa_string<>::_M_append): New. (append(const __versa_string&), append(const __versa_string&, size_type, size_type), append(const _CharT*, size_type), append(const _CharT*)): Use it. (append(size_type, _CharT)): Delegate to _M_replace_aux. (assign(const __versa_string&, size_type, size_type), assign(const _CharT*), replace(size_type, size_type, const _CharT*, size_type)): Forward to _M_replace. * include/ext/vstring.tcc (__versa_string<>::_M_append): Define, core append functionality. (_M_replace): Simplify, move __s == 0 case to _M_replace_aux. (_M_replace_aux): Reorganize, don't call _M_replace. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.tcc (__versa_string<>::_M_replace): Perform _M_check_length at the beginning and remove it from ... (replace, _M_replace_dispatch, _M_replace_aux, assign): ... here. (assign): Now move inline. (resize): Don't call _M_check_length redundantly, append does. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/sso_string_base.h (__sso_string_base<>::_M_get_allocator): Add non const version. * include/ext/rc_string_base.h (__rc_string_base<>::_M_get_allocator): Likewise. * include/ext/sso_string_base.h (__sso_string_base<>::_M_erase): Add. * include/ext/rc_string_base.h (__rc_string_base<>::_M_erase): Likewise. (_M_leak_hard): Use it. * include/ext/vstring.h (__versa_string<>::clear, erase, all versions): Use it. * include/ext/vstring.tcc (__versa_string<>::resize): Likewise. * include/ext/vstring.h (__versa_string<>::_M_replace_safe): Remove. * include/ext/vstring.h (__versa_string<>::_M_replace): New, does the in-place work or delegates to _M_mutate in case of reallocation. * include/ext/vstring.tcc (__versa_string<>::_M_replace_safe): Remove. * include/ext/vstring.tcc (__versa_string<>::_M_replace): Define. (assign, replace, _M_replace_dispatch, _M_replace_aux): Use it. * include/ext/sso_string_base.h (__sso_string_base<>::_M_mutate): Change to manage only reallocations. * include/ext/rc_string_base.h (__rc_string_base<>::_M_mutate): Likewise. * include/ext/vstring.h (__versa_string<>::insert(size_type, const __versa_string&), insert(size_type, const __versa_string&, size_type, size_type), insert(size_type, const _CharT*, size_type), insert(size_type, const _CharT*)): Delegate to replace. * include/ext/vstring.h (__versa_string<>::reserve): Move out of line. * include/ext/vstring.tcc (__versa_string<>::reserve): Do the checks and call _M_reserve. * include/ext/vstring.h (__versa_string<>::append): Call _M_reserve instead of reserve. * include/ext/vstring.tcc (__versa_string<>::append, all versions): Likewise. * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): Likewise. From-SVN: r108034
2005-12-05 01:32:31 +01:00
// plus sizeof(_Rep) - 1 to upper round to a size multiple of
// sizeof(_Rep).
// Whew. Seemingly so needy, yet so elemental.
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
size_type __size = ((__capacity + 1) * sizeof(_CharT)
+ 2 * sizeof(_Rep) - 1);
const size_type __adj_size = __size + __malloc_header_size;
if (__adj_size > __pagesize && __capacity > __old_capacity)
{
const size_type __extra = __pagesize - __adj_size % __pagesize;
__capacity += __extra / sizeof(_CharT);
if (__capacity > size_type(_S_max_size))
__capacity = size_type(_S_max_size);
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
__size = (__capacity + 1) * sizeof(_CharT) + 2 * sizeof(_Rep) - 1;
}
// NB: Might throw, but no worries about a leak, mate: _Rep()
// does not throw.
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
_Rep* __place = _Rep_alloc_type(__alloc).allocate(__size / sizeof(_Rep));
_Rep* __p = new (__place) _Rep;
__p->_M_info._M_capacity = __capacity;
return __p;
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
__rc_string_base<_CharT, _Traits, _Alloc>::_Rep::
_M_destroy(const _Alloc& __a) throw ()
{
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
const size_type __size = ((_M_info._M_capacity + 1) * sizeof(_CharT)
+ 2 * sizeof(_Rep) - 1);
_Rep_alloc_type(__a).deallocate(this, __size / sizeof(_Rep));
}
template<typename _CharT, typename _Traits, typename _Alloc>
_CharT*
__rc_string_base<_CharT, _Traits, _Alloc>::_Rep::
_M_clone(const _Alloc& __alloc, size_type __res)
{
// Requested capacity of the clone.
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
const size_type __requested_cap = _M_info._M_length + __res;
_Rep* __r = _Rep::_S_create(__requested_cap, _M_info._M_capacity,
__alloc);
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
if (_M_info._M_length)
_S_copy(__r->_M_refdata(), _M_refdata(), _M_info._M_length);
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
__r->_M_set_length(_M_info._M_length);
return __r->_M_refdata();
}
template<typename _CharT, typename _Traits, typename _Alloc>
__rc_string_base<_CharT, _Traits, _Alloc>::
__rc_string_base(const _Alloc& __a)
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
: _M_dataplus(__a, _S_construct(size_type(), _CharT(), __a)) { }
template<typename _CharT, typename _Traits, typename _Alloc>
__rc_string_base<_CharT, _Traits, _Alloc>::
__rc_string_base(const __rc_string_base& __rcs)
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
: _M_dataplus(__rcs._M_get_allocator(),
__rcs._M_grab(__rcs._M_get_allocator())) { }
template<typename _CharT, typename _Traits, typename _Alloc>
__rc_string_base<_CharT, _Traits, _Alloc>::
__rc_string_base(size_type __n, _CharT __c, const _Alloc& __a)
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
: _M_dataplus(__a, _S_construct(__n, __c, __a)) { }
template<typename _CharT, typename _Traits, typename _Alloc>
template<typename _InputIterator>
__rc_string_base<_CharT, _Traits, _Alloc>::
__rc_string_base(_InputIterator __beg, _InputIterator __end,
const _Alloc& __a)
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
: _M_dataplus(__a, _S_construct(__beg, __end, __a)) { }
template<typename _CharT, typename _Traits, typename _Alloc>
void
__rc_string_base<_CharT, _Traits, _Alloc>::
_M_leak_hard()
{
if (_M_is_shared())
vstring.h (__versa_string<>::operator+, [...]): Move out of line... 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.h (__versa_string<>::operator+, all versions): Move out of line... * include/ext/vstring.tcc (__versa_string<>::operator+): ... here; consistently use reserve for the benefit of sso_string_base; prefer push_back to single-char append when appropriate. * include/ext/vstring.h (__versa_string<>::push_back): Don't call _M_reserve, _M_mutate instead. (reserve): Just forward to _M_reserve. * include/ext/vstring.tcc (__versa_string<>::_M_reserve): Remove. * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): Also do the initial checks (first on length, in case __res == capacity). * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve: Likewise; don't call _M_set_length unnecessarily. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.h (__versa_string<>::_M_append): New. (append(const __versa_string&), append(const __versa_string&, size_type, size_type), append(const _CharT*, size_type), append(const _CharT*)): Use it. (append(size_type, _CharT)): Delegate to _M_replace_aux. (assign(const __versa_string&, size_type, size_type), assign(const _CharT*), replace(size_type, size_type, const _CharT*, size_type)): Forward to _M_replace. * include/ext/vstring.tcc (__versa_string<>::_M_append): Define, core append functionality. (_M_replace): Simplify, move __s == 0 case to _M_replace_aux. (_M_replace_aux): Reorganize, don't call _M_replace. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.tcc (__versa_string<>::_M_replace): Perform _M_check_length at the beginning and remove it from ... (replace, _M_replace_dispatch, _M_replace_aux, assign): ... here. (assign): Now move inline. (resize): Don't call _M_check_length redundantly, append does. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/sso_string_base.h (__sso_string_base<>::_M_get_allocator): Add non const version. * include/ext/rc_string_base.h (__rc_string_base<>::_M_get_allocator): Likewise. * include/ext/sso_string_base.h (__sso_string_base<>::_M_erase): Add. * include/ext/rc_string_base.h (__rc_string_base<>::_M_erase): Likewise. (_M_leak_hard): Use it. * include/ext/vstring.h (__versa_string<>::clear, erase, all versions): Use it. * include/ext/vstring.tcc (__versa_string<>::resize): Likewise. * include/ext/vstring.h (__versa_string<>::_M_replace_safe): Remove. * include/ext/vstring.h (__versa_string<>::_M_replace): New, does the in-place work or delegates to _M_mutate in case of reallocation. * include/ext/vstring.tcc (__versa_string<>::_M_replace_safe): Remove. * include/ext/vstring.tcc (__versa_string<>::_M_replace): Define. (assign, replace, _M_replace_dispatch, _M_replace_aux): Use it. * include/ext/sso_string_base.h (__sso_string_base<>::_M_mutate): Change to manage only reallocations. * include/ext/rc_string_base.h (__rc_string_base<>::_M_mutate): Likewise. * include/ext/vstring.h (__versa_string<>::insert(size_type, const __versa_string&), insert(size_type, const __versa_string&, size_type, size_type), insert(size_type, const _CharT*, size_type), insert(size_type, const _CharT*)): Delegate to replace. * include/ext/vstring.h (__versa_string<>::reserve): Move out of line. * include/ext/vstring.tcc (__versa_string<>::reserve): Do the checks and call _M_reserve. * include/ext/vstring.h (__versa_string<>::append): Call _M_reserve instead of reserve. * include/ext/vstring.tcc (__versa_string<>::append, all versions): Likewise. * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): Likewise. From-SVN: r108034
2005-12-05 01:32:31 +01:00
_M_erase(0, 0);
_M_set_leaked();
}
// 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>
template<typename _InIterator>
_CharT*
__rc_string_base<_CharT, _Traits, _Alloc>::
_S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
std::input_iterator_tag)
{
if (__beg == __end && __a == _Alloc())
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
return _S_empty_rep._M_refcopy();
// Avoid reallocation for common case.
_CharT __buf[128];
size_type __len = 0;
while (__beg != __end && __len < sizeof(__buf) / sizeof(_CharT))
{
__buf[__len++] = *__beg;
++__beg;
}
_Rep* __r = _Rep::_S_create(__len, size_type(0), __a);
_S_copy(__r->_M_refdata(), __buf, __len);
try
{
while (__beg != __end)
{
vstring.h (__versa_string<>::operator+, [...]): Move out of line... 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.h (__versa_string<>::operator+, all versions): Move out of line... * include/ext/vstring.tcc (__versa_string<>::operator+): ... here; consistently use reserve for the benefit of sso_string_base; prefer push_back to single-char append when appropriate. * include/ext/vstring.h (__versa_string<>::push_back): Don't call _M_reserve, _M_mutate instead. (reserve): Just forward to _M_reserve. * include/ext/vstring.tcc (__versa_string<>::_M_reserve): Remove. * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): Also do the initial checks (first on length, in case __res == capacity). * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve: Likewise; don't call _M_set_length unnecessarily. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.h (__versa_string<>::_M_append): New. (append(const __versa_string&), append(const __versa_string&, size_type, size_type), append(const _CharT*, size_type), append(const _CharT*)): Use it. (append(size_type, _CharT)): Delegate to _M_replace_aux. (assign(const __versa_string&, size_type, size_type), assign(const _CharT*), replace(size_type, size_type, const _CharT*, size_type)): Forward to _M_replace. * include/ext/vstring.tcc (__versa_string<>::_M_append): Define, core append functionality. (_M_replace): Simplify, move __s == 0 case to _M_replace_aux. (_M_replace_aux): Reorganize, don't call _M_replace. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.tcc (__versa_string<>::_M_replace): Perform _M_check_length at the beginning and remove it from ... (replace, _M_replace_dispatch, _M_replace_aux, assign): ... here. (assign): Now move inline. (resize): Don't call _M_check_length redundantly, append does. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/sso_string_base.h (__sso_string_base<>::_M_get_allocator): Add non const version. * include/ext/rc_string_base.h (__rc_string_base<>::_M_get_allocator): Likewise. * include/ext/sso_string_base.h (__sso_string_base<>::_M_erase): Add. * include/ext/rc_string_base.h (__rc_string_base<>::_M_erase): Likewise. (_M_leak_hard): Use it. * include/ext/vstring.h (__versa_string<>::clear, erase, all versions): Use it. * include/ext/vstring.tcc (__versa_string<>::resize): Likewise. * include/ext/vstring.h (__versa_string<>::_M_replace_safe): Remove. * include/ext/vstring.h (__versa_string<>::_M_replace): New, does the in-place work or delegates to _M_mutate in case of reallocation. * include/ext/vstring.tcc (__versa_string<>::_M_replace_safe): Remove. * include/ext/vstring.tcc (__versa_string<>::_M_replace): Define. (assign, replace, _M_replace_dispatch, _M_replace_aux): Use it. * include/ext/sso_string_base.h (__sso_string_base<>::_M_mutate): Change to manage only reallocations. * include/ext/rc_string_base.h (__rc_string_base<>::_M_mutate): Likewise. * include/ext/vstring.h (__versa_string<>::insert(size_type, const __versa_string&), insert(size_type, const __versa_string&, size_type, size_type), insert(size_type, const _CharT*, size_type), insert(size_type, const _CharT*)): Delegate to replace. * include/ext/vstring.h (__versa_string<>::reserve): Move out of line. * include/ext/vstring.tcc (__versa_string<>::reserve): Do the checks and call _M_reserve. * include/ext/vstring.h (__versa_string<>::append): Call _M_reserve instead of reserve. * include/ext/vstring.tcc (__versa_string<>::append, all versions): Likewise. * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): Likewise. From-SVN: r108034
2005-12-05 01:32:31 +01:00
if (__len == __r->_M_info._M_capacity)
{
// Allocate more space.
_Rep* __another = _Rep::_S_create(__len + 1, __len, __a);
_S_copy(__another->_M_refdata(), __r->_M_refdata(), __len);
__r->_M_destroy(__a);
__r = __another;
}
__r->_M_refdata()[__len++] = *__beg;
++__beg;
}
}
catch(...)
{
__r->_M_destroy(__a);
__throw_exception_again;
}
__r->_M_set_length(__len);
return __r->_M_refdata();
}
template<typename _CharT, typename _Traits, typename _Alloc>
template<typename _InIterator>
_CharT*
__rc_string_base<_CharT, _Traits, _Alloc>::
_S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
std::forward_iterator_tag)
{
if (__beg == __end && __a == _Alloc())
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
return _S_empty_rep._M_refcopy();
// NB: Not required, but considered best practice.
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
if (__builtin_expect(_S_is_null_pointer(__beg) && __beg != __end, 0))
std::__throw_logic_error(__N("__rc_string_base::"
"_S_construct NULL not valid"));
const size_type __dnew = static_cast<size_type>(std::distance(__beg,
__end));
// Check for out_of_range and length_error exceptions.
_Rep* __r = _Rep::_S_create(__dnew, size_type(0), __a);
try
{ _S_copy_chars(__r->_M_refdata(), __beg, __end); }
catch(...)
{
__r->_M_destroy(__a);
__throw_exception_again;
}
__r->_M_set_length(__dnew);
return __r->_M_refdata();
}
template<typename _CharT, typename _Traits, typename _Alloc>
_CharT*
__rc_string_base<_CharT, _Traits, _Alloc>::
_S_construct(size_type __n, _CharT __c, const _Alloc& __a)
{
if (__n == 0 && __a == _Alloc())
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
return _S_empty_rep._M_refcopy();
// Check for out_of_range and length_error exceptions.
_Rep* __r = _Rep::_S_create(__n, size_type(0), __a);
if (__n)
_S_assign(__r->_M_refdata(), __n, __c);
__r->_M_set_length(__n);
return __r->_M_refdata();
}
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
template<typename _CharT, typename _Traits, typename _Alloc>
void
__rc_string_base<_CharT, _Traits, _Alloc>::
_M_swap(__rc_string_base& __rcs)
{
if (_M_is_leaked())
_M_set_sharable();
if (__rcs._M_is_leaked())
__rcs._M_set_sharable();
_CharT* __tmp = _M_data();
_M_data(__rcs._M_data());
__rcs._M_data(__tmp);
sso_string_base.h (__sso_string_base<>::_M_dataplus): Use _CharT_alloc_type as base class. 2006-01-04 Paolo Carlini <pcarlini@suse.de> * include/ext/sso_string_base.h (__sso_string_base<>::_M_dataplus): Use _CharT_alloc_type as base class. (_M_get_allocator, _M_swap, _M_create, _M_destroy): Adjust. * include/ext/vstring.h (get_allocator): Tidy. 2006-01-04 Paolo Carlini <pcarlini@suse.de> Implement Option 3 of DR 431 for all the containers. * include/bits/allocator.h (struct __alloc_swap): Add, swaps allocators, optimized to nothing in case they are empty. * include/bits/stl_deque.h (deque<>::swap): Use it. * include/bits/stl_list.h (list<>::swap): Likewise. * include/bits/stl_tree.h (_Rb_tree<>::swap): Likewise. * include/bits/stl_vector.h (vector<>::swap): Likewise. * include/tr1/hashtable (hashtable<>::swap): Likewise. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Likewise. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. * include/ext/vstring_util.h (__vstring_utility<>::_Alloc_hider): Clean-up (now vstring uses the generic __alloc_swap facility). * include/tr1/unordered_map: Adjust includes. * include/tr1/unordered_set: Likewise. * docs/html/ext/howto.html: Add an entry for DR 431. * testsuite/23_containers/deque/modifiers/swap.cc: Move to... * testsuite/23_containers/deque/modifiers/swap/1.cc: ... here. * testsuite/23_containers/deque/modifiers/swap/2.cc: New. * testsuite/23_containers/deque/modifiers/swap/3.cc: New. * testsuite/23_containers/list/modifiers/swap.cc: Move to... * testsuite/23_containers/list/modifiers/swap/1.cc: ... here. * testsuite/23_containers/list/modifiers/swap/2.cc: New. * testsuite/23_containers/list/modifiers/swap/3.cc: New. * testsuite/23_containers/vector/modifiers/swap.cc: Move to... * testsuite/23_containers/vector/modifiers/swap/1.cc: ... here. * testsuite/23_containers/vector/modifiers/swap/2.cc: New. * testsuite/23_containers/vector/modifiers/swap/3.cc: New. * testsuite/23_containers/set/modifiers/swap.cc: Move to... * testsuite/23_containers/set/modifiers/swap/1.cc: ... here. * testsuite/23_containers/set/modifiers/swap/2.cc: New. * testsuite/23_containers/set/modifiers/swap/3.cc: New. * testsuite/23_containers/map/modifiers/swap.cc: Move to... * testsuite/23_containers/map/modifiers/swap/1.cc: ... here. * testsuite/23_containers/map/modifiers/swap/2.cc: New. * testsuite/23_containers/map/modifiers/swap/3.cc: New. * testsuite/23_containers/multiset/modifiers/swap.cc: Move to... * testsuite/23_containers/multiset/modifiers/swap/1.cc: ... here. * testsuite/23_containers/multiset/modifiers/swap/2.cc: New. * testsuite/23_containers/multiset/modifiers/swap/3.cc: New. * testsuite/23_containers/multimap/modifiers/swap.cc: Move to... * testsuite/23_containers/multimap/modifiers/swap/1.cc: ... here. * testsuite/23_containers/multimap/modifiers/swap/2.cc: New. * testsuite/23_containers/multimap/modifiers/swap/3.cc: New. * testsuite/tr1/6_containers/unordered/swap/unordered_set/1.cc: New. * testsuite/tr1/6_containers/unordered/swap/unordered_set/2.cc: New. * testsuite/tr1/6_containers/unordered/swap/unordered_map/1.cc: New. * testsuite/tr1/6_containers/unordered/swap/unordered_map/2.cc: New. * testsuite/tr1/6_containers/unordered/swap/unordered_multiset/1.cc: New. * testsuite/tr1/6_containers/unordered/swap/unordered_multiset/2.cc: New. * testsuite/tr1/6_containers/unordered/swap/unordered_multimap/1.cc: New. * testsuite/tr1/6_containers/unordered/swap/unordered_multimap/2.cc: New. From-SVN: r109324
2006-01-04 12:34:45 +01:00
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 431. Swapping containers with unequal allocators.
std::__alloc_swap<allocator_type>::_S_do_it(_M_get_allocator(),
__rcs._M_get_allocator());
rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. 2005-11-18 Paolo Carlini <pcarlini@suse.de> * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the anonymous struct extension, adjust everywhere. * include/ext/rc_string_base.h (__rc_string_base<>::_S_empty_rep()): Just use a static member. (__rc_string_base<>::__rc_string_base(), _S_construct): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Use anonymous union together with _CharT to fix alignment issues, rebind to _Rep and rename _Raw_alloc to _Rep_alloc_type. (__rc_string_base<>::_Rep::_S_create, _M_destroy): Adjust consistently. * include/ext/vstring_util.h (__is_null_p): Move inside struct __vstring_utility as static _S_is_null_pointer. * include/ext/sso_string.h (__sso_string_base<>::_M_construct(std::forward_iterator_tag): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_S_construct(std::forward_iterator_tag): Likewise. Implement Option 3 of DR 431 for ext/vstring - both available bases. * include/bits/cpp_type_traits.h (struct __is_empty): Add. * include/ext/vstring.h (__versa_string<>::swap): Delegate to this->_M_swap. * include/ext/vstring.tcc (__versa_string<>::swap): Remove. * include/ext/vstring_util.h (struct __vstring_utility<>): Add struct _Alloc_hider<>, augmented of allocator swapping facility, specialized to nop for empty allocators. * include/ext/rc_string_base.h (__rc_string_base<>::_M_swap): Use it. (__rc_string_base<>::_M_is_leaked, _M_set_sharable): Change to private. * include/ext/sso_string_base.h (__sso_string_base<>::_M_swap): Likewise. (__sso_string_base<>::_M_is_leaked, _M_set_sharable): Remove, unused. * include/ext/rc_string_base.h (__rc_string_base<>::_M_data(_CharT*): Return void. * include/ext/sso_string_base.h (__sso_string_base<>::_M_data(_CharT*): Likewise. From-SVN: r107176
2005-11-18 12:50:22 +01:00
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
__rc_string_base<_CharT, _Traits, _Alloc>::
_M_assign(const __rc_string_base& __rcs)
{
if (_M_rep() != __rcs._M_rep())
{
_CharT* __tmp = __rcs._M_grab(_M_get_allocator());
_M_dispose();
_M_data(__tmp);
}
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
__rc_string_base<_CharT, _Traits, _Alloc>::
_M_reserve(size_type __res)
{
vstring.h (__versa_string<>::operator+, [...]): Move out of line... 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.h (__versa_string<>::operator+, all versions): Move out of line... * include/ext/vstring.tcc (__versa_string<>::operator+): ... here; consistently use reserve for the benefit of sso_string_base; prefer push_back to single-char append when appropriate. * include/ext/vstring.h (__versa_string<>::push_back): Don't call _M_reserve, _M_mutate instead. (reserve): Just forward to _M_reserve. * include/ext/vstring.tcc (__versa_string<>::_M_reserve): Remove. * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): Also do the initial checks (first on length, in case __res == capacity). * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve: Likewise; don't call _M_set_length unnecessarily. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.h (__versa_string<>::_M_append): New. (append(const __versa_string&), append(const __versa_string&, size_type, size_type), append(const _CharT*, size_type), append(const _CharT*)): Use it. (append(size_type, _CharT)): Delegate to _M_replace_aux. (assign(const __versa_string&, size_type, size_type), assign(const _CharT*), replace(size_type, size_type, const _CharT*, size_type)): Forward to _M_replace. * include/ext/vstring.tcc (__versa_string<>::_M_append): Define, core append functionality. (_M_replace): Simplify, move __s == 0 case to _M_replace_aux. (_M_replace_aux): Reorganize, don't call _M_replace. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.tcc (__versa_string<>::_M_replace): Perform _M_check_length at the beginning and remove it from ... (replace, _M_replace_dispatch, _M_replace_aux, assign): ... here. (assign): Now move inline. (resize): Don't call _M_check_length redundantly, append does. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/sso_string_base.h (__sso_string_base<>::_M_get_allocator): Add non const version. * include/ext/rc_string_base.h (__rc_string_base<>::_M_get_allocator): Likewise. * include/ext/sso_string_base.h (__sso_string_base<>::_M_erase): Add. * include/ext/rc_string_base.h (__rc_string_base<>::_M_erase): Likewise. (_M_leak_hard): Use it. * include/ext/vstring.h (__versa_string<>::clear, erase, all versions): Use it. * include/ext/vstring.tcc (__versa_string<>::resize): Likewise. * include/ext/vstring.h (__versa_string<>::_M_replace_safe): Remove. * include/ext/vstring.h (__versa_string<>::_M_replace): New, does the in-place work or delegates to _M_mutate in case of reallocation. * include/ext/vstring.tcc (__versa_string<>::_M_replace_safe): Remove. * include/ext/vstring.tcc (__versa_string<>::_M_replace): Define. (assign, replace, _M_replace_dispatch, _M_replace_aux): Use it. * include/ext/sso_string_base.h (__sso_string_base<>::_M_mutate): Change to manage only reallocations. * include/ext/rc_string_base.h (__rc_string_base<>::_M_mutate): Likewise. * include/ext/vstring.h (__versa_string<>::insert(size_type, const __versa_string&), insert(size_type, const __versa_string&, size_type, size_type), insert(size_type, const _CharT*, size_type), insert(size_type, const _CharT*)): Delegate to replace. * include/ext/vstring.h (__versa_string<>::reserve): Move out of line. * include/ext/vstring.tcc (__versa_string<>::reserve): Do the checks and call _M_reserve. * include/ext/vstring.h (__versa_string<>::append): Call _M_reserve instead of reserve. * include/ext/vstring.tcc (__versa_string<>::append, all versions): Likewise. * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): Likewise. From-SVN: r108034
2005-12-05 01:32:31 +01:00
// Make sure we don't shrink below the current size.
if (__res < _M_length())
__res = _M_length();
if (__res != _M_capacity() || _M_is_shared())
{
_CharT* __tmp = _M_rep()->_M_clone(_M_get_allocator(),
__res - _M_length());
_M_dispose();
_M_data(__tmp);
}
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
__rc_string_base<_CharT, _Traits, _Alloc>::
vstring.h (__versa_string<>::operator+, [...]): Move out of line... 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.h (__versa_string<>::operator+, all versions): Move out of line... * include/ext/vstring.tcc (__versa_string<>::operator+): ... here; consistently use reserve for the benefit of sso_string_base; prefer push_back to single-char append when appropriate. * include/ext/vstring.h (__versa_string<>::push_back): Don't call _M_reserve, _M_mutate instead. (reserve): Just forward to _M_reserve. * include/ext/vstring.tcc (__versa_string<>::_M_reserve): Remove. * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): Also do the initial checks (first on length, in case __res == capacity). * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve: Likewise; don't call _M_set_length unnecessarily. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.h (__versa_string<>::_M_append): New. (append(const __versa_string&), append(const __versa_string&, size_type, size_type), append(const _CharT*, size_type), append(const _CharT*)): Use it. (append(size_type, _CharT)): Delegate to _M_replace_aux. (assign(const __versa_string&, size_type, size_type), assign(const _CharT*), replace(size_type, size_type, const _CharT*, size_type)): Forward to _M_replace. * include/ext/vstring.tcc (__versa_string<>::_M_append): Define, core append functionality. (_M_replace): Simplify, move __s == 0 case to _M_replace_aux. (_M_replace_aux): Reorganize, don't call _M_replace. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.tcc (__versa_string<>::_M_replace): Perform _M_check_length at the beginning and remove it from ... (replace, _M_replace_dispatch, _M_replace_aux, assign): ... here. (assign): Now move inline. (resize): Don't call _M_check_length redundantly, append does. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/sso_string_base.h (__sso_string_base<>::_M_get_allocator): Add non const version. * include/ext/rc_string_base.h (__rc_string_base<>::_M_get_allocator): Likewise. * include/ext/sso_string_base.h (__sso_string_base<>::_M_erase): Add. * include/ext/rc_string_base.h (__rc_string_base<>::_M_erase): Likewise. (_M_leak_hard): Use it. * include/ext/vstring.h (__versa_string<>::clear, erase, all versions): Use it. * include/ext/vstring.tcc (__versa_string<>::resize): Likewise. * include/ext/vstring.h (__versa_string<>::_M_replace_safe): Remove. * include/ext/vstring.h (__versa_string<>::_M_replace): New, does the in-place work or delegates to _M_mutate in case of reallocation. * include/ext/vstring.tcc (__versa_string<>::_M_replace_safe): Remove. * include/ext/vstring.tcc (__versa_string<>::_M_replace): Define. (assign, replace, _M_replace_dispatch, _M_replace_aux): Use it. * include/ext/sso_string_base.h (__sso_string_base<>::_M_mutate): Change to manage only reallocations. * include/ext/rc_string_base.h (__rc_string_base<>::_M_mutate): Likewise. * include/ext/vstring.h (__versa_string<>::insert(size_type, const __versa_string&), insert(size_type, const __versa_string&, size_type, size_type), insert(size_type, const _CharT*, size_type), insert(size_type, const _CharT*)): Delegate to replace. * include/ext/vstring.h (__versa_string<>::reserve): Move out of line. * include/ext/vstring.tcc (__versa_string<>::reserve): Do the checks and call _M_reserve. * include/ext/vstring.h (__versa_string<>::append): Call _M_reserve instead of reserve. * include/ext/vstring.tcc (__versa_string<>::append, all versions): Likewise. * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): Likewise. From-SVN: r108034
2005-12-05 01:32:31 +01:00
_M_mutate(size_type __pos, size_type __len1, const _CharT* __s,
size_type __len2)
{
vstring.h (__versa_string<>::operator+, [...]): Move out of line... 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.h (__versa_string<>::operator+, all versions): Move out of line... * include/ext/vstring.tcc (__versa_string<>::operator+): ... here; consistently use reserve for the benefit of sso_string_base; prefer push_back to single-char append when appropriate. * include/ext/vstring.h (__versa_string<>::push_back): Don't call _M_reserve, _M_mutate instead. (reserve): Just forward to _M_reserve. * include/ext/vstring.tcc (__versa_string<>::_M_reserve): Remove. * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): Also do the initial checks (first on length, in case __res == capacity). * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve: Likewise; don't call _M_set_length unnecessarily. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.h (__versa_string<>::_M_append): New. (append(const __versa_string&), append(const __versa_string&, size_type, size_type), append(const _CharT*, size_type), append(const _CharT*)): Use it. (append(size_type, _CharT)): Delegate to _M_replace_aux. (assign(const __versa_string&, size_type, size_type), assign(const _CharT*), replace(size_type, size_type, const _CharT*, size_type)): Forward to _M_replace. * include/ext/vstring.tcc (__versa_string<>::_M_append): Define, core append functionality. (_M_replace): Simplify, move __s == 0 case to _M_replace_aux. (_M_replace_aux): Reorganize, don't call _M_replace. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.tcc (__versa_string<>::_M_replace): Perform _M_check_length at the beginning and remove it from ... (replace, _M_replace_dispatch, _M_replace_aux, assign): ... here. (assign): Now move inline. (resize): Don't call _M_check_length redundantly, append does. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/sso_string_base.h (__sso_string_base<>::_M_get_allocator): Add non const version. * include/ext/rc_string_base.h (__rc_string_base<>::_M_get_allocator): Likewise. * include/ext/sso_string_base.h (__sso_string_base<>::_M_erase): Add. * include/ext/rc_string_base.h (__rc_string_base<>::_M_erase): Likewise. (_M_leak_hard): Use it. * include/ext/vstring.h (__versa_string<>::clear, erase, all versions): Use it. * include/ext/vstring.tcc (__versa_string<>::resize): Likewise. * include/ext/vstring.h (__versa_string<>::_M_replace_safe): Remove. * include/ext/vstring.h (__versa_string<>::_M_replace): New, does the in-place work or delegates to _M_mutate in case of reallocation. * include/ext/vstring.tcc (__versa_string<>::_M_replace_safe): Remove. * include/ext/vstring.tcc (__versa_string<>::_M_replace): Define. (assign, replace, _M_replace_dispatch, _M_replace_aux): Use it. * include/ext/sso_string_base.h (__sso_string_base<>::_M_mutate): Change to manage only reallocations. * include/ext/rc_string_base.h (__rc_string_base<>::_M_mutate): Likewise. * include/ext/vstring.h (__versa_string<>::insert(size_type, const __versa_string&), insert(size_type, const __versa_string&, size_type, size_type), insert(size_type, const _CharT*, size_type), insert(size_type, const _CharT*)): Delegate to replace. * include/ext/vstring.h (__versa_string<>::reserve): Move out of line. * include/ext/vstring.tcc (__versa_string<>::reserve): Do the checks and call _M_reserve. * include/ext/vstring.h (__versa_string<>::append): Call _M_reserve instead of reserve. * include/ext/vstring.tcc (__versa_string<>::append, all versions): Likewise. * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): Likewise. From-SVN: r108034
2005-12-05 01:32:31 +01:00
const size_type __how_much = _M_length() - __pos - __len1;
_Rep* __r = _Rep::_S_create(_M_length() + __len2 - __len1,
_M_capacity(), _M_get_allocator());
vstring.h (__versa_string<>::operator+, [...]): Move out of line... 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.h (__versa_string<>::operator+, all versions): Move out of line... * include/ext/vstring.tcc (__versa_string<>::operator+): ... here; consistently use reserve for the benefit of sso_string_base; prefer push_back to single-char append when appropriate. * include/ext/vstring.h (__versa_string<>::push_back): Don't call _M_reserve, _M_mutate instead. (reserve): Just forward to _M_reserve. * include/ext/vstring.tcc (__versa_string<>::_M_reserve): Remove. * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): Also do the initial checks (first on length, in case __res == capacity). * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve: Likewise; don't call _M_set_length unnecessarily. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.h (__versa_string<>::_M_append): New. (append(const __versa_string&), append(const __versa_string&, size_type, size_type), append(const _CharT*, size_type), append(const _CharT*)): Use it. (append(size_type, _CharT)): Delegate to _M_replace_aux. (assign(const __versa_string&, size_type, size_type), assign(const _CharT*), replace(size_type, size_type, const _CharT*, size_type)): Forward to _M_replace. * include/ext/vstring.tcc (__versa_string<>::_M_append): Define, core append functionality. (_M_replace): Simplify, move __s == 0 case to _M_replace_aux. (_M_replace_aux): Reorganize, don't call _M_replace. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.tcc (__versa_string<>::_M_replace): Perform _M_check_length at the beginning and remove it from ... (replace, _M_replace_dispatch, _M_replace_aux, assign): ... here. (assign): Now move inline. (resize): Don't call _M_check_length redundantly, append does. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/sso_string_base.h (__sso_string_base<>::_M_get_allocator): Add non const version. * include/ext/rc_string_base.h (__rc_string_base<>::_M_get_allocator): Likewise. * include/ext/sso_string_base.h (__sso_string_base<>::_M_erase): Add. * include/ext/rc_string_base.h (__rc_string_base<>::_M_erase): Likewise. (_M_leak_hard): Use it. * include/ext/vstring.h (__versa_string<>::clear, erase, all versions): Use it. * include/ext/vstring.tcc (__versa_string<>::resize): Likewise. * include/ext/vstring.h (__versa_string<>::_M_replace_safe): Remove. * include/ext/vstring.h (__versa_string<>::_M_replace): New, does the in-place work or delegates to _M_mutate in case of reallocation. * include/ext/vstring.tcc (__versa_string<>::_M_replace_safe): Remove. * include/ext/vstring.tcc (__versa_string<>::_M_replace): Define. (assign, replace, _M_replace_dispatch, _M_replace_aux): Use it. * include/ext/sso_string_base.h (__sso_string_base<>::_M_mutate): Change to manage only reallocations. * include/ext/rc_string_base.h (__rc_string_base<>::_M_mutate): Likewise. * include/ext/vstring.h (__versa_string<>::insert(size_type, const __versa_string&), insert(size_type, const __versa_string&, size_type, size_type), insert(size_type, const _CharT*, size_type), insert(size_type, const _CharT*)): Delegate to replace. * include/ext/vstring.h (__versa_string<>::reserve): Move out of line. * include/ext/vstring.tcc (__versa_string<>::reserve): Do the checks and call _M_reserve. * include/ext/vstring.h (__versa_string<>::append): Call _M_reserve instead of reserve. * include/ext/vstring.tcc (__versa_string<>::append, all versions): Likewise. * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): Likewise. From-SVN: r108034
2005-12-05 01:32:31 +01:00
if (__pos)
_S_copy(__r->_M_refdata(), _M_data(), __pos);
if (__s && __len2)
_S_copy(__r->_M_refdata() + __pos, __s, __len2);
if (__how_much)
_S_copy(__r->_M_refdata() + __pos + __len2,
_M_data() + __pos + __len1, __how_much);
_M_dispose();
_M_data(__r->_M_refdata());
}
template<typename _CharT, typename _Traits, typename _Alloc>
void
__rc_string_base<_CharT, _Traits, _Alloc>::
_M_erase(size_type __pos, size_type __n)
{
const size_type __new_size = _M_length() - __n;
const size_type __how_much = _M_length() - __pos - __n;
if (_M_is_shared())
{
// Must reallocate.
_Rep* __r = _Rep::_S_create(__new_size, _M_capacity(),
_M_get_allocator());
if (__pos)
_S_copy(__r->_M_refdata(), _M_data(), __pos);
if (__how_much)
vstring.h (__versa_string<>::operator+, [...]): Move out of line... 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.h (__versa_string<>::operator+, all versions): Move out of line... * include/ext/vstring.tcc (__versa_string<>::operator+): ... here; consistently use reserve for the benefit of sso_string_base; prefer push_back to single-char append when appropriate. * include/ext/vstring.h (__versa_string<>::push_back): Don't call _M_reserve, _M_mutate instead. (reserve): Just forward to _M_reserve. * include/ext/vstring.tcc (__versa_string<>::_M_reserve): Remove. * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): Also do the initial checks (first on length, in case __res == capacity). * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve: Likewise; don't call _M_set_length unnecessarily. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.h (__versa_string<>::_M_append): New. (append(const __versa_string&), append(const __versa_string&, size_type, size_type), append(const _CharT*, size_type), append(const _CharT*)): Use it. (append(size_type, _CharT)): Delegate to _M_replace_aux. (assign(const __versa_string&, size_type, size_type), assign(const _CharT*), replace(size_type, size_type, const _CharT*, size_type)): Forward to _M_replace. * include/ext/vstring.tcc (__versa_string<>::_M_append): Define, core append functionality. (_M_replace): Simplify, move __s == 0 case to _M_replace_aux. (_M_replace_aux): Reorganize, don't call _M_replace. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.tcc (__versa_string<>::_M_replace): Perform _M_check_length at the beginning and remove it from ... (replace, _M_replace_dispatch, _M_replace_aux, assign): ... here. (assign): Now move inline. (resize): Don't call _M_check_length redundantly, append does. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/sso_string_base.h (__sso_string_base<>::_M_get_allocator): Add non const version. * include/ext/rc_string_base.h (__rc_string_base<>::_M_get_allocator): Likewise. * include/ext/sso_string_base.h (__sso_string_base<>::_M_erase): Add. * include/ext/rc_string_base.h (__rc_string_base<>::_M_erase): Likewise. (_M_leak_hard): Use it. * include/ext/vstring.h (__versa_string<>::clear, erase, all versions): Use it. * include/ext/vstring.tcc (__versa_string<>::resize): Likewise. * include/ext/vstring.h (__versa_string<>::_M_replace_safe): Remove. * include/ext/vstring.h (__versa_string<>::_M_replace): New, does the in-place work or delegates to _M_mutate in case of reallocation. * include/ext/vstring.tcc (__versa_string<>::_M_replace_safe): Remove. * include/ext/vstring.tcc (__versa_string<>::_M_replace): Define. (assign, replace, _M_replace_dispatch, _M_replace_aux): Use it. * include/ext/sso_string_base.h (__sso_string_base<>::_M_mutate): Change to manage only reallocations. * include/ext/rc_string_base.h (__rc_string_base<>::_M_mutate): Likewise. * include/ext/vstring.h (__versa_string<>::insert(size_type, const __versa_string&), insert(size_type, const __versa_string&, size_type, size_type), insert(size_type, const _CharT*, size_type), insert(size_type, const _CharT*)): Delegate to replace. * include/ext/vstring.h (__versa_string<>::reserve): Move out of line. * include/ext/vstring.tcc (__versa_string<>::reserve): Do the checks and call _M_reserve. * include/ext/vstring.h (__versa_string<>::append): Call _M_reserve instead of reserve. * include/ext/vstring.tcc (__versa_string<>::append, all versions): Likewise. * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): Likewise. From-SVN: r108034
2005-12-05 01:32:31 +01:00
_S_copy(__r->_M_refdata() + __pos,
_M_data() + __pos + __n, __how_much);
_M_dispose();
_M_data(__r->_M_refdata());
}
vstring.h (__versa_string<>::operator+, [...]): Move out of line... 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.h (__versa_string<>::operator+, all versions): Move out of line... * include/ext/vstring.tcc (__versa_string<>::operator+): ... here; consistently use reserve for the benefit of sso_string_base; prefer push_back to single-char append when appropriate. * include/ext/vstring.h (__versa_string<>::push_back): Don't call _M_reserve, _M_mutate instead. (reserve): Just forward to _M_reserve. * include/ext/vstring.tcc (__versa_string<>::_M_reserve): Remove. * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): Also do the initial checks (first on length, in case __res == capacity). * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve: Likewise; don't call _M_set_length unnecessarily. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.h (__versa_string<>::_M_append): New. (append(const __versa_string&), append(const __versa_string&, size_type, size_type), append(const _CharT*, size_type), append(const _CharT*)): Use it. (append(size_type, _CharT)): Delegate to _M_replace_aux. (assign(const __versa_string&, size_type, size_type), assign(const _CharT*), replace(size_type, size_type, const _CharT*, size_type)): Forward to _M_replace. * include/ext/vstring.tcc (__versa_string<>::_M_append): Define, core append functionality. (_M_replace): Simplify, move __s == 0 case to _M_replace_aux. (_M_replace_aux): Reorganize, don't call _M_replace. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.tcc (__versa_string<>::_M_replace): Perform _M_check_length at the beginning and remove it from ... (replace, _M_replace_dispatch, _M_replace_aux, assign): ... here. (assign): Now move inline. (resize): Don't call _M_check_length redundantly, append does. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/sso_string_base.h (__sso_string_base<>::_M_get_allocator): Add non const version. * include/ext/rc_string_base.h (__rc_string_base<>::_M_get_allocator): Likewise. * include/ext/sso_string_base.h (__sso_string_base<>::_M_erase): Add. * include/ext/rc_string_base.h (__rc_string_base<>::_M_erase): Likewise. (_M_leak_hard): Use it. * include/ext/vstring.h (__versa_string<>::clear, erase, all versions): Use it. * include/ext/vstring.tcc (__versa_string<>::resize): Likewise. * include/ext/vstring.h (__versa_string<>::_M_replace_safe): Remove. * include/ext/vstring.h (__versa_string<>::_M_replace): New, does the in-place work or delegates to _M_mutate in case of reallocation. * include/ext/vstring.tcc (__versa_string<>::_M_replace_safe): Remove. * include/ext/vstring.tcc (__versa_string<>::_M_replace): Define. (assign, replace, _M_replace_dispatch, _M_replace_aux): Use it. * include/ext/sso_string_base.h (__sso_string_base<>::_M_mutate): Change to manage only reallocations. * include/ext/rc_string_base.h (__rc_string_base<>::_M_mutate): Likewise. * include/ext/vstring.h (__versa_string<>::insert(size_type, const __versa_string&), insert(size_type, const __versa_string&, size_type, size_type), insert(size_type, const _CharT*, size_type), insert(size_type, const _CharT*)): Delegate to replace. * include/ext/vstring.h (__versa_string<>::reserve): Move out of line. * include/ext/vstring.tcc (__versa_string<>::reserve): Do the checks and call _M_reserve. * include/ext/vstring.h (__versa_string<>::append): Call _M_reserve instead of reserve. * include/ext/vstring.tcc (__versa_string<>::append, all versions): Likewise. * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): Likewise. From-SVN: r108034
2005-12-05 01:32:31 +01:00
else if (__how_much && __n)
{
// Work in-place.
vstring.h (__versa_string<>::operator+, [...]): Move out of line... 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.h (__versa_string<>::operator+, all versions): Move out of line... * include/ext/vstring.tcc (__versa_string<>::operator+): ... here; consistently use reserve for the benefit of sso_string_base; prefer push_back to single-char append when appropriate. * include/ext/vstring.h (__versa_string<>::push_back): Don't call _M_reserve, _M_mutate instead. (reserve): Just forward to _M_reserve. * include/ext/vstring.tcc (__versa_string<>::_M_reserve): Remove. * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): Also do the initial checks (first on length, in case __res == capacity). * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve: Likewise; don't call _M_set_length unnecessarily. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.h (__versa_string<>::_M_append): New. (append(const __versa_string&), append(const __versa_string&, size_type, size_type), append(const _CharT*, size_type), append(const _CharT*)): Use it. (append(size_type, _CharT)): Delegate to _M_replace_aux. (assign(const __versa_string&, size_type, size_type), assign(const _CharT*), replace(size_type, size_type, const _CharT*, size_type)): Forward to _M_replace. * include/ext/vstring.tcc (__versa_string<>::_M_append): Define, core append functionality. (_M_replace): Simplify, move __s == 0 case to _M_replace_aux. (_M_replace_aux): Reorganize, don't call _M_replace. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.tcc (__versa_string<>::_M_replace): Perform _M_check_length at the beginning and remove it from ... (replace, _M_replace_dispatch, _M_replace_aux, assign): ... here. (assign): Now move inline. (resize): Don't call _M_check_length redundantly, append does. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/sso_string_base.h (__sso_string_base<>::_M_get_allocator): Add non const version. * include/ext/rc_string_base.h (__rc_string_base<>::_M_get_allocator): Likewise. * include/ext/sso_string_base.h (__sso_string_base<>::_M_erase): Add. * include/ext/rc_string_base.h (__rc_string_base<>::_M_erase): Likewise. (_M_leak_hard): Use it. * include/ext/vstring.h (__versa_string<>::clear, erase, all versions): Use it. * include/ext/vstring.tcc (__versa_string<>::resize): Likewise. * include/ext/vstring.h (__versa_string<>::_M_replace_safe): Remove. * include/ext/vstring.h (__versa_string<>::_M_replace): New, does the in-place work or delegates to _M_mutate in case of reallocation. * include/ext/vstring.tcc (__versa_string<>::_M_replace_safe): Remove. * include/ext/vstring.tcc (__versa_string<>::_M_replace): Define. (assign, replace, _M_replace_dispatch, _M_replace_aux): Use it. * include/ext/sso_string_base.h (__sso_string_base<>::_M_mutate): Change to manage only reallocations. * include/ext/rc_string_base.h (__rc_string_base<>::_M_mutate): Likewise. * include/ext/vstring.h (__versa_string<>::insert(size_type, const __versa_string&), insert(size_type, const __versa_string&, size_type, size_type), insert(size_type, const _CharT*, size_type), insert(size_type, const _CharT*)): Delegate to replace. * include/ext/vstring.h (__versa_string<>::reserve): Move out of line. * include/ext/vstring.tcc (__versa_string<>::reserve): Do the checks and call _M_reserve. * include/ext/vstring.h (__versa_string<>::append): Call _M_reserve instead of reserve. * include/ext/vstring.tcc (__versa_string<>::append, all versions): Likewise. * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): Likewise. From-SVN: r108034
2005-12-05 01:32:31 +01:00
_S_move(_M_data() + __pos,
_M_data() + __pos + __n, __how_much);
}
vstring.h (__versa_string<>::operator+, [...]): Move out of line... 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.h (__versa_string<>::operator+, all versions): Move out of line... * include/ext/vstring.tcc (__versa_string<>::operator+): ... here; consistently use reserve for the benefit of sso_string_base; prefer push_back to single-char append when appropriate. * include/ext/vstring.h (__versa_string<>::push_back): Don't call _M_reserve, _M_mutate instead. (reserve): Just forward to _M_reserve. * include/ext/vstring.tcc (__versa_string<>::_M_reserve): Remove. * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): Also do the initial checks (first on length, in case __res == capacity). * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve: Likewise; don't call _M_set_length unnecessarily. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.h (__versa_string<>::_M_append): New. (append(const __versa_string&), append(const __versa_string&, size_type, size_type), append(const _CharT*, size_type), append(const _CharT*)): Use it. (append(size_type, _CharT)): Delegate to _M_replace_aux. (assign(const __versa_string&, size_type, size_type), assign(const _CharT*), replace(size_type, size_type, const _CharT*, size_type)): Forward to _M_replace. * include/ext/vstring.tcc (__versa_string<>::_M_append): Define, core append functionality. (_M_replace): Simplify, move __s == 0 case to _M_replace_aux. (_M_replace_aux): Reorganize, don't call _M_replace. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/vstring.tcc (__versa_string<>::_M_replace): Perform _M_check_length at the beginning and remove it from ... (replace, _M_replace_dispatch, _M_replace_aux, assign): ... here. (assign): Now move inline. (resize): Don't call _M_check_length redundantly, append does. 2005-12-04 Paolo Carlini <pcarlini@suse.de> * include/ext/sso_string_base.h (__sso_string_base<>::_M_get_allocator): Add non const version. * include/ext/rc_string_base.h (__rc_string_base<>::_M_get_allocator): Likewise. * include/ext/sso_string_base.h (__sso_string_base<>::_M_erase): Add. * include/ext/rc_string_base.h (__rc_string_base<>::_M_erase): Likewise. (_M_leak_hard): Use it. * include/ext/vstring.h (__versa_string<>::clear, erase, all versions): Use it. * include/ext/vstring.tcc (__versa_string<>::resize): Likewise. * include/ext/vstring.h (__versa_string<>::_M_replace_safe): Remove. * include/ext/vstring.h (__versa_string<>::_M_replace): New, does the in-place work or delegates to _M_mutate in case of reallocation. * include/ext/vstring.tcc (__versa_string<>::_M_replace_safe): Remove. * include/ext/vstring.tcc (__versa_string<>::_M_replace): Define. (assign, replace, _M_replace_dispatch, _M_replace_aux): Use it. * include/ext/sso_string_base.h (__sso_string_base<>::_M_mutate): Change to manage only reallocations. * include/ext/rc_string_base.h (__rc_string_base<>::_M_mutate): Likewise. * include/ext/vstring.h (__versa_string<>::insert(size_type, const __versa_string&), insert(size_type, const __versa_string&, size_type, size_type), insert(size_type, const _CharT*, size_type), insert(size_type, const _CharT*)): Delegate to replace. * include/ext/vstring.h (__versa_string<>::reserve): Move out of line. * include/ext/vstring.tcc (__versa_string<>::reserve): Do the checks and call _M_reserve. * include/ext/vstring.h (__versa_string<>::append): Call _M_reserve instead of reserve. * include/ext/vstring.tcc (__versa_string<>::append, all versions): Likewise. * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve): Adjust. * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): Likewise. From-SVN: r108034
2005-12-05 01:32:31 +01:00
_M_rep()->_M_set_length(__new_size);
}
template<>
inline bool
__rc_string_base<char, std::char_traits<char>,
std::allocator<char> >::
_M_compare(const __rc_string_base& __rcs) const
{
if (_M_rep() == __rcs._M_rep())
return true;
return false;
}
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
inline bool
__rc_string_base<wchar_t, std::char_traits<wchar_t>,
std::allocator<wchar_t> >::
_M_compare(const __rc_string_base& __rcs) const
{
if (_M_rep() == __rcs._M_rep())
return true;
return false;
}
#endif
c++config: Add in revised namespace associations. 2005-12-18 Benjamin Kosnik <bkoz@redhat.com> * include/bits/c++config: Add in revised namespace associations. _GLIBCXX_BEGIN_NAMESPACE: New macro. _GLIBCXX_END_NAMESPACE: Same. _GLIBCXX_BEGIN_NESTED_NAMESPACE: Same. _GLIBCXX_END_NESTED_NAMESPACE: Same. * acinclude.m4 (GLIBCXX_ENABLE_SYMVERS]): Add gnu-versioned-namespace. * configure: Regenerated. * config.h.in: Same. * config/abi/pre/gnu-versioned-namespace.ver: New. * config/abi/pre/gnu.ver (GLIBCXX_3.4.7): Add exports for nested debug mode items. * include/Makefile.am (${host_builddir}/c++config.h): Fill in values for __GLIBCXX__ and _GLIBCXX_NAMESPACE_ASSOCIATION_VERSION. * include/Makefile.in: Regnerate. * src/compatibility.cc: Alias new, nested definitions to exported symbols from non-nested __gnu_debug. * src/Makefile.am: Add in ENABLE_SYMVERS_GNU_NAMESPACE. * src/Makefile.in: Regenerate. * docs/html/debug_mode.html: Revise for nested design. * docs/html/debug.html: Use debug qualifications instead of __gnu_debug. * docs/html/configopts.html: Revise documentation for --enable-symvers. * include/debug/formatter: Simplify namespace qualifications for current, nested-only reality. Add top-level namespace alias, namespace debug, for debug-mode containers. * include/debug/safe_iterator.h: Same. * include/debug/set.h: Same. * include/debug/hash_multimap.h: Same. * include/debug/hash_set.h: Same. * include/debug/bitset * include/debug/safe_sequence.h: Same. * include/debug/multiset.h: Same. * include/debug/safe_base.h: Same. * include/debug/functions.h: Same. * include/debug/safe_iterator.tcc * include/debug/hash_multiset.h: Same. * include/debug/vector * include/debug/map.h: Same. * include/debug/deque * include/debug/hash_map.h: Same. * include/debug/string * include/debug/macros.h: Same. * include/debug/list * include/debug/debug.h: Same. * include/debug/multimap.h: Same. * src/debug.cc: Same. * testsuite/23_containers/vector/invalidation/1.cc: Cleanups. * testsuite/23_containers/vector/invalidation/2.cc: Same. * testsuite/23_containers/vector/invalidation/3.cc: Same. * testsuite/23_containers/vector/invalidation/4.cc: Same. * testsuite/23_containers/deque/invalidation/1.cc: Same. * testsuite/23_containers/deque/invalidation/2.cc: Same. * testsuite/23_containers/deque/invalidation/3.cc: Same. * testsuite/23_containers/deque/invalidation/4.cc: Same. * testsuite/23_containers/multiset/invalidation/1.cc: Same. * testsuite/23_containers/multiset/invalidation/2.cc: Same. * testsuite/23_containers/multimap/invalidation/1.cc: Same. * testsuite/23_containers/multimap/invalidation/2.cc: Same. * testsuite/23_containers/bitset/invalidation/1.cc: Same. * testsuite/23_containers/bitset/cons/16020.cc: Same. * testsuite/23_containers/bitset/operations/13838.cc: Same. * testsuite/23_containers/list/invalidation/1.cc: Same. * testsuite/23_containers/list/invalidation/2.cc: Same. * testsuite/23_containers/list/invalidation/3.cc: Same. * testsuite/23_containers/list/invalidation/4.cc: Same. * testsuite/23_containers/set/invalidation/1.cc: Same. * testsuite/23_containers/set/invalidation/2.cc: Same. * testsuite/23_containers/map/invalidation/1.cc: Same. * testsuite/23_containers/map/invalidation/2.cc: Same. * testsuite/23_containers/map/insert/16813.cc: Same. * include/bits/basic_ios.h: Use _GLIBCXX_BEGIN_NAMESPACE(std) and friends. * include/bits/stl_list.h: Same. * include/bits/stl_map.h: Same. * include/bits/stl_algobase.h: Same. * include/bits/localefwd.h: Same. * include/bits/valarray_array.tcc: Same. * include/bits/valarray_after.h: Same. * include/bits/gslice_array.h: Same. * include/bits/stl_queue.h: Same. * include/bits/gslice.h: Same. * include/bits/locale_facets.tcc: Same. * include/bits/locale_classes.h: Same. * include/bits/stl_set.h: Same. * include/bits/locale_facets.h: Same. * include/bits/stl_stack.h: Same. * include/bits/stl_iterator_base_types.h: Same. * include/bits/stl_heap.h: Same. * include/bits/indirect_array.h: Same. * include/bits/atomicity.h: Same. * include/bits/stream_iterator.h: Same. * include/bits/concurrence.h: Same. * include/bits/basic_string.h: Same. * include/bits/stl_multimap.h: Same. * include/bits/stl_pair.h: Same. * include/bits/basic_ios.tcc: Same. * include/bits/stl_raw_storage_iter.h: Same. * include/bits/stl_vector.h: Same. * include/bits/stl_numeric.h: Same. * include/bits/ios_base.h: Same. * include/bits/stl_deque.h: Same. * include/bits/istream.tcc: Same. * include/bits/postypes.h: Same. * include/bits/stl_multiset.h: Same. * include/bits/mask_array.h: Same. * include/bits/stl_uninitialized.h: Same. * include/bits/ostream.tcc: Same. * include/bits/slice_array.h: Same. * include/bits/boost_concept_check.h: Same. * include/bits/sstream.tcc: Same. * include/bits/stl_iterator_base_funcs.h: Same. * include/bits/char_traits.h: Same. * include/bits/stl_algo.h: Same. * include/bits/stringfwd.h: Same. * include/bits/c++config * include/bits/stl_iterator.h: Same. * include/bits/valarray_array.h: Same. * include/bits/stl_tempbuf.h: Same. * include/bits/vector.tcc: Same. * include/bits/deque.tcc: Same. * include/bits/stl_bvector.h: Same. * include/bits/basic_string.tcc: Same. * include/bits/list.tcc: Same. * include/bits/streambuf_iterator.h: Same. * include/bits/valarray_before.h: Same. * include/bits/stl_construct.h: Same. * include/bits/stl_function.h: Same. * include/bits/cpp_type_traits.h: Same. * include/bits/streambuf.tcc: Same. * include/bits/allocator.h: Same. * include/bits/stl_tree.h: Same. * include/bits/fstream.tcc: Same. * include/bits/stl_relops.h: Same. * include/bits/functexcept.h: Same. * include/std/std_valarray.h: Same. * include/std/std_iostream.h: Same. * include/std/std_streambuf.h: Same. * include/std/std_bitset.h: Same. * include/std/std_iosfwd.h: Same. * include/std/std_iomanip.h: Same. * include/std/std_fstream.h: Same. * include/std/std_limits.h: Same. * include/std/std_stdexcept.h: Same. * include/std/std_istream.h: Same. * include/std/std_complex.h: Same. * include/std/std_memory.h: Same. * include/std/std_ostream.h: Same. * include/std/std_sstream.h: Same. * include/c_std/std_csignal.h: Same. * include/c_std/std_cstdlib.h: Same. * include/c_std/std_cstdio.h: Same. * include/c_std/std_cstdarg.h: Same. * include/c_std/std_cctype.h: Same. * include/c_std/std_cmath.h: Same. * include/c_std/std_ctime.h: Same. * include/c_std/std_clocale.h: Same. * include/c_std/std_csetjmp.h: Same. * include/c_std/std_cwchar.h: Same. * include/c_std/std_cstring.h: Same. * include/c_std/std_cstddef.h: Same. * include/c_std/std_cwctype.h: Same. * include/backward/iterator.h: Same. * include/backward/set.h: Same. * include/backward/hashtable.h: Same. * include/backward/fstream.h: Same. * include/backward/tempbuf.h: Same. * include/backward/istream.h: Same. * include/backward/bvector.h: Same. * include/backward/stack.h: Same. * include/backward/rope.h: Same. * include/backward/complex.h: Same. * include/backward/ostream.h: Same. * include/backward/heap.h: Same. * include/backward/iostream.h: Same. * include/backward/function.h: Same. * include/backward/multimap.h: Same. * include/backward/pair.h: Same. * include/backward/stream.h: Same. * include/backward/iomanip.h: Same. * include/backward/strstream * include/backward/slist.h: Same. * include/backward/tree.h: Same. * include/backward/vector.h: Same. * include/backward/deque.h: Same. * include/backward/multiset.h: Same. * include/backward/list.h: Same. * include/backward/map.h: Same. * include/backward/algobase.h: Same. * include/backward/hash_map.h: Same. * include/backward/algo.h: Same. * include/backward/queue.h: Same. * include/backward/streambuf.h: Same. * src/allocator-inst.cc: Same. * src/complex_io.cc: Same. * src/localename.cc: Same. * src/limits.cc: Same. * src/ios_failure.cc: Same. * src/locale-misc-inst.cc: Same. * src/streambuf-inst.cc: Same. * src/misc-inst.cc: Same. * src/concept-inst.cc: Same. * src/ios_locale.cc: Same. * src/pool_allocator.cc: Same. * src/fstream-inst.cc: Same. * src/istream-inst.cc: Same. * src/string-inst.cc: Same. * src/locale_init.cc: Same. * src/ctype.cc: Same. * src/strstream.cc: Same. * src/ostream-inst.cc: Same. * src/functexcept.cc: Same. * src/streambuf.cc: Same. * src/sstream-inst.cc: Same. * src/ios.cc: Same. * src/valarray-inst.cc: Same. * src/locale.cc: Same. * src/tree.cc: Same. * src/stdexcept.cc: Same. * src/istream.cc: Same. * src/compatibility.cc: Same. * src/locale-inst.cc: Same. * src/globals_io.cc: Same. * src/list.cc: Same. * src/ios_init.cc: Same. * src/locale_facets.cc: Same. * src/codecvt.cc: Same. * include/tr1/unordered_map: Use _GLIBCXX_BEGIN_NAMESPACE(tr1). * include/tr1/boost_shared_ptr.h: Same. * include/tr1/tuple * include/tr1/hashtable * include/tr1/type_traits_fwd.h: Same. * include/tr1/unordered_set * include/tr1/functional * include/tr1/ref_fwd.h: Same. * include/tr1/utility * include/tr1/type_traits * include/tr1/array * include/ext/hashtable.h: Use _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx). * include/ext/typelist.h: Same. * include/ext/hash_map: Same. * include/ext/rc_string_base.h: Same. * include/ext/pool_allocator.h: Same. * include/ext/iterator: Same. * include/ext/rb_tree: Same. * include/ext/numeric: Same. * include/ext/vstring.tcc: Same. * include/ext/sso_string_base.h: Same. * include/ext/stdio_filebuf.h: Same. * include/ext/algorithm: Same. * include/ext/codecvt_specializations.h: Same. * include/ext/new_allocator.h: Same. * include/ext/array_allocator.h: Same. * include/ext/vstring_util.h: Same. * include/ext/vstring_fwd.h: Same. * include/ext/mt_allocator.h: Same. * include/ext/debug_allocator.h: Same. * include/ext/slist: Same. * include/ext/stdio_sync_filebuf.h: Same. * include/ext/hash_fun.h: Same. * include/ext/malloc_allocator.h: Same. * include/ext/functional: Same. * include/ext/bitmap_allocator.h: Same. * include/ext/pod_char_traits.h: Same. * include/ext/vstring.h: Same. * include/ext/ropeimpl.h: Same. * include/ext/hash_set: Same. * include/ext/memory: Same. * include/ext/rope: Same. * include/bits/boost_concept_check.h: Same. * include/bits/stl_iterator.h: Same. * include/bits/char_traits.h: Same. * include/bits/cpp_type_traits.h: Same. * include/bits/concurrence.h: Same. * include/bits/atomicity.h: Same. * config/locale/gnu/numeric_members.cc: Same. * config/locale/gnu/collate_members.cc: Same. * config/locale/gnu/ctype_members.cc: Same. * config/locale/gnu/c_locale.cc: Same. * config/locale/gnu/codecvt_members.cc: Same. * config/locale/gnu/messages_members.cc: Same. * config/locale/gnu/c_locale.h: Same. * config/locale/gnu/monetary_members.cc: Same. * config/locale/gnu/time_members.cc: Same. * config/locale/ieee_1003.1-2001/c_locale.h: Same. * config/locale/generic/numeric_members.cc: Same. * config/locale/generic/collate_members.cc: Same. * config/locale/generic/ctype_members.cc: Same. * config/locale/generic/c_locale.cc: Same. * config/locale/generic/codecvt_members.cc: Same. * config/locale/generic/messages_members.cc: Same. * config/locale/generic/c_locale.h: Same. * config/locale/generic/monetary_members.cc: Same. * config/locale/generic/time_members.cc: Same. * config/os/aix/atomicity.h: Same. * config/os/irix/atomicity.h: Same. * config/cpu/powerpc/atomicity.h: Same. * config/cpu/cris/atomicity.h: Same. * config/cpu/ia64/atomicity.h: Same. * config/cpu/alpha/atomicity.h: Same. * config/cpu/m68k/atomicity.h: Same. * config/cpu/hppa/atomicity.h: Same. * config/cpu/mips/atomicity.h: Same. * config/cpu/sparc/atomicity.h: Same. * config/cpu/i386/atomicity.h: Same. * config/cpu/i486/atomicity.h: Same. * config/cpu/sh/atomicity.h: Same. * config/cpu/generic/atomicity.h: Same. * config/cpu/s390/atomicity.h: Same. * config/io/c_io_stdio.h: Same. * config/io/basic_file_stdio.cc: Same. * config/io/basic_file_stdio.h: Same. * src/misc-inst.cc: Same. * src/concept-inst.cc: Same. * src/ext-inst.cc: Same. * src/string-inst.cc: Same. * src/pool_allocator.cc: Same. * src/bitmap_allocator.cc: Same. * src/mt_allocator.cc: Same. * libsupc++/exception: Same. * libsupc++/vterminate.cc: Same. * testsuite/ext/hash_map/1.cc: Explicitly qualify __gnu_cxx::hash_map. * testsuite/ext/hash_map/14648.cc: Same. * libsupc++/eh_alloc.cc: Correct comment line spacing. From-SVN: r108775
2005-12-19 01:56:05 +01:00
_GLIBCXX_END_NAMESPACE
#endif /* _RC_STRING_BASE_H */