2000-10-05 13:27:02 +02:00
|
|
|
// Components for manipulating sequences of characters -*- C++ -*-
|
|
|
|
|
basic_string.h (basic_string<>::_S_compare): Add.
2007-01-18 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (basic_string<>::_S_compare): Add.
(compare(const basic_string&)): Use it.
* include/bits/basic_string.tcc (compare(size_type, size_type,
const basic_string&), compare(size_type, size_type,
const basic_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
* include/ext/vstring_util.h (__vstring_utility<>::_S_compare): Add.
* include/ext/vstring.h (compare(const __versa_string&)): Use it.
* include/ext/vstring.tcc (compare(size_type, size_type,
const __versa_string&), compare(size_type, size_type,
const __versa_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
From-SVN: r120896
2007-01-18 13:03:35 +01:00
|
|
|
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
2010-01-10 14:38:47 +01:00
|
|
|
// 2006, 2007, 2008, 2009, 2010
|
2002-01-14 Paolo Carlini <pcarlini@unitus.it>
Nathan Myers <ncm@cantrip.org>
* include/bits/basic_string.h
(replace(__pos, __n1, __s, __n2)): Optimize by avoiding
temporaries (i.e., call _M_replace_safe) when possible.
(replace(__pos, __n, __str)): Call replace(__pos, __n1, __s, __n2).
(replace(__pos, __n1, __s)): Call replace(__pos, __n1, __s , __n2).
(replace(__i1, __i2, __str)): Call replace(__i1, __i2, __s, __n).
(replace(__i1, __i2, __s)): Call replace(__i1, __i2, __s, __n).
(replace(__i1, __i2, __s, __n)): Call replace(__pos1, __n1, __s, __n2).
* include/bits/basic_string.tcc
(replace(__pos1, __n1, __str, __pos2, __n2)): Call
replace(__pos, __n1, __s, __n2).
* testsuite/21_strings/replace.cc (test03): New testcases.
* include/bits/basic_string.h (insert(__pos, __s, __n)):
Adjust comparison wrt overflow.
Co-Authored-By: Nathan Myers <ncm@cantrip.org>
From-SVN: r48834
2002-01-14 20:04:15 +01:00
|
|
|
// Free Software Foundation, Inc.
|
2000-10-05 13:27:02 +02:00
|
|
|
//
|
|
|
|
// This file is part of the GNU ISO C++ Library. This library is free
|
|
|
|
// software; you can redistribute it and/or modify it under the
|
|
|
|
// terms of the GNU General Public License as published by the
|
2009-04-09 17:00:19 +02:00
|
|
|
// Free Software Foundation; either version 3, or (at your option)
|
2000-10-05 13:27:02 +02:00
|
|
|
// any later version.
|
|
|
|
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
2009-04-09 17:00:19 +02:00
|
|
|
// Under Section 7 of GPL version 3, you are granted additional
|
|
|
|
// permissions described in the GCC Runtime Library Exception, version
|
|
|
|
// 3.1, as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License and
|
|
|
|
// a copy of the GCC Runtime Library Exception along with this program;
|
|
|
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
// <http://www.gnu.org/licenses/>.
|
2000-10-05 13:27:02 +02:00
|
|
|
|
c_io_stdio.h: Correct grammar in comments.
2001-11-02 Phil Edwards <pme@gcc.gnu.org>
* config/io/c_io_stdio.h: Correct grammar in comments.
* docs/doxygen/Intro.3: Expand "top-level" man page.
* docs/doxygen/doxygroups.cc: New module definitions (comments).
* docs/doxygen/mainpage.doxy: Tweaks.
* docs/doxygen/run_doxygen: Update Doxygen version, massage man pages.
Add @file hooks so that headers are considered to be documented.
* include/bits/basic_ios.h, include/bits/basic_file.h,
include/bits/basic_string.h, include/bits/boost_concept_check.h,
include/bits/char_traits.h, include/bits/codecvt.h,
include/bits/concept_check.h, include/bits/cpp_type_traits.h,
include/bits/fpos.h, include/bits/gslice.h, include/bits/gslice_array.h,
include/bits/indirect_array.h, include/bits/ios_base.h,
include/bits/locale_facets.h, include/bits/localefwd.h,
include/bits/mask_array.h, include/bits/pthread_allocimpl.h,
include/bits/slice.h, include/bits/slice_array.h,
include/bits/std_algorithm.h, include/bits/std_bitset.h,
include/bits/std_complex.h, include/bits/std_deque.h,
include/bits/std_fstream.h, include/bits/std_functional.h,
include/bits/std_iomanip.h, include/bits/std_ios.h,
include/bits/std_iosfwd.h, include/bits/std_iostream.h,
include/bits/std_istream.h, include/bits/std_iterator.h,
include/bits/std_limits.h, include/bits/std_list.h,
include/bits/std_locale.h, include/bits/std_map.h,
include/bits/std_memory.h, include/bits/std_numeric.h,
include/bits/std_ostream.h, include/bits/std_queue.h,
include/bits/std_set.h, include/bits/std_sstream.h,
include/bits/std_stack.h, include/bits/std_streambuf.h,
include/bits/std_string.h, include/bits/std_utility.h,
include/bits/std_valarray.h, include/bits/std_vector.h,
include/bits/stl_algo.h, include/bits/stl_alloc.h,
include/bits/stl_bvector.h, include/bits/stl_construct.h,
include/bits/stl_deque.h, include/bits/stl_heap.h,
include/bits/stl_iterator.h, include/bits/stl_iterator_base_funcs.h,
include/bits/stl_iterator_base_types.h, include/bits/stl_list.h,
include/bits/stl_map.h, include/bits/stl_multimap.h,
include/bits/stl_multiset.h, include/bits/stl_numeric.h,
include/bits/stl_pair.h, include/bits/stl_pthread_alloc.h,
include/bits/stl_queue.h, include/bits/stl_raw_storage_iter.h,
include/bits/stl_relops.h, include/bits/stl_set.h,
include/bits/stl_stack.h, include/bits/stl_tempbuf.h,
include/bits/stl_threads.h, include/bits/stl_tree.h,
include/bits/stl_uninitialized.h, include/bits/stl_vector.h,
include/bits/stream_iterator.h, include/bits/streambuf_iterator.h,
include/bits/stringfwd.h, include/bits/type_traits.h,
include/bits/valarray_array.h, include/bits/valarray_meta.h:
Add hooks, tweak comments only.
* include/bits/stl_algobase.h (swap, min, iter_swap): Also
document these functions.
* include/bits/stl_function.h: Tweak link comments.
From-SVN: r46717
2001-11-02 18:38:11 +01:00
|
|
|
/** @file basic_string.h
|
|
|
|
* This is an internal header file, included by other library headers.
|
|
|
|
* You should not attempt to use it directly.
|
|
|
|
*/
|
|
|
|
|
2006-12-06 00:24:07 +01:00
|
|
|
//
|
|
|
|
// ISO C++ 14882: 21 Strings library
|
|
|
|
//
|
|
|
|
|
2003-07-05 06:05:45 +02:00
|
|
|
#ifndef _BASIC_STRING_H
|
|
|
|
#define _BASIC_STRING_H 1
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2001-02-19 19:52:25 +01:00
|
|
|
#pragma GCC system_header
|
|
|
|
|
2006-09-14 11:48:15 +02:00
|
|
|
#include <ext/atomicity.h>
|
2003-11-11 21:09:16 +01:00
|
|
|
#include <debug/debug.h>
|
2008-07-21 21:40:39 +02:00
|
|
|
#include <initializer_list>
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2005-12-19 01:56:05 +01:00
|
|
|
_GLIBCXX_BEGIN_NAMESPACE(std)
|
|
|
|
|
2002-09-01 02:33:53 +02:00
|
|
|
/**
|
|
|
|
* @class basic_string basic_string.h <string>
|
|
|
|
* @brief Managing sequences of characters and character-like objects.
|
|
|
|
*
|
2009-02-19 09:15:15 +01:00
|
|
|
* @ingroup sequences
|
2002-09-01 02:33:53 +02:00
|
|
|
*
|
|
|
|
* Meets the requirements of a <a href="tables.html#65">container</a>, a
|
|
|
|
* <a href="tables.html#66">reversible container</a>, and a
|
|
|
|
* <a href="tables.html#67">sequence</a>. Of the
|
|
|
|
* <a href="tables.html#68">optional sequence requirements</a>, only
|
|
|
|
* @c push_back, @c at, and array access are supported.
|
|
|
|
*
|
|
|
|
* @doctodo
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Documentation? What's that?
|
|
|
|
* Nathan Myers <ncm@cantrip.org>.
|
|
|
|
*
|
|
|
|
* A string looks like this:
|
|
|
|
*
|
|
|
|
* @code
|
|
|
|
* [_Rep]
|
|
|
|
* _M_length
|
|
|
|
* [basic_string<char_type>] _M_capacity
|
2004-02-07 00:02:45 +01:00
|
|
|
* _M_dataplus _M_refcount
|
2002-09-01 02:33:53 +02:00
|
|
|
* _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_data(), and
|
|
|
|
* string::_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.
|
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
// 21.3 Template class basic_string
|
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
class basic_string
|
|
|
|
{
|
2005-06-03 19:07:48 +02:00
|
|
|
typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
|
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
// Types:
|
|
|
|
public:
|
2004-02-08 05:46:42 +01:00
|
|
|
typedef _Traits traits_type;
|
|
|
|
typedef typename _Traits::char_type value_type;
|
|
|
|
typedef _Alloc allocator_type;
|
2005-06-03 19:07:48 +02:00
|
|
|
typedef typename _CharT_alloc_type::size_type size_type;
|
|
|
|
typedef typename _CharT_alloc_type::difference_type difference_type;
|
|
|
|
typedef typename _CharT_alloc_type::reference reference;
|
|
|
|
typedef typename _CharT_alloc_type::const_reference const_reference;
|
|
|
|
typedef typename _CharT_alloc_type::pointer pointer;
|
|
|
|
typedef typename _CharT_alloc_type::const_pointer const_pointer;
|
2002-04-16 04:29:22 +02:00
|
|
|
typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
|
|
|
|
typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
|
|
|
|
const_iterator;
|
2004-02-08 05:46:42 +01:00
|
|
|
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
|
|
|
typedef std::reverse_iterator<iterator> reverse_iterator;
|
2002-09-01 02:33:53 +02:00
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
private:
|
|
|
|
// _Rep: string representation
|
|
|
|
// Invariants:
|
2004-01-18 11:51:13 +01:00
|
|
|
// 1. String really contains _M_length + 1 characters: due to 21.3.4
|
|
|
|
// must be kept null-terminated.
|
2000-10-05 13:27:02 +02:00
|
|
|
// 2. _M_capacity >= _M_length
|
2004-01-31 18:50:46 +01:00
|
|
|
// Allocated memory is always (_M_capacity + 1) * sizeof(_CharT).
|
2003-12-15 20:48:50 +01:00
|
|
|
// 3. _M_refcount has three states:
|
2000-10-05 13:27:02 +02:00
|
|
|
// -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.
|
|
|
|
// 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.
|
Avoid multi-processor bus contention on increment/decrement-and- test of the reference count in the empty-string object...
2003-06-13 Nathan C. Myers <ncm-nospam@cantrip.org>
Avoid multi-processor bus contention on increment/decrement-and-
test of the reference count in the empty-string object, by comparing
addresses first, and never touching the reference count of the empty-
string object.
* include/bits/basic_string.h:
(_S_empty_rep_storage): Move into basic_string<>::_Rep for use by its
members.
(_Rep::_S_empty_rep()): New accessor.
(_Rep::_M_length, _Rep::_M_capacity, _Rep::_M_references): Move to
a base class _Rep_base.
(_Rep::_M_dispose, _Rep::_M_refcopy): Check for the empty string.
(basic_string()): Change to use _M_refdata() in place of _M_refcopy(),
since no longer must increment its refcount.
* include/bits/basic_string.tcc:
(_Rep::_M_destroy, _M_leak_hard): Check for the empty string and
return immediately. The former might be unnecessary. The latter
prevents begin() and end() from cloning it unnecessarily.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
input_iterator_tag), _S_construct(_InIterator, _InIterator,
const _Alloc&, forward_iterator_tag), _S_construct(size_type, _CharT,
const _Alloc&)): Change to use _M_refdata() in place of _M_refcopy().
(_M_mutate): Check for the empty string and treat it as shared.
This is necessary here because _M_mutate is sometimes called with
all-zero arguments; in all other uses of _M_is_shared, the test comes
out right anyhow.
From-SVN: r67912
2003-06-13 22:59:42 +02:00
|
|
|
|
|
|
|
struct _Rep_base
|
|
|
|
{
|
2004-02-08 05:46:42 +01:00
|
|
|
size_type _M_length;
|
|
|
|
size_type _M_capacity;
|
2003-12-15 20:48:50 +01:00
|
|
|
_Atomic_word _M_refcount;
|
Avoid multi-processor bus contention on increment/decrement-and- test of the reference count in the empty-string object...
2003-06-13 Nathan C. Myers <ncm-nospam@cantrip.org>
Avoid multi-processor bus contention on increment/decrement-and-
test of the reference count in the empty-string object, by comparing
addresses first, and never touching the reference count of the empty-
string object.
* include/bits/basic_string.h:
(_S_empty_rep_storage): Move into basic_string<>::_Rep for use by its
members.
(_Rep::_S_empty_rep()): New accessor.
(_Rep::_M_length, _Rep::_M_capacity, _Rep::_M_references): Move to
a base class _Rep_base.
(_Rep::_M_dispose, _Rep::_M_refcopy): Check for the empty string.
(basic_string()): Change to use _M_refdata() in place of _M_refcopy(),
since no longer must increment its refcount.
* include/bits/basic_string.tcc:
(_Rep::_M_destroy, _M_leak_hard): Check for the empty string and
return immediately. The former might be unnecessary. The latter
prevents begin() and end() from cloning it unnecessarily.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
input_iterator_tag), _S_construct(_InIterator, _InIterator,
const _Alloc&, forward_iterator_tag), _S_construct(size_type, _CharT,
const _Alloc&)): Change to use _M_refdata() in place of _M_refcopy().
(_M_mutate): Check for the empty string and treat it as shared.
This is necessary here because _M_mutate is sometimes called with
all-zero arguments; in all other uses of _M_is_shared, the test comes
out right anyhow.
From-SVN: r67912
2003-06-13 22:59:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _Rep : _Rep_base
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
|
|
|
// Types:
|
2005-05-28 23:57:03 +02:00
|
|
|
typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2002-09-01 02:33:53 +02:00
|
|
|
// (Public) Data members:
|
2000-10-05 13:27:02 +02:00
|
|
|
|
|
|
|
// 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
|
2002-09-01 02:33:53 +02:00
|
|
|
// look like this:
|
2000-10-05 13:27:02 +02:00
|
|
|
// npos = sizeof(_Rep) + (m * sizeof(_CharT)) + sizeof(_CharT)
|
|
|
|
// Solving for m:
|
2002-09-01 02:33:53 +02:00
|
|
|
// m = ((npos - sizeof(_Rep))/sizeof(CharT)) - 1
|
Avoid multi-processor bus contention on increment/decrement-and- test of the reference count in the empty-string object...
2003-06-13 Nathan C. Myers <ncm-nospam@cantrip.org>
Avoid multi-processor bus contention on increment/decrement-and-
test of the reference count in the empty-string object, by comparing
addresses first, and never touching the reference count of the empty-
string object.
* include/bits/basic_string.h:
(_S_empty_rep_storage): Move into basic_string<>::_Rep for use by its
members.
(_Rep::_S_empty_rep()): New accessor.
(_Rep::_M_length, _Rep::_M_capacity, _Rep::_M_references): Move to
a base class _Rep_base.
(_Rep::_M_dispose, _Rep::_M_refcopy): Check for the empty string.
(basic_string()): Change to use _M_refdata() in place of _M_refcopy(),
since no longer must increment its refcount.
* include/bits/basic_string.tcc:
(_Rep::_M_destroy, _M_leak_hard): Check for the empty string and
return immediately. The former might be unnecessary. The latter
prevents begin() and end() from cloning it unnecessarily.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
input_iterator_tag), _S_construct(_InIterator, _InIterator,
const _Alloc&, forward_iterator_tag), _S_construct(size_type, _CharT,
const _Alloc&)): Change to use _M_refdata() in place of _M_refcopy().
(_M_mutate): Check for the empty string and treat it as shared.
This is necessary here because _M_mutate is sometimes called with
all-zero arguments; in all other uses of _M_is_shared, the test comes
out right anyhow.
From-SVN: r67912
2003-06-13 22:59:42 +02:00
|
|
|
// In addition, this implementation quarters this amount.
|
2004-02-08 05:46:42 +01:00
|
|
|
static const size_type _S_max_size;
|
|
|
|
static const _CharT _S_terminal;
|
2000-10-05 13:27:02 +02:00
|
|
|
|
Avoid multi-processor bus contention on increment/decrement-and- test of the reference count in the empty-string object...
2003-06-13 Nathan C. Myers <ncm-nospam@cantrip.org>
Avoid multi-processor bus contention on increment/decrement-and-
test of the reference count in the empty-string object, by comparing
addresses first, and never touching the reference count of the empty-
string object.
* include/bits/basic_string.h:
(_S_empty_rep_storage): Move into basic_string<>::_Rep for use by its
members.
(_Rep::_S_empty_rep()): New accessor.
(_Rep::_M_length, _Rep::_M_capacity, _Rep::_M_references): Move to
a base class _Rep_base.
(_Rep::_M_dispose, _Rep::_M_refcopy): Check for the empty string.
(basic_string()): Change to use _M_refdata() in place of _M_refcopy(),
since no longer must increment its refcount.
* include/bits/basic_string.tcc:
(_Rep::_M_destroy, _M_leak_hard): Check for the empty string and
return immediately. The former might be unnecessary. The latter
prevents begin() and end() from cloning it unnecessarily.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
input_iterator_tag), _S_construct(_InIterator, _InIterator,
const _Alloc&, forward_iterator_tag), _S_construct(size_type, _CharT,
const _Alloc&)): Change to use _M_refdata() in place of _M_refcopy().
(_M_mutate): Check for the empty string and treat it as shared.
This is necessary here because _M_mutate is sometimes called with
all-zero arguments; in all other uses of _M_is_shared, the test comes
out right anyhow.
From-SVN: r67912
2003-06-13 22:59:42 +02:00
|
|
|
// The following storage is init'd to 0 by the linker, resulting
|
|
|
|
// (carefully) in an empty string with one reference.
|
|
|
|
static size_type _S_empty_rep_storage[];
|
2002-09-01 02:33:53 +02:00
|
|
|
|
2004-02-08 05:46:42 +01:00
|
|
|
static _Rep&
|
Avoid multi-processor bus contention on increment/decrement-and- test of the reference count in the empty-string object...
2003-06-13 Nathan C. Myers <ncm-nospam@cantrip.org>
Avoid multi-processor bus contention on increment/decrement-and-
test of the reference count in the empty-string object, by comparing
addresses first, and never touching the reference count of the empty-
string object.
* include/bits/basic_string.h:
(_S_empty_rep_storage): Move into basic_string<>::_Rep for use by its
members.
(_Rep::_S_empty_rep()): New accessor.
(_Rep::_M_length, _Rep::_M_capacity, _Rep::_M_references): Move to
a base class _Rep_base.
(_Rep::_M_dispose, _Rep::_M_refcopy): Check for the empty string.
(basic_string()): Change to use _M_refdata() in place of _M_refcopy(),
since no longer must increment its refcount.
* include/bits/basic_string.tcc:
(_Rep::_M_destroy, _M_leak_hard): Check for the empty string and
return immediately. The former might be unnecessary. The latter
prevents begin() and end() from cloning it unnecessarily.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
input_iterator_tag), _S_construct(_InIterator, _InIterator,
const _Alloc&, forward_iterator_tag), _S_construct(size_type, _CharT,
const _Alloc&)): Change to use _M_refdata() in place of _M_refcopy().
(_M_mutate): Check for the empty string and treat it as shared.
This is necessary here because _M_mutate is sometimes called with
all-zero arguments; in all other uses of _M_is_shared, the test comes
out right anyhow.
From-SVN: r67912
2003-06-13 22:59:42 +02:00
|
|
|
_S_empty_rep()
|
2005-11-24 02:29:51 +01:00
|
|
|
{
|
|
|
|
// NB: Mild hack to avoid strict-aliasing warnings. Note that
|
|
|
|
// _S_empty_rep_storage is never modified and the punning should
|
|
|
|
// be reasonably safe in this case.
|
|
|
|
void* __p = reinterpret_cast<void*>(&_S_empty_rep_storage);
|
|
|
|
return *reinterpret_cast<_Rep*>(__p);
|
|
|
|
}
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
bool
|
|
|
|
_M_is_leaked() const
|
2003-12-15 20:48:50 +01:00
|
|
|
{ return this->_M_refcount < 0; }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
|
|
|
bool
|
|
|
|
_M_is_shared() const
|
2003-12-15 20:48:50 +01:00
|
|
|
{ return this->_M_refcount > 0; }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
|
|
|
void
|
2002-09-01 02:33:53 +02:00
|
|
|
_M_set_leaked()
|
2003-12-15 20:48:50 +01:00
|
|
|
{ this->_M_refcount = -1; }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
|
|
|
void
|
2002-09-01 02:33:53 +02:00
|
|
|
_M_set_sharable()
|
2003-12-15 20:48:50 +01:00
|
|
|
{ this->_M_refcount = 0; }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2004-10-22 00:01:41 +02:00
|
|
|
void
|
|
|
|
_M_set_length_and_sharable(size_type __n)
|
2009-06-23 14:36:43 +02:00
|
|
|
{
|
|
|
|
#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
|
|
|
|
if (__builtin_expect(this != &_S_empty_rep(), false))
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
this->_M_set_sharable(); // One reference.
|
|
|
|
this->_M_length = __n;
|
|
|
|
traits_type::assign(this->_M_refdata()[__n], _S_terminal);
|
|
|
|
// grrr. (per 21.3.4)
|
|
|
|
// You cannot leave those LWG people alone for a second.
|
|
|
|
}
|
2004-10-22 00:01:41 +02:00
|
|
|
}
|
|
|
|
|
2002-09-01 02:33:53 +02:00
|
|
|
_CharT*
|
2000-10-05 13:27:02 +02:00
|
|
|
_M_refdata() throw()
|
2002-04-01 20:39:37 +02:00
|
|
|
{ return reinterpret_cast<_CharT*>(this + 1); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2002-09-01 02:33:53 +02:00
|
|
|
_CharT*
|
2000-10-05 13:27:02 +02:00
|
|
|
_M_grab(const _Alloc& __alloc1, const _Alloc& __alloc2)
|
2002-09-01 02:33:53 +02:00
|
|
|
{
|
|
|
|
return (!_M_is_leaked() && __alloc1 == __alloc2)
|
|
|
|
? _M_refcopy() : _M_clone(__alloc1);
|
2002-04-01 20:39:37 +02:00
|
|
|
}
|
2000-10-05 13:27:02 +02:00
|
|
|
|
|
|
|
// Create & Destroy
|
2002-09-01 02:33:53 +02:00
|
|
|
static _Rep*
|
basic_string.h (_S_create(size_t, const _Alloc&): Change signature to take two size_type arguments.
2004-01-28 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_S_create(size_t,
const _Alloc&): Change signature to take two size_type
arguments.
* include/bits/basic_string.tcc (_S_construct(_InIterator,
_InIterator, const _Alloc&, input_iterator_tag)): Update
call, tweak a bit.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
forward_iterator_tag)): Likewise.
(_S_construct(size_type, _CharT, const _Alloc&)): Likewise.
(_M_mutate(size_type, size_type, size_type)): Don't
implement the exponential growth policy, demand it to
_S_create, update call and simplify.
(_M_clone(const _Alloc&, size_type)): Likewise.
(_S_create(size_type, size_type, const _Alloc&)): Implement
the growth policy, simplify otherwise.
* include/bits/basic_string.h (_Rep::operator[]): Tweak
signature to take a size_type, consistently with the other
members.
From-SVN: r76786
2004-01-28 11:37:32 +01:00
|
|
|
_S_create(size_type, size_type, const _Alloc&);
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2002-09-01 02:33:53 +02:00
|
|
|
void
|
2000-10-05 13:27:02 +02:00
|
|
|
_M_dispose(const _Alloc& __a)
|
2002-09-01 02:33:53 +02:00
|
|
|
{
|
2004-09-28 10:58:35 +02:00
|
|
|
#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
|
Avoid multi-processor bus contention on increment/decrement-and- test of the reference count in the empty-string object...
2003-06-13 Nathan C. Myers <ncm-nospam@cantrip.org>
Avoid multi-processor bus contention on increment/decrement-and-
test of the reference count in the empty-string object, by comparing
addresses first, and never touching the reference count of the empty-
string object.
* include/bits/basic_string.h:
(_S_empty_rep_storage): Move into basic_string<>::_Rep for use by its
members.
(_Rep::_S_empty_rep()): New accessor.
(_Rep::_M_length, _Rep::_M_capacity, _Rep::_M_references): Move to
a base class _Rep_base.
(_Rep::_M_dispose, _Rep::_M_refcopy): Check for the empty string.
(basic_string()): Change to use _M_refdata() in place of _M_refcopy(),
since no longer must increment its refcount.
* include/bits/basic_string.tcc:
(_Rep::_M_destroy, _M_leak_hard): Check for the empty string and
return immediately. The former might be unnecessary. The latter
prevents begin() and end() from cloning it unnecessarily.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
input_iterator_tag), _S_construct(_InIterator, _InIterator,
const _Alloc&, forward_iterator_tag), _S_construct(size_type, _CharT,
const _Alloc&)): Change to use _M_refdata() in place of _M_refcopy().
(_M_mutate): Check for the empty string and treat it as shared.
This is necessary here because _M_mutate is sometimes called with
all-zero arguments; in all other uses of _M_is_shared, the test comes
out right anyhow.
From-SVN: r67912
2003-06-13 22:59:42 +02:00
|
|
|
if (__builtin_expect(this != &_S_empty_rep(), false))
|
2004-09-28 10:58:35 +02:00
|
|
|
#endif
|
2006-05-24 18:37:42 +02:00
|
|
|
if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
|
|
|
|
-1) <= 0)
|
Avoid multi-processor bus contention on increment/decrement-and- test of the reference count in the empty-string object...
2003-06-13 Nathan C. Myers <ncm-nospam@cantrip.org>
Avoid multi-processor bus contention on increment/decrement-and-
test of the reference count in the empty-string object, by comparing
addresses first, and never touching the reference count of the empty-
string object.
* include/bits/basic_string.h:
(_S_empty_rep_storage): Move into basic_string<>::_Rep for use by its
members.
(_Rep::_S_empty_rep()): New accessor.
(_Rep::_M_length, _Rep::_M_capacity, _Rep::_M_references): Move to
a base class _Rep_base.
(_Rep::_M_dispose, _Rep::_M_refcopy): Check for the empty string.
(basic_string()): Change to use _M_refdata() in place of _M_refcopy(),
since no longer must increment its refcount.
* include/bits/basic_string.tcc:
(_Rep::_M_destroy, _M_leak_hard): Check for the empty string and
return immediately. The former might be unnecessary. The latter
prevents begin() and end() from cloning it unnecessarily.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
input_iterator_tag), _S_construct(_InIterator, _InIterator,
const _Alloc&, forward_iterator_tag), _S_construct(size_type, _CharT,
const _Alloc&)): Change to use _M_refdata() in place of _M_refcopy().
(_M_mutate): Check for the empty string and treat it as shared.
This is necessary here because _M_mutate is sometimes called with
all-zero arguments; in all other uses of _M_is_shared, the test comes
out right anyhow.
From-SVN: r67912
2003-06-13 22:59:42 +02:00
|
|
|
_M_destroy(__a);
|
2000-10-05 13:27:02 +02:00
|
|
|
} // XXX MT
|
|
|
|
|
2002-09-01 02:33:53 +02:00
|
|
|
void
|
2000-10-05 13:27:02 +02:00
|
|
|
_M_destroy(const _Alloc&) throw();
|
|
|
|
|
2002-09-01 02:33:53 +02:00
|
|
|
_CharT*
|
2000-10-05 13:27:02 +02:00
|
|
|
_M_refcopy() throw()
|
2002-09-01 02:33:53 +02:00
|
|
|
{
|
2004-09-28 10:58:35 +02:00
|
|
|
#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
|
Avoid multi-processor bus contention on increment/decrement-and- test of the reference count in the empty-string object...
2003-06-13 Nathan C. Myers <ncm-nospam@cantrip.org>
Avoid multi-processor bus contention on increment/decrement-and-
test of the reference count in the empty-string object, by comparing
addresses first, and never touching the reference count of the empty-
string object.
* include/bits/basic_string.h:
(_S_empty_rep_storage): Move into basic_string<>::_Rep for use by its
members.
(_Rep::_S_empty_rep()): New accessor.
(_Rep::_M_length, _Rep::_M_capacity, _Rep::_M_references): Move to
a base class _Rep_base.
(_Rep::_M_dispose, _Rep::_M_refcopy): Check for the empty string.
(basic_string()): Change to use _M_refdata() in place of _M_refcopy(),
since no longer must increment its refcount.
* include/bits/basic_string.tcc:
(_Rep::_M_destroy, _M_leak_hard): Check for the empty string and
return immediately. The former might be unnecessary. The latter
prevents begin() and end() from cloning it unnecessarily.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
input_iterator_tag), _S_construct(_InIterator, _InIterator,
const _Alloc&, forward_iterator_tag), _S_construct(size_type, _CharT,
const _Alloc&)): Change to use _M_refdata() in place of _M_refcopy().
(_M_mutate): Check for the empty string and treat it as shared.
This is necessary here because _M_mutate is sometimes called with
all-zero arguments; in all other uses of _M_is_shared, the test comes
out right anyhow.
From-SVN: r67912
2003-06-13 22:59:42 +02:00
|
|
|
if (__builtin_expect(this != &_S_empty_rep(), false))
|
2004-09-28 10:58:35 +02:00
|
|
|
#endif
|
2006-05-24 18:37:42 +02:00
|
|
|
__gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
|
2002-09-01 02:33:53 +02:00
|
|
|
return _M_refdata();
|
2000-10-05 13:27:02 +02:00
|
|
|
} // XXX MT
|
|
|
|
|
2002-09-01 02:33:53 +02:00
|
|
|
_CharT*
|
2000-10-05 13:27:02 +02:00
|
|
|
_M_clone(const _Alloc&, size_type __res = 0);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Use empty-base optimization: http://www.cantrip.org/emptyopt.html
|
|
|
|
struct _Alloc_hider : _Alloc
|
|
|
|
{
|
|
|
|
_Alloc_hider(_CharT* __dat, const _Alloc& __a)
|
|
|
|
: _Alloc(__a), _M_p(__dat) { }
|
|
|
|
|
|
|
|
_CharT* _M_p; // The actual data.
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
// Data Members (public):
|
|
|
|
// NB: This is an unsigned type, and thus represents the maximum
|
|
|
|
// size that the allocator can hold.
|
2004-11-21 14:16:24 +01:00
|
|
|
/// Value returned by various member functions when they fail.
|
2004-02-08 05:46:42 +01:00
|
|
|
static const size_type npos = static_cast<size_type>(-1);
|
2000-10-05 13:27:02 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Data Members (private):
|
2004-02-08 05:46:42 +01:00
|
|
|
mutable _Alloc_hider _M_dataplus;
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2002-09-01 02:33:53 +02:00
|
|
|
_CharT*
|
|
|
|
_M_data() const
|
2000-10-05 13:27:02 +02:00
|
|
|
{ return _M_dataplus._M_p; }
|
|
|
|
|
2002-09-01 02:33:53 +02:00
|
|
|
_CharT*
|
|
|
|
_M_data(_CharT* __p)
|
2000-10-05 13:27:02 +02:00
|
|
|
{ return (_M_dataplus._M_p = __p); }
|
|
|
|
|
2002-09-01 02:33:53 +02:00
|
|
|
_Rep*
|
2000-10-05 13:27:02 +02:00
|
|
|
_M_rep() const
|
|
|
|
{ return &((reinterpret_cast<_Rep*> (_M_data()))[-1]); }
|
|
|
|
|
|
|
|
// For the internal use we have functions similar to `begin'/`end'
|
|
|
|
// but they do not call _M_leak.
|
2002-09-01 02:33:53 +02:00
|
|
|
iterator
|
2004-10-18 10:43:17 +02:00
|
|
|
_M_ibegin() const
|
|
|
|
{ return iterator(_M_data()); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2002-09-01 02:33:53 +02:00
|
|
|
iterator
|
2004-10-18 10:43:17 +02:00
|
|
|
_M_iend() const
|
|
|
|
{ return iterator(_M_data() + this->size()); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2002-09-01 02:33:53 +02:00
|
|
|
void
|
2000-10-05 13:27:02 +02:00
|
|
|
_M_leak() // for use in begin() & non-const op[]
|
2002-09-01 02:33:53 +02:00
|
|
|
{
|
|
|
|
if (!_M_rep()->_M_is_leaked())
|
|
|
|
_M_leak_hard();
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
|
|
|
|
basic_string.h (_M_check): Change to return a checked __pos and take an additional const char* argument.
2004-01-21 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_M_check): Change to return
a checked __pos and take an additional const char* argument.
(_M_fold): Rename to _M_limit, change to return a size_type,
corresponding to the __off limited to the actual length.
(insert(size_type, size_type, _CharT)): Update call, call
replace.
(insert(iterator, _CharT)): Call replace(iterator, iterator,
size_type, _CharT) instead.
(erase(size_type, size_type)): Update calls.
(replace(size_type, size_type, size_type, _CharT)): Ditto.
(substr(size_type, size_type)): Use _M_check.
* include/bits/basic_string.tcc (basic_string(const basic_string&,
size_type, size_type)): Update calls.
(basic_string(const basic_string&, size_type, size_type,
const _Alloc&)): Ditto.
(assign(const basic_string&, size_type, size_type)): Use the
new _M_check and _M_limit.
(insert(size_type, const basic_string&, size_type, size_type):
Ditto.
(insert(size_type, const _CharT*, size_type)): Ditto.
(replace(size_type, size_type, const _CharT*, size_type): Ditto.
(replace(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(append(const basic_string&)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,size_type,
size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76274
2004-01-21 12:29:51 +01:00
|
|
|
size_type
|
|
|
|
_M_check(size_type __pos, const char* __s) const
|
2002-09-01 02:33:53 +02:00
|
|
|
{
|
2001-02-16 01:44:44 +01:00
|
|
|
if (__pos > this->size())
|
basic_string.h (_M_check): Change to return a checked __pos and take an additional const char* argument.
2004-01-21 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_M_check): Change to return
a checked __pos and take an additional const char* argument.
(_M_fold): Rename to _M_limit, change to return a size_type,
corresponding to the __off limited to the actual length.
(insert(size_type, size_type, _CharT)): Update call, call
replace.
(insert(iterator, _CharT)): Call replace(iterator, iterator,
size_type, _CharT) instead.
(erase(size_type, size_type)): Update calls.
(replace(size_type, size_type, size_type, _CharT)): Ditto.
(substr(size_type, size_type)): Use _M_check.
* include/bits/basic_string.tcc (basic_string(const basic_string&,
size_type, size_type)): Update calls.
(basic_string(const basic_string&, size_type, size_type,
const _Alloc&)): Ditto.
(assign(const basic_string&, size_type, size_type)): Use the
new _M_check and _M_limit.
(insert(size_type, const basic_string&, size_type, size_type):
Ditto.
(insert(size_type, const _CharT*, size_type)): Ditto.
(replace(size_type, size_type, const _CharT*, size_type): Ditto.
(replace(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(append(const basic_string&)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,size_type,
size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76274
2004-01-21 12:29:51 +01:00
|
|
|
__throw_out_of_range(__N(__s));
|
|
|
|
return __pos;
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
|
|
|
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
void
|
|
|
|
_M_check_length(size_type __n1, size_type __n2, const char* __s) const
|
|
|
|
{
|
|
|
|
if (this->max_size() - (this->size() - __n1) < __n2)
|
|
|
|
__throw_length_error(__N(__s));
|
|
|
|
}
|
|
|
|
|
basic_string.h (_M_check): Change to return a checked __pos and take an additional const char* argument.
2004-01-21 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_M_check): Change to return
a checked __pos and take an additional const char* argument.
(_M_fold): Rename to _M_limit, change to return a size_type,
corresponding to the __off limited to the actual length.
(insert(size_type, size_type, _CharT)): Update call, call
replace.
(insert(iterator, _CharT)): Call replace(iterator, iterator,
size_type, _CharT) instead.
(erase(size_type, size_type)): Update calls.
(replace(size_type, size_type, size_type, _CharT)): Ditto.
(substr(size_type, size_type)): Use _M_check.
* include/bits/basic_string.tcc (basic_string(const basic_string&,
size_type, size_type)): Update calls.
(basic_string(const basic_string&, size_type, size_type,
const _Alloc&)): Ditto.
(assign(const basic_string&, size_type, size_type)): Use the
new _M_check and _M_limit.
(insert(size_type, const basic_string&, size_type, size_type):
Ditto.
(insert(size_type, const _CharT*, size_type)): Ditto.
(replace(size_type, size_type, const _CharT*, size_type): Ditto.
(replace(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(append(const basic_string&)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,size_type,
size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76274
2004-01-21 12:29:51 +01:00
|
|
|
// NB: _M_limit doesn't check for a bad __pos value.
|
|
|
|
size_type
|
|
|
|
_M_limit(size_type __pos, size_type __off) const
|
2002-09-01 02:33:53 +02:00
|
|
|
{
|
basic_string.h (_M_fold, [...]): Constify various variables.
2003-06-04 Paolo Carlini <pcarlini@unitus.it>
* include/bits/basic_string.h (_M_fold, insert(iterator, _CharT),
erase(iterator), erase(iterator, iterator), c_str,
compare(const basic_string&)): Constify various variables.
* include/bits/basic_string.tcc (_S_construct(_InIter, _InIter,
const _Alloc&, input_iterator_tag), _M_destroy, _M_mutate,
_S_create, resize, _M_replace, _M_replace_safe,
append(const basic_string&), append(const basic_string&, size_type,
size_type), append(const _CharT*, size_type), append(size_type,
_CharT), operator+(const _CharT*, const basic_string&),
operator+(_CharT, const basic_string&), replace(iterator, iterator,
size_type, _CharT), find(const _CharT*, size_type, size_type),
find(_CharT, size_type), rfind(const _CharT*, size_type, size_type),
rfind(_CharT, size_type), compare(size_type, size_type,
const basic_string&), compare(size_type, size_type,
const basic_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
From-SVN: r67468
2003-06-05 00:53:05 +02:00
|
|
|
const bool __testoff = __off < this->size() - __pos;
|
basic_string.h (_M_check): Change to return a checked __pos and take an additional const char* argument.
2004-01-21 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_M_check): Change to return
a checked __pos and take an additional const char* argument.
(_M_fold): Rename to _M_limit, change to return a size_type,
corresponding to the __off limited to the actual length.
(insert(size_type, size_type, _CharT)): Update call, call
replace.
(insert(iterator, _CharT)): Call replace(iterator, iterator,
size_type, _CharT) instead.
(erase(size_type, size_type)): Update calls.
(replace(size_type, size_type, size_type, _CharT)): Ditto.
(substr(size_type, size_type)): Use _M_check.
* include/bits/basic_string.tcc (basic_string(const basic_string&,
size_type, size_type)): Update calls.
(basic_string(const basic_string&, size_type, size_type,
const _Alloc&)): Ditto.
(assign(const basic_string&, size_type, size_type)): Use the
new _M_check and _M_limit.
(insert(size_type, const basic_string&, size_type, size_type):
Ditto.
(insert(size_type, const _CharT*, size_type)): Ditto.
(replace(size_type, size_type, const _CharT*, size_type): Ditto.
(replace(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(append(const basic_string&)): Ditto.
(append(const basic_string&, size_type, size_type)): Ditto.
(copy(_CharT*, size_type, size_type)): Ditto.
(compare(size_type, size_type, const basic_string&)): Ditto.
(compare(size_type, size_type, const basic_string&,size_type,
size_type)): Ditto.
(compare(size_type, size_type, const _CharT*)): Ditto.
(compare(size_type, size_type, const _CharT*, size_type)): Ditto.
From-SVN: r76274
2004-01-21 12:29:51 +01:00
|
|
|
return __testoff ? __off : this->size() - __pos;
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
|
|
|
|
2004-10-25 17:16:49 +02:00
|
|
|
// True if _Rep and source do not overlap.
|
|
|
|
bool
|
|
|
|
_M_disjunct(const _CharT* __s) const
|
|
|
|
{
|
|
|
|
return (less<const _CharT*>()(__s, _M_data())
|
|
|
|
|| less<const _CharT*>()(_M_data() + this->size(), __s));
|
|
|
|
}
|
|
|
|
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
// When __n = 1 way faster than the general multichar
|
|
|
|
// traits_type::copy/move/assign.
|
|
|
|
static void
|
|
|
|
_M_copy(_CharT* __d, const _CharT* __s, size_type __n)
|
|
|
|
{
|
|
|
|
if (__n == 1)
|
|
|
|
traits_type::assign(*__d, *__s);
|
|
|
|
else
|
|
|
|
traits_type::copy(__d, __s, __n);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_M_move(_CharT* __d, const _CharT* __s, size_type __n)
|
|
|
|
{
|
|
|
|
if (__n == 1)
|
|
|
|
traits_type::assign(*__d, *__s);
|
|
|
|
else
|
|
|
|
traits_type::move(__d, __s, __n);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_M_assign(_CharT* __d, size_type __n, _CharT __c)
|
|
|
|
{
|
|
|
|
if (__n == 1)
|
|
|
|
traits_type::assign(*__d, __c);
|
|
|
|
else
|
|
|
|
traits_type::assign(__d, __n, __c);
|
|
|
|
}
|
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
// _S_copy_chars is a separate template to permit specialization
|
|
|
|
// to optimize for the common case of pointers as iterators.
|
|
|
|
template<class _Iterator>
|
|
|
|
static void
|
|
|
|
_S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
|
2002-09-01 02:33:53 +02:00
|
|
|
{
|
|
|
|
for (; __k1 != __k2; ++__k1, ++__p)
|
2001-10-31 09:27:20 +01:00
|
|
|
traits_type::assign(*__p, *__k1); // These types are off.
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_S_copy_chars(_CharT* __p, iterator __k1, iterator __k2)
|
|
|
|
{ _S_copy_chars(__p, __k1.base(), __k2.base()); }
|
|
|
|
|
|
|
|
static void
|
|
|
|
_S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
|
|
|
|
{ _S_copy_chars(__p, __k1.base(), __k2.base()); }
|
2002-09-01 02:33:53 +02:00
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
static void
|
|
|
|
_S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2)
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
{ _M_copy(__p, __k1, __k2 - __k1); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
|
|
|
static void
|
|
|
|
_S_copy_chars(_CharT* __p, const _CharT* __k1, const _CharT* __k2)
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
{ _M_copy(__p, __k1, __k2 - __k1); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
basic_string.h (basic_string<>::_S_compare): Add.
2007-01-18 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (basic_string<>::_S_compare): Add.
(compare(const basic_string&)): Use it.
* include/bits/basic_string.tcc (compare(size_type, size_type,
const basic_string&), compare(size_type, size_type,
const basic_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
* include/ext/vstring_util.h (__vstring_utility<>::_S_compare): Add.
* include/ext/vstring.h (compare(const __versa_string&)): Use it.
* include/ext/vstring.tcc (compare(size_type, size_type,
const __versa_string&), compare(size_type, size_type,
const __versa_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
From-SVN: r120896
2007-01-18 13:03:35 +01:00
|
|
|
static int
|
|
|
|
_S_compare(size_type __n1, size_type __n2)
|
|
|
|
{
|
|
|
|
const difference_type __d = difference_type(__n1 - __n2);
|
|
|
|
|
numeric_traits.h: Do not include <limits>.
2007-04-13 Paolo Carlini <pcarlini@suse.de>
* include/ext/numeric_traits.h: Do not include <limits>.
(__numeric_traits_integer::__is_signed, __digits): Add.
(__numeric_traits_floating::__digits10, __max_exponent10): Add.
* src/istream.cc (ignore<char>(streamsize, int_type), operator>>
(basic_istream<char>&, char*), ignore<wchar_t>(streamsize,
int_type)): Use the latter.
* src/compatibility.cc (ignore<char>(streamsize),
ignore<wchar_t>(streamsize)): Likewise.
* include/ext/vstring_util.h (__vstring_utility<>::_S_compare):
Likewise.
* include/bits/stl_memory.h (__get_temporary_buffer): Likewise.
* include/bits/stl_algobase.h (lexicographical_compare(const char*,
const char*, const char*, const char*)): Likewise.
* include/bits/locale_facets.tcc (num_get<>::_M_extract_int(_InIter,
_InIter, ios_base&, ios_base::iostate&, _ValueT&),
num_put<>::_M_insert_int(_OutIter, ios_base&, _CharT, _ValueT),
num_put<>::_M_insert_float(_OutIter, ios_base&, _CharT, char,
_ValueT), collate<>::do_hash(const _CharT*, const _CharT*)): Likewise.
* include/bits/basic_string.h (basic_string<>::_S_compare): Likewise.
* include/bits/istream.tcc (operator>>(short&), operator>>(int&),
ignore(streamsize), ignore(streamsize, int_type), operator>>
(basic_istream<>&, _CharT*)): Likewise.
* include/bits/stl_bvector.h (vector<bool>::max_size): Likewise.
* include/tr1/functional_hash.h (struct hash<long double>): Likewise.
* include/std/istream: Do not include <limits>.
* include/tr1/cmath: Include <limits>.
* testsuite/23_containers/vector/bool/capacity/29134.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_arithmetic/char/12.cc:
Likewise.
* testsuite/27_io/basic_istream/extractors_arithmetic/char/13.cc:
Likewise.
* testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/12.cc:
Likewise.
* testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/13.cc:
Likewise.
* testsuite/27_io/ios_base/storage/2.cc: Likewise.
* include/tr1/hashtable: Do not include the whole <iterator>.
From-SVN: r123779
2007-04-13 12:54:37 +02:00
|
|
|
if (__d > __gnu_cxx::__numeric_traits<int>::__max)
|
|
|
|
return __gnu_cxx::__numeric_traits<int>::__max;
|
|
|
|
else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
|
|
|
|
return __gnu_cxx::__numeric_traits<int>::__min;
|
basic_string.h (basic_string<>::_S_compare): Add.
2007-01-18 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (basic_string<>::_S_compare): Add.
(compare(const basic_string&)): Use it.
* include/bits/basic_string.tcc (compare(size_type, size_type,
const basic_string&), compare(size_type, size_type,
const basic_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
* include/ext/vstring_util.h (__vstring_utility<>::_S_compare): Add.
* include/ext/vstring.h (compare(const __versa_string&)): Use it.
* include/ext/vstring.tcc (compare(size_type, size_type,
const __versa_string&), compare(size_type, size_type,
const __versa_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
From-SVN: r120896
2007-01-18 13:03:35 +01:00
|
|
|
else
|
numeric_traits.h: Do not include <limits>.
2007-04-13 Paolo Carlini <pcarlini@suse.de>
* include/ext/numeric_traits.h: Do not include <limits>.
(__numeric_traits_integer::__is_signed, __digits): Add.
(__numeric_traits_floating::__digits10, __max_exponent10): Add.
* src/istream.cc (ignore<char>(streamsize, int_type), operator>>
(basic_istream<char>&, char*), ignore<wchar_t>(streamsize,
int_type)): Use the latter.
* src/compatibility.cc (ignore<char>(streamsize),
ignore<wchar_t>(streamsize)): Likewise.
* include/ext/vstring_util.h (__vstring_utility<>::_S_compare):
Likewise.
* include/bits/stl_memory.h (__get_temporary_buffer): Likewise.
* include/bits/stl_algobase.h (lexicographical_compare(const char*,
const char*, const char*, const char*)): Likewise.
* include/bits/locale_facets.tcc (num_get<>::_M_extract_int(_InIter,
_InIter, ios_base&, ios_base::iostate&, _ValueT&),
num_put<>::_M_insert_int(_OutIter, ios_base&, _CharT, _ValueT),
num_put<>::_M_insert_float(_OutIter, ios_base&, _CharT, char,
_ValueT), collate<>::do_hash(const _CharT*, const _CharT*)): Likewise.
* include/bits/basic_string.h (basic_string<>::_S_compare): Likewise.
* include/bits/istream.tcc (operator>>(short&), operator>>(int&),
ignore(streamsize), ignore(streamsize, int_type), operator>>
(basic_istream<>&, _CharT*)): Likewise.
* include/bits/stl_bvector.h (vector<bool>::max_size): Likewise.
* include/tr1/functional_hash.h (struct hash<long double>): Likewise.
* include/std/istream: Do not include <limits>.
* include/tr1/cmath: Include <limits>.
* testsuite/23_containers/vector/bool/capacity/29134.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_arithmetic/char/12.cc:
Likewise.
* testsuite/27_io/basic_istream/extractors_arithmetic/char/13.cc:
Likewise.
* testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/12.cc:
Likewise.
* testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/13.cc:
Likewise.
* testsuite/27_io/ios_base/storage/2.cc: Likewise.
* include/tr1/hashtable: Do not include the whole <iterator>.
From-SVN: r123779
2007-04-13 12:54:37 +02:00
|
|
|
return int(__d);
|
basic_string.h (basic_string<>::_S_compare): Add.
2007-01-18 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (basic_string<>::_S_compare): Add.
(compare(const basic_string&)): Use it.
* include/bits/basic_string.tcc (compare(size_type, size_type,
const basic_string&), compare(size_type, size_type,
const basic_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
* include/ext/vstring_util.h (__vstring_utility<>::_S_compare): Add.
* include/ext/vstring.h (compare(const __versa_string&)): Use it.
* include/ext/vstring.tcc (compare(size_type, size_type,
const __versa_string&), compare(size_type, size_type,
const __versa_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
From-SVN: r120896
2007-01-18 13:03:35 +01:00
|
|
|
}
|
|
|
|
|
2002-09-01 02:33:53 +02:00
|
|
|
void
|
2000-10-05 13:27:02 +02:00
|
|
|
_M_mutate(size_type __pos, size_type __len1, size_type __len2);
|
|
|
|
|
2002-09-01 02:33:53 +02:00
|
|
|
void
|
2000-10-05 13:27:02 +02:00
|
|
|
_M_leak_hard();
|
|
|
|
|
2002-09-01 02:33:53 +02:00
|
|
|
static _Rep&
|
2000-10-05 13:27:02 +02:00
|
|
|
_S_empty_rep()
|
Avoid multi-processor bus contention on increment/decrement-and- test of the reference count in the empty-string object...
2003-06-13 Nathan C. Myers <ncm-nospam@cantrip.org>
Avoid multi-processor bus contention on increment/decrement-and-
test of the reference count in the empty-string object, by comparing
addresses first, and never touching the reference count of the empty-
string object.
* include/bits/basic_string.h:
(_S_empty_rep_storage): Move into basic_string<>::_Rep for use by its
members.
(_Rep::_S_empty_rep()): New accessor.
(_Rep::_M_length, _Rep::_M_capacity, _Rep::_M_references): Move to
a base class _Rep_base.
(_Rep::_M_dispose, _Rep::_M_refcopy): Check for the empty string.
(basic_string()): Change to use _M_refdata() in place of _M_refcopy(),
since no longer must increment its refcount.
* include/bits/basic_string.tcc:
(_Rep::_M_destroy, _M_leak_hard): Check for the empty string and
return immediately. The former might be unnecessary. The latter
prevents begin() and end() from cloning it unnecessarily.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
input_iterator_tag), _S_construct(_InIterator, _InIterator,
const _Alloc&, forward_iterator_tag), _S_construct(size_type, _CharT,
const _Alloc&)): Change to use _M_refdata() in place of _M_refcopy().
(_M_mutate): Check for the empty string and treat it as shared.
This is necessary here because _M_mutate is sometimes called with
all-zero arguments; in all other uses of _M_is_shared, the test comes
out right anyhow.
From-SVN: r67912
2003-06-13 22:59:42 +02:00
|
|
|
{ return _Rep::_S_empty_rep(); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
// Construct/copy/destroy:
|
|
|
|
// NB: We overload ctors in some cases instead of using default
|
|
|
|
// arguments, per 17.4.4.4 para. 2 item 2.
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Default constructor creates an empty string.
|
|
|
|
*/
|
2010-01-10 14:38:47 +01:00
|
|
|
basic_string()
|
|
|
|
#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
|
|
|
|
: _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
|
|
|
|
#else
|
|
|
|
: _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()){ }
|
|
|
|
#endif
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
2005-06-29 14:18:08 +02:00
|
|
|
* @brief Construct an empty string using allocator @a a.
|
2003-07-15 09:02:40 +02:00
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
explicit
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_string(const _Alloc& __a);
|
|
|
|
|
|
|
|
// NB: per LWG issue 42, semantics different from IS:
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Construct string with copy of value of @a str.
|
|
|
|
* @param str Source string.
|
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_string(const basic_string& __str);
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Construct string as copy of a substring.
|
|
|
|
* @param str Source string.
|
|
|
|
* @param pos Index of first character to copy from.
|
|
|
|
* @param n Number of characters to copy (default remainder).
|
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_string(const basic_string& __str, size_type __pos,
|
|
|
|
size_type __n = npos);
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Construct string as copy of a substring.
|
|
|
|
* @param str Source string.
|
|
|
|
* @param pos Index of first character to copy from.
|
|
|
|
* @param n Number of characters to copy.
|
|
|
|
* @param a Allocator to use.
|
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_string(const basic_string& __str, size_type __pos,
|
|
|
|
size_type __n, const _Alloc& __a);
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
2004-01-13 12:12:38 +01:00
|
|
|
* @brief Construct string initialized by a character array.
|
|
|
|
* @param s Source character array.
|
2003-07-15 09:02:40 +02:00
|
|
|
* @param n Number of characters to copy.
|
|
|
|
* @param a Allocator to use (default is default allocator).
|
2004-02-08 05:46:42 +01:00
|
|
|
*
|
2009-03-11 16:16:21 +01:00
|
|
|
* NB: @a s must have at least @a n characters, '\\0' has no special
|
2004-01-13 12:12:38 +01:00
|
|
|
* meaning.
|
2003-07-15 09:02:40 +02:00
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_string(const _CharT* __s, size_type __n,
|
|
|
|
const _Alloc& __a = _Alloc());
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Construct string as copy of a C string.
|
|
|
|
* @param s Source C string.
|
|
|
|
* @param a Allocator to use (default is default allocator).
|
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_string(const _CharT* __s, const _Alloc& __a = _Alloc());
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Construct string as multiple characters.
|
|
|
|
* @param n Number of characters.
|
|
|
|
* @param c Character to use.
|
|
|
|
* @param a Allocator to use (default is default allocator).
|
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc());
|
|
|
|
|
2008-07-21 21:40:39 +02:00
|
|
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
2010-01-10 14:38:47 +01:00
|
|
|
/**
|
|
|
|
* @brief Move construct string.
|
|
|
|
* @param str Source string.
|
|
|
|
*
|
|
|
|
* The newly-created string contains the exact contents of @a str.
|
|
|
|
* @a str is a valid, but unspecified string.
|
|
|
|
**/
|
|
|
|
basic_string(basic_string&& __str)
|
|
|
|
: _M_dataplus(__str._M_dataplus)
|
|
|
|
{
|
|
|
|
#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
|
|
|
|
__str._M_data(_S_empty_rep()._M_refdata());
|
|
|
|
#else
|
|
|
|
__str._M_data(_S_construct(size_type(), _CharT(), get_allocator()));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-07-21 21:40:39 +02:00
|
|
|
/**
|
|
|
|
* @brief Construct string from an initializer list.
|
|
|
|
* @param l std::initializer_list of characters.
|
|
|
|
* @param a Allocator to use (default is default allocator).
|
|
|
|
*/
|
|
|
|
basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc());
|
|
|
|
#endif // __GXX_EXPERIMENTAL_CXX0X__
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Construct string as copy of a range.
|
|
|
|
* @param beg Start of range.
|
|
|
|
* @param end End of range.
|
|
|
|
* @param a Allocator to use (default is default allocator).
|
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<class _InputIterator>
|
2001-10-31 09:27:20 +01:00
|
|
|
basic_string(_InputIterator __beg, _InputIterator __end,
|
2000-10-05 13:27:02 +02:00
|
|
|
const _Alloc& __a = _Alloc());
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Destroy the string instance.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
~basic_string()
|
2000-10-05 13:27:02 +02:00
|
|
|
{ _M_rep()->_M_dispose(this->get_allocator()); }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Assign the value of @a str to this string.
|
|
|
|
* @param str Source string.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2004-05-23 01:46:34 +02:00
|
|
|
operator=(const basic_string& __str)
|
2004-07-08 17:56:21 +02:00
|
|
|
{ return this->assign(__str); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Copy contents of @a s into this string.
|
|
|
|
* @param s Source null-terminated string.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2004-05-23 01:46:34 +02:00
|
|
|
operator=(const _CharT* __s)
|
2004-07-08 17:56:21 +02:00
|
|
|
{ return this->assign(__s); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Set value to string of length 1.
|
|
|
|
* @param c Source character.
|
|
|
|
*
|
|
|
|
* Assigning to a character makes this string length 1 and
|
|
|
|
* (*this)[0] == @a c.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2004-05-23 01:46:34 +02:00
|
|
|
operator=(_CharT __c)
|
|
|
|
{
|
|
|
|
this->assign(1, __c);
|
|
|
|
return *this;
|
|
|
|
}
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2008-07-21 21:40:39 +02:00
|
|
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
2010-01-10 14:38:47 +01:00
|
|
|
/**
|
|
|
|
* @brief Move assign the value of @a str to this string.
|
|
|
|
* @param str Source string.
|
|
|
|
*
|
|
|
|
* The contents of @a str are moved into this string (without copying).
|
|
|
|
* @a str is a valid, but unspecified string.
|
|
|
|
**/
|
|
|
|
basic_string&
|
|
|
|
operator=(basic_string&& __str)
|
|
|
|
{
|
|
|
|
// NB: DR 1204.
|
|
|
|
this->swap(__str);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2008-07-21 21:40:39 +02:00
|
|
|
/**
|
|
|
|
* @brief Set value to string constructed from initializer list.
|
|
|
|
* @param l std::initializer_list.
|
|
|
|
*/
|
|
|
|
basic_string&
|
|
|
|
operator=(initializer_list<_CharT> __l)
|
|
|
|
{
|
2009-10-15 03:16:53 +02:00
|
|
|
this->assign(__l.begin(), __l.size());
|
2008-07-21 21:40:39 +02:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
#endif // __GXX_EXPERIMENTAL_CXX0X__
|
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
// Iterators:
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* Returns a read/write iterator that points to the first character in
|
|
|
|
* the %string. Unshares the string.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
iterator
|
|
|
|
begin()
|
|
|
|
{
|
|
|
|
_M_leak();
|
2000-10-05 13:27:02 +02:00
|
|
|
return iterator(_M_data());
|
|
|
|
}
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* Returns a read-only (constant) iterator that points to the first
|
|
|
|
* character in the %string.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
const_iterator
|
|
|
|
begin() const
|
2000-10-05 13:27:02 +02:00
|
|
|
{ return const_iterator(_M_data()); }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* Returns a read/write iterator that points one past the last
|
|
|
|
* character in the %string. Unshares the string.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
iterator
|
2000-10-05 13:27:02 +02:00
|
|
|
end()
|
|
|
|
{
|
basic_string.h (_M_fold, [...]): Constify various variables.
2003-06-04 Paolo Carlini <pcarlini@unitus.it>
* include/bits/basic_string.h (_M_fold, insert(iterator, _CharT),
erase(iterator), erase(iterator, iterator), c_str,
compare(const basic_string&)): Constify various variables.
* include/bits/basic_string.tcc (_S_construct(_InIter, _InIter,
const _Alloc&, input_iterator_tag), _M_destroy, _M_mutate,
_S_create, resize, _M_replace, _M_replace_safe,
append(const basic_string&), append(const basic_string&, size_type,
size_type), append(const _CharT*, size_type), append(size_type,
_CharT), operator+(const _CharT*, const basic_string&),
operator+(_CharT, const basic_string&), replace(iterator, iterator,
size_type, _CharT), find(const _CharT*, size_type, size_type),
find(_CharT, size_type), rfind(const _CharT*, size_type, size_type),
rfind(_CharT, size_type), compare(size_type, size_type,
const basic_string&), compare(size_type, size_type,
const basic_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
From-SVN: r67468
2003-06-05 00:53:05 +02:00
|
|
|
_M_leak();
|
|
|
|
return iterator(_M_data() + this->size());
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* Returns a read-only (constant) iterator that points one past the
|
|
|
|
* last character in the %string.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
const_iterator
|
2000-10-05 13:27:02 +02:00
|
|
|
end() const
|
|
|
|
{ return const_iterator(_M_data() + this->size()); }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* Returns a read/write reverse iterator that points to the last
|
|
|
|
* character in the %string. Iteration is done in reverse element
|
|
|
|
* order. Unshares the string.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
reverse_iterator
|
|
|
|
rbegin()
|
2000-10-05 13:27:02 +02:00
|
|
|
{ return reverse_iterator(this->end()); }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* Returns a read-only (constant) reverse iterator that points
|
|
|
|
* to the last character in the %string. Iteration is done in
|
|
|
|
* reverse element order.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
const_reverse_iterator
|
|
|
|
rbegin() const
|
2000-10-05 13:27:02 +02:00
|
|
|
{ return const_reverse_iterator(this->end()); }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* Returns a read/write reverse iterator that points to one before the
|
|
|
|
* first character in the %string. Iteration is done in reverse
|
|
|
|
* element order. Unshares the string.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
reverse_iterator
|
|
|
|
rend()
|
2000-10-05 13:27:02 +02:00
|
|
|
{ return reverse_iterator(this->begin()); }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* Returns a read-only (constant) reverse iterator that points
|
|
|
|
* to one before the first character in the %string. Iteration
|
|
|
|
* is done in reverse element order.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
const_reverse_iterator
|
|
|
|
rend() const
|
2000-10-05 13:27:02 +02:00
|
|
|
{ return const_reverse_iterator(this->begin()); }
|
|
|
|
|
2009-08-26 00:29:08 +02:00
|
|
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
|
|
|
/**
|
|
|
|
* Returns a read-only (constant) iterator that points to the first
|
|
|
|
* character in the %string.
|
|
|
|
*/
|
|
|
|
const_iterator
|
|
|
|
cbegin() const
|
|
|
|
{ return const_iterator(this->_M_data()); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a read-only (constant) iterator that points one past the
|
|
|
|
* last character in the %string.
|
|
|
|
*/
|
|
|
|
const_iterator
|
|
|
|
cend() const
|
|
|
|
{ return const_iterator(this->_M_data() + this->size()); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a read-only (constant) reverse iterator that points
|
|
|
|
* to the last character in the %string. Iteration is done in
|
|
|
|
* reverse element order.
|
|
|
|
*/
|
|
|
|
const_reverse_iterator
|
|
|
|
crbegin() const
|
|
|
|
{ return const_reverse_iterator(this->end()); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a read-only (constant) reverse iterator that points
|
|
|
|
* to one before the first character in the %string. Iteration
|
|
|
|
* is done in reverse element order.
|
|
|
|
*/
|
|
|
|
const_reverse_iterator
|
|
|
|
crend() const
|
|
|
|
{ return const_reverse_iterator(this->begin()); }
|
|
|
|
#endif
|
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
public:
|
|
|
|
// Capacity:
|
2003-07-15 09:02:40 +02:00
|
|
|
/// Returns the number of characters in the string, not including any
|
|
|
|
/// null-termination.
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
2004-10-18 10:43:17 +02:00
|
|
|
size() const
|
|
|
|
{ return _M_rep()->_M_length; }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/// Returns the number of characters in the string, not including any
|
|
|
|
/// null-termination.
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
2004-10-18 10:43:17 +02:00
|
|
|
length() const
|
|
|
|
{ return _M_rep()->_M_length; }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2010-01-08 14:01:24 +01:00
|
|
|
/// Returns the size() of the largest possible %string.
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
2004-10-18 10:43:17 +02:00
|
|
|
max_size() const
|
|
|
|
{ return _Rep::_S_max_size; }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Resizes the %string to the specified number of characters.
|
|
|
|
* @param n Number of characters the %string should contain.
|
|
|
|
* @param c Character to fill any new elements.
|
|
|
|
*
|
|
|
|
* This function will %resize the %string to the specified
|
|
|
|
* number of characters. If the number is smaller than the
|
|
|
|
* %string's current size the %string is truncated, otherwise
|
|
|
|
* the %string is extended and new elements are set to @a c.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
void
|
2000-10-05 13:27:02 +02:00
|
|
|
resize(size_type __n, _CharT __c);
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Resizes the %string to the specified number of characters.
|
|
|
|
* @param n Number of characters the %string should contain.
|
|
|
|
*
|
|
|
|
* This function will resize the %string to the specified length. If
|
|
|
|
* the new size is smaller than the %string's current size the %string
|
|
|
|
* is truncated, otherwise the %string is extended and new characters
|
|
|
|
* are default-constructed. For basic types such as char, this means
|
|
|
|
* setting them to 0.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
void
|
2004-10-18 10:43:17 +02:00
|
|
|
resize(size_type __n)
|
|
|
|
{ this->resize(__n, _CharT()); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2010-01-08 14:01:24 +01:00
|
|
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
|
|
|
/// A non-binding request to reduce capacity() to size().
|
|
|
|
void
|
|
|
|
shrink_to_fit()
|
|
|
|
{
|
2010-02-03 01:20:05 +01:00
|
|
|
__try
|
2010-01-08 14:01:24 +01:00
|
|
|
{ reserve(0); }
|
2010-02-03 01:20:05 +01:00
|
|
|
__catch(...)
|
2010-01-08 14:01:24 +01:00
|
|
|
{ }
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* Returns the total number of characters that the %string can hold
|
|
|
|
* before needing to allocate more memory.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
2004-10-18 10:43:17 +02:00
|
|
|
capacity() const
|
|
|
|
{ return _M_rep()->_M_capacity; }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Attempt to preallocate enough memory for specified number of
|
|
|
|
* characters.
|
2005-06-29 14:18:08 +02:00
|
|
|
* @param res_arg Number of characters required.
|
|
|
|
* @throw std::length_error If @a res_arg exceeds @c max_size().
|
2003-07-15 09:02:40 +02:00
|
|
|
*
|
|
|
|
* This function attempts to reserve enough memory for the
|
|
|
|
* %string to hold the specified number of characters. If the
|
|
|
|
* number requested is more than max_size(), length_error is
|
|
|
|
* thrown.
|
|
|
|
*
|
|
|
|
* The advantage of this function is that if optimal code is a
|
|
|
|
* necessity and the user can determine the string length that will be
|
|
|
|
* required, the user can reserve the memory in %advance, and thus
|
|
|
|
* prevent a possible reallocation of memory and copying of %string
|
|
|
|
* data.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
void
|
2000-10-05 13:27:02 +02:00
|
|
|
reserve(size_type __res_arg = 0);
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* Erases the string, making it empty.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
void
|
2004-10-18 10:43:17 +02:00
|
|
|
clear()
|
|
|
|
{ _M_mutate(0, this->size(), 0); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* Returns true if the %string is empty. Equivalent to *this == "".
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
bool
|
2004-10-18 10:43:17 +02:00
|
|
|
empty() const
|
|
|
|
{ return this->size() == 0; }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
|
|
|
// Element access:
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Subscript access to the data contained in the %string.
|
2005-06-29 14:18:08 +02:00
|
|
|
* @param pos The index of the character to access.
|
2003-07-15 09:02:40 +02:00
|
|
|
* @return Read-only (constant) reference to the character.
|
|
|
|
*
|
|
|
|
* This operator allows for easy, array-style, data access.
|
|
|
|
* Note that data access with this operator is unchecked and
|
|
|
|
* out_of_range lookups are not defined. (For checked lookups
|
|
|
|
* see at().)
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
const_reference
|
|
|
|
operator[] (size_type __pos) const
|
2004-02-08 05:46:42 +01:00
|
|
|
{
|
2003-11-11 21:09:16 +01:00
|
|
|
_GLIBCXX_DEBUG_ASSERT(__pos <= size());
|
2004-02-08 05:46:42 +01:00
|
|
|
return _M_data()[__pos];
|
2003-11-11 21:09:16 +01:00
|
|
|
}
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Subscript access to the data contained in the %string.
|
2005-06-29 14:18:08 +02:00
|
|
|
* @param pos The index of the character to access.
|
2003-07-15 09:02:40 +02:00
|
|
|
* @return Read/write reference to the character.
|
|
|
|
*
|
|
|
|
* This operator allows for easy, array-style, data access.
|
|
|
|
* Note that data access with this operator is unchecked and
|
|
|
|
* out_of_range lookups are not defined. (For checked lookups
|
|
|
|
* see at().) Unshares the string.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
reference
|
|
|
|
operator[](size_type __pos)
|
|
|
|
{
|
2005-05-19 10:59:46 +02:00
|
|
|
// allow pos == size() as v3 extension:
|
|
|
|
_GLIBCXX_DEBUG_ASSERT(__pos <= size());
|
|
|
|
// but be strict in pedantic mode:
|
|
|
|
_GLIBCXX_DEBUG_PEDASSERT(__pos < size());
|
2002-09-01 02:33:53 +02:00
|
|
|
_M_leak();
|
|
|
|
return _M_data()[__pos];
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Provides access to the data contained in the %string.
|
|
|
|
* @param n The index of the character to access.
|
|
|
|
* @return Read-only (const) reference to the character.
|
|
|
|
* @throw std::out_of_range If @a n is an invalid index.
|
|
|
|
*
|
|
|
|
* This function provides for safer data access. The parameter is
|
|
|
|
* first checked that it is in the range of the string. The function
|
|
|
|
* throws out_of_range if the check fails.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
const_reference
|
2000-10-05 13:27:02 +02:00
|
|
|
at(size_type __n) const
|
|
|
|
{
|
2001-02-16 01:44:44 +01:00
|
|
|
if (__n >= this->size())
|
2003-04-28 23:03:19 +02:00
|
|
|
__throw_out_of_range(__N("basic_string::at"));
|
2002-09-01 02:33:53 +02:00
|
|
|
return _M_data()[__n];
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Provides access to the data contained in the %string.
|
|
|
|
* @param n The index of the character to access.
|
|
|
|
* @return Read/write reference to the character.
|
|
|
|
* @throw std::out_of_range If @a n is an invalid index.
|
|
|
|
*
|
|
|
|
* This function provides for safer data access. The parameter is
|
|
|
|
* first checked that it is in the range of the string. The function
|
|
|
|
* throws out_of_range if the check fails. Success results in
|
|
|
|
* unsharing the string.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
reference
|
2000-10-05 13:27:02 +02:00
|
|
|
at(size_type __n)
|
|
|
|
{
|
2001-02-16 01:44:44 +01:00
|
|
|
if (__n >= size())
|
2003-04-28 23:03:19 +02:00
|
|
|
__throw_out_of_range(__N("basic_string::at"));
|
2002-09-01 02:33:53 +02:00
|
|
|
_M_leak();
|
|
|
|
return _M_data()[__n];
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Modifiers:
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Append a string to this string.
|
|
|
|
* @param str The string to append.
|
|
|
|
* @return Reference to this string.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2004-10-18 10:43:17 +02:00
|
|
|
operator+=(const basic_string& __str)
|
|
|
|
{ return this->append(__str); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Append a C string.
|
|
|
|
* @param s The C string to append.
|
|
|
|
* @return Reference to this string.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2004-10-18 10:43:17 +02:00
|
|
|
operator+=(const _CharT* __s)
|
|
|
|
{ return this->append(__s); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Append a character.
|
2005-06-29 14:18:08 +02:00
|
|
|
* @param c The character to append.
|
2003-07-15 09:02:40 +02:00
|
|
|
* @return Reference to this string.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2004-10-18 10:43:17 +02:00
|
|
|
operator+=(_CharT __c)
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
{
|
|
|
|
this->push_back(__c);
|
|
|
|
return *this;
|
|
|
|
}
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2008-07-21 21:40:39 +02:00
|
|
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
|
|
|
/**
|
|
|
|
* @brief Append an initializer_list of characters.
|
|
|
|
* @param l The initializer_list of characters to be appended.
|
|
|
|
* @return Reference to this string.
|
|
|
|
*/
|
|
|
|
basic_string&
|
|
|
|
operator+=(initializer_list<_CharT> __l)
|
2009-10-15 03:16:53 +02:00
|
|
|
{ return this->append(__l.begin(), __l.size()); }
|
2008-07-21 21:40:39 +02:00
|
|
|
#endif // __GXX_EXPERIMENTAL_CXX0X__
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Append a string to this string.
|
|
|
|
* @param str The string to append.
|
|
|
|
* @return Reference to this string.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2004-10-27 03:02:47 +02:00
|
|
|
append(const basic_string& __str);
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Append a substring.
|
|
|
|
* @param str The string to append.
|
|
|
|
* @param pos Index of the first character of str to append.
|
|
|
|
* @param n The number of characters to append.
|
|
|
|
* @return Reference to this string.
|
|
|
|
* @throw std::out_of_range if @a pos is not a valid index.
|
|
|
|
*
|
|
|
|
* This function appends @a n characters from @a str starting at @a pos
|
|
|
|
* to this string. If @a n is is larger than the number of available
|
|
|
|
* characters in @a str, the remainder of @a str is appended.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2000-10-05 13:27:02 +02:00
|
|
|
append(const basic_string& __str, size_type __pos, size_type __n);
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Append a C substring.
|
|
|
|
* @param s The C string to append.
|
|
|
|
* @param n The number of characters to append.
|
|
|
|
* @return Reference to this string.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2000-10-05 13:27:02 +02:00
|
|
|
append(const _CharT* __s, size_type __n);
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Append a C string.
|
|
|
|
* @param s The C string to append.
|
|
|
|
* @return Reference to this string.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2000-10-05 13:27:02 +02:00
|
|
|
append(const _CharT* __s)
|
2004-02-08 05:46:42 +01:00
|
|
|
{
|
2003-11-11 21:09:16 +01:00
|
|
|
__glibcxx_requires_string(__s);
|
2004-02-08 05:46:42 +01:00
|
|
|
return this->append(__s, traits_type::length(__s));
|
2003-11-11 21:09:16 +01:00
|
|
|
}
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Append multiple characters.
|
|
|
|
* @param n The number of characters to append.
|
|
|
|
* @param c The character to use.
|
|
|
|
* @return Reference to this string.
|
|
|
|
*
|
|
|
|
* Appends n copies of c to this string.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2004-10-27 03:02:47 +02:00
|
|
|
append(size_type __n, _CharT __c);
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2008-07-21 21:40:39 +02:00
|
|
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
|
|
|
/**
|
|
|
|
* @brief Append an initializer_list of characters.
|
|
|
|
* @param l The initializer_list of characters to append.
|
|
|
|
* @return Reference to this string.
|
|
|
|
*/
|
|
|
|
basic_string&
|
|
|
|
append(initializer_list<_CharT> __l)
|
2009-10-15 03:16:53 +02:00
|
|
|
{ return this->append(__l.begin(), __l.size()); }
|
2008-07-21 21:40:39 +02:00
|
|
|
#endif // __GXX_EXPERIMENTAL_CXX0X__
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Append a range of characters.
|
|
|
|
* @param first Iterator referencing the first character to append.
|
|
|
|
* @param last Iterator marking the end of the range.
|
|
|
|
* @return Reference to this string.
|
|
|
|
*
|
|
|
|
* Appends characters in the range [first,last) to this string.
|
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<class _InputIterator>
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2000-10-05 13:27:02 +02:00
|
|
|
append(_InputIterator __first, _InputIterator __last)
|
|
|
|
{ return this->replace(_M_iend(), _M_iend(), __first, __last); }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Append a single character.
|
|
|
|
* @param c Character to append.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
void
|
2000-10-05 13:27:02 +02:00
|
|
|
push_back(_CharT __c)
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
{
|
|
|
|
const size_type __len = 1 + this->size();
|
|
|
|
if (__len > this->capacity() || _M_rep()->_M_is_shared())
|
|
|
|
this->reserve(__len);
|
|
|
|
traits_type::assign(_M_data()[this->size()], __c);
|
|
|
|
_M_rep()->_M_set_length_and_sharable(__len);
|
|
|
|
}
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Set value to contents of another string.
|
|
|
|
* @param str Source string to use.
|
|
|
|
* @return Reference to this string.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2004-10-28 03:04:35 +02:00
|
|
|
assign(const basic_string& __str);
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2010-01-10 14:38:47 +01:00
|
|
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
|
|
|
/**
|
|
|
|
* @brief Set value to contents of another string.
|
|
|
|
* @param str Source string to use.
|
|
|
|
* @return Reference to this string.
|
|
|
|
*
|
|
|
|
* This function sets this string to the exact contents of @a str.
|
|
|
|
* @a str is a valid, but unspecified string.
|
|
|
|
*/
|
|
|
|
basic_string&
|
|
|
|
assign(basic_string&& __str)
|
|
|
|
{
|
|
|
|
this->swap(__str);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
#endif // __GXX_EXPERIMENTAL_CXX0X__
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Set value to a substring of a string.
|
|
|
|
* @param str The string to use.
|
|
|
|
* @param pos Index of the first character of str.
|
|
|
|
* @param n Number of characters to use.
|
|
|
|
* @return Reference to this string.
|
|
|
|
* @throw std::out_of_range if @a pos is not a valid index.
|
|
|
|
*
|
|
|
|
* This function sets this string to the substring of @a str consisting
|
|
|
|
* of @a n characters at @a pos. If @a n is is larger than the number
|
|
|
|
* of available characters in @a str, the remainder of @a str is used.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
basic_string.h (assign(const basic_string&, size_type, size_type)): Define inline here.
2004-01-24 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (assign(const basic_string&,
size_type, size_type)): Define inline here.
(replace(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(_M_replace_dispatch(iterator, iterator, _InputIterator,
_InputIterator, __false_type)): Only declare.
(_M_replace(iterator, iterator, _InputIterator,
_InputIterator)): Remove.
* include/bits/basic_string.tcc (assign(const basic_string&,
size_type, size_type)): Move inline.
(replace(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(_M_replace_dispatch(iterator, iterator, _InputIterator,
_InputIterator, __false_type)): Define, now does also what
_M_replace did before.
* src/string-inst.cc (_M_replace): Don't instantiate.
* include/bits/basic_string.tcc (find(const _CharT*,
size_type, size_type)): Tidy.
(rfind(_CharT, size_type)): Ditto.
(find_first_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_first_not_of(_CharT, size_type)): Ditto.
(find_last_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(_CharT, size_type)): Ditto.
From-SVN: r76508
2004-01-24 12:34:06 +01:00
|
|
|
assign(const basic_string& __str, size_type __pos, size_type __n)
|
|
|
|
{ return this->assign(__str._M_data()
|
|
|
|
+ __str._M_check(__pos, "basic_string::assign"),
|
|
|
|
__str._M_limit(__pos, __n)); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Set value to a C substring.
|
|
|
|
* @param s The C string to use.
|
|
|
|
* @param n Number of characters to use.
|
|
|
|
* @return Reference to this string.
|
|
|
|
*
|
|
|
|
* This function sets the value of this string to the first @a n
|
|
|
|
* characters of @a s. If @a n is is larger than the number of
|
|
|
|
* available characters in @a s, the remainder of @a s is used.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
Move some basic_string members out of line because they are too big to reasonably be inline.
2003-04-27 Nathan Myers <ncm@cantrip.org>
Move some basic_string members out of line because
they are too big to reasonably be inline.
* include/bits/basic_string.h
(assign(const basic_string&, size_type, size_type),
assign(const _CharT*, size_type),
insert(size_type, const basic_string&, size_type, size_type),
insert(size_type, const _CharT*, size_type),
replace(size_type, size_type, const _CharT*, size_type)):
Move from here to...
* include/bits/basic_string.tcc: ...here.
From-SVN: r66132
2003-04-27 19:20:42 +02:00
|
|
|
assign(const _CharT* __s, size_type __n);
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Set value to contents of a C string.
|
|
|
|
* @param s The C string to use.
|
|
|
|
* @return Reference to this string.
|
|
|
|
*
|
|
|
|
* This function sets the value of this string to the value of @a s.
|
|
|
|
* The data is copied, so there is no dependence on @a s once the
|
|
|
|
* function returns.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2000-10-05 13:27:02 +02:00
|
|
|
assign(const _CharT* __s)
|
2004-02-08 05:46:42 +01:00
|
|
|
{
|
2003-11-11 21:09:16 +01:00
|
|
|
__glibcxx_requires_string(__s);
|
2004-02-08 05:46:42 +01:00
|
|
|
return this->assign(__s, traits_type::length(__s));
|
2003-11-11 21:09:16 +01:00
|
|
|
}
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Set value to multiple characters.
|
|
|
|
* @param n Length of the resulting string.
|
|
|
|
* @param c The character to use.
|
|
|
|
* @return Reference to this string.
|
|
|
|
*
|
|
|
|
* This function sets the value of this string to @a n copies of
|
|
|
|
* character @a c.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2000-10-05 13:27:02 +02:00
|
|
|
assign(size_type __n, _CharT __c)
|
basic_string.h (_M_replace_safe): Change signatures to take size_types and const _CharT*.
2004-01-22 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_M_replace_safe): Change
signatures to take size_types and const _CharT*.
(_M_replace_aux): Likewise, takes size_types instead of
iterators.
(append(size_type, _CharT)): Update call.
(assign(size_type, _CharT)): Ditto.
(replace(iterator, iterator, size_type, _CharT)): Ditto.
(_M_replace_dispatch(iterator, iterator, _Integer,
_Integer, __true_type)): Ditto.
* include/bits/basic_string.tcc (assign(const _CharT*,
size_type)): Ditto.
(insert(size_type, const _CharT*, size_type)): Ditto.
(replace(size_type, size_type, const _CharT*,
size_type)): Ditto.
(_M_replace(iterator, iterator, _InputIterator,
_InputIterator)): Ditto.
(append(const basic_string&)): Ditto.
(append(const basic_string&, size_type, size_type): Ditto.
(append(const _CharT*, size_type): Ditto.
(_M_replace_safe, _M_replace_safe): Change definitions
accordingly, simplify.
* string-inst.cc (_M_replace_safe): Don't instantiate.
From-SVN: r76353
2004-01-22 13:46:28 +01:00
|
|
|
{ return _M_replace_aux(size_type(0), this->size(), __n, __c); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Set value to a range of characters.
|
|
|
|
* @param first Iterator referencing the first character to append.
|
|
|
|
* @param last Iterator marking the end of the range.
|
|
|
|
* @return Reference to this string.
|
|
|
|
*
|
|
|
|
* Sets value of string to characters in the range [first,last).
|
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<class _InputIterator>
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2000-10-05 13:27:02 +02:00
|
|
|
assign(_InputIterator __first, _InputIterator __last)
|
|
|
|
{ return this->replace(_M_ibegin(), _M_iend(), __first, __last); }
|
|
|
|
|
2008-07-21 21:40:39 +02:00
|
|
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
|
|
|
/**
|
|
|
|
* @brief Set value to an initializer_list of characters.
|
|
|
|
* @param l The initializer_list of characters to assign.
|
|
|
|
* @return Reference to this string.
|
|
|
|
*/
|
|
|
|
basic_string&
|
|
|
|
assign(initializer_list<_CharT> __l)
|
2009-10-15 03:16:53 +02:00
|
|
|
{ return this->assign(__l.begin(), __l.size()); }
|
2008-07-21 21:40:39 +02:00
|
|
|
#endif // __GXX_EXPERIMENTAL_CXX0X__
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Insert multiple characters.
|
|
|
|
* @param p Iterator referencing location in string to insert at.
|
|
|
|
* @param n Number of characters to insert
|
|
|
|
* @param c The character to insert.
|
|
|
|
* @throw std::length_error If new length exceeds @c max_size().
|
|
|
|
*
|
|
|
|
* Inserts @a n copies of character @a c starting at the position
|
|
|
|
* referenced by iterator @a p. If adding characters causes the length
|
|
|
|
* to exceed max_size(), length_error is thrown. The value of the
|
|
|
|
* string doesn't change if an error is thrown.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
void
|
2000-10-05 13:27:02 +02:00
|
|
|
insert(iterator __p, size_type __n, _CharT __c)
|
|
|
|
{ this->replace(__p, __p, __n, __c); }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Insert a range of characters.
|
|
|
|
* @param p Iterator referencing location in string to insert at.
|
|
|
|
* @param beg Start of range.
|
2004-02-08 05:46:42 +01:00
|
|
|
* @param end End of range.
|
2003-07-15 09:02:40 +02:00
|
|
|
* @throw std::length_error If new length exceeds @c max_size().
|
|
|
|
*
|
|
|
|
* Inserts characters in range [beg,end). If adding characters causes
|
|
|
|
* the length to exceed max_size(), length_error is thrown. The value
|
|
|
|
* of the string doesn't change if an error is thrown.
|
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<class _InputIterator>
|
basic_string.h (_Rep::_M_is_safe, [...]): New, use througout.
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe, _M_check_length,
_M_move, _M_copy, _M_assign): New, use througout.
(operator+=(_CharT)): Define in terms of push_back.
(append(const basic_string&)): Define here, inline, and simplify,
don't use the full _M_replace_safe.
(append(size_type, _CharT)): Likewise, don't use _M_replace_aux.
(push_back): Likewise.
(assign(const basic_string&)): Define here, inline.
* include/bits/basic_string.tcc (append(const _CharT* s, size_type):
Fix: when s points inside the _Rep, upon reallocation (reserve) we
were copying from deallocated memory.
(append(const basic_string&, size_type, size_type)): Simplify,
don't use _M_replace_safe.
(replace(size_type, size_type, const _CharT*, size_type)): Slightly
tweak.
(reserve): Likewise.
* testsuite/21_strings/basic_string/append/char/2.cc: New.
* testsuite/21_strings/basic_string/append/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/2.cc: Likewise.
* testsuite/21_strings/basic_string/append/wchar_t/3.cc: Likewise.
* testsuite/21_strings/basic_string/assign/char/3.cc: Remove junk.
* testsuite/21_strings/basic_string/assign/wchar_t/3.cc: Likewise.
From-SVN: r89526
2004-10-25 10:45:04 +02:00
|
|
|
void
|
|
|
|
insert(iterator __p, _InputIterator __beg, _InputIterator __end)
|
2000-10-05 13:27:02 +02:00
|
|
|
{ this->replace(__p, __p, __beg, __end); }
|
|
|
|
|
2008-07-21 21:40:39 +02:00
|
|
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
|
|
|
/**
|
|
|
|
* @brief Insert an initializer_list of characters.
|
|
|
|
* @param p Iterator referencing location in string to insert at.
|
|
|
|
* @param l The initializer_list of characters to insert.
|
|
|
|
* @throw std::length_error If new length exceeds @c max_size().
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
insert(iterator __p, initializer_list<_CharT> __l)
|
2009-10-15 03:16:53 +02:00
|
|
|
{
|
|
|
|
_GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
|
|
|
|
this->insert(__p - _M_ibegin(), __l.begin(), __l.size());
|
|
|
|
}
|
2008-07-21 21:40:39 +02:00
|
|
|
#endif // __GXX_EXPERIMENTAL_CXX0X__
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Insert value of a string.
|
|
|
|
* @param pos1 Iterator referencing location in string to insert at.
|
|
|
|
* @param str The string to insert.
|
|
|
|
* @return Reference to this string.
|
|
|
|
* @throw std::length_error If new length exceeds @c max_size().
|
|
|
|
*
|
|
|
|
* Inserts value of @a str starting at @a pos1. If adding characters
|
|
|
|
* causes the length to exceed max_size(), length_error is thrown. The
|
|
|
|
* value of the string doesn't change if an error is thrown.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2000-10-05 13:27:02 +02:00
|
|
|
insert(size_type __pos1, const basic_string& __str)
|
2004-01-23 14:57:19 +01:00
|
|
|
{ return this->insert(__pos1, __str, size_type(0), __str.size()); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Insert a substring.
|
|
|
|
* @param pos1 Iterator referencing location in string to insert at.
|
|
|
|
* @param str The string to insert.
|
|
|
|
* @param pos2 Start of characters in str to insert.
|
|
|
|
* @param n Number of characters to insert.
|
|
|
|
* @return Reference to this string.
|
|
|
|
* @throw std::length_error If new length exceeds @c max_size().
|
|
|
|
* @throw std::out_of_range If @a pos1 > size() or
|
|
|
|
* @a pos2 > @a str.size().
|
|
|
|
*
|
|
|
|
* Starting at @a pos1, insert @a n character of @a str beginning with
|
|
|
|
* @a pos2. If adding characters causes the length to exceed
|
|
|
|
* max_size(), length_error is thrown. If @a pos1 is beyond the end of
|
|
|
|
* this string or @a pos2 is beyond the end of @a str, out_of_range is
|
|
|
|
* thrown. The value of the string doesn't change if an error is
|
|
|
|
* thrown.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2000-10-05 13:27:02 +02:00
|
|
|
insert(size_type __pos1, const basic_string& __str,
|
2004-01-24 13:32:54 +01:00
|
|
|
size_type __pos2, size_type __n)
|
|
|
|
{ return this->insert(__pos1, __str._M_data()
|
|
|
|
+ __str._M_check(__pos2, "basic_string::insert"),
|
|
|
|
__str._M_limit(__pos2, __n)); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Insert a C substring.
|
|
|
|
* @param pos Iterator referencing location in string to insert at.
|
|
|
|
* @param s The C string to insert.
|
|
|
|
* @param n The number of characters to insert.
|
|
|
|
* @return Reference to this string.
|
|
|
|
* @throw std::length_error If new length exceeds @c max_size().
|
|
|
|
* @throw std::out_of_range If @a pos is beyond the end of this
|
2004-02-08 05:46:42 +01:00
|
|
|
* string.
|
2003-07-15 09:02:40 +02:00
|
|
|
*
|
|
|
|
* Inserts the first @a n characters of @a s starting at @a pos. If
|
|
|
|
* adding characters causes the length to exceed max_size(),
|
|
|
|
* length_error is thrown. If @a pos is beyond end(), out_of_range is
|
|
|
|
* thrown. The value of the string doesn't change if an error is
|
|
|
|
* thrown.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
Move some basic_string members out of line because they are too big to reasonably be inline.
2003-04-27 Nathan Myers <ncm@cantrip.org>
Move some basic_string members out of line because
they are too big to reasonably be inline.
* include/bits/basic_string.h
(assign(const basic_string&, size_type, size_type),
assign(const _CharT*, size_type),
insert(size_type, const basic_string&, size_type, size_type),
insert(size_type, const _CharT*, size_type),
replace(size_type, size_type, const _CharT*, size_type)):
Move from here to...
* include/bits/basic_string.tcc: ...here.
From-SVN: r66132
2003-04-27 19:20:42 +02:00
|
|
|
insert(size_type __pos, const _CharT* __s, size_type __n);
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Insert a C string.
|
|
|
|
* @param pos Iterator referencing location in string to insert at.
|
|
|
|
* @param s The C string to insert.
|
|
|
|
* @return Reference to this string.
|
|
|
|
* @throw std::length_error If new length exceeds @c max_size().
|
|
|
|
* @throw std::out_of_range If @a pos is beyond the end of this
|
|
|
|
* string.
|
|
|
|
*
|
|
|
|
* Inserts the first @a n characters of @a s starting at @a pos. If
|
|
|
|
* adding characters causes the length to exceed max_size(),
|
|
|
|
* length_error is thrown. If @a pos is beyond end(), out_of_range is
|
|
|
|
* thrown. The value of the string doesn't change if an error is
|
|
|
|
* thrown.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2000-10-05 13:27:02 +02:00
|
|
|
insert(size_type __pos, const _CharT* __s)
|
2004-02-08 05:46:42 +01:00
|
|
|
{
|
2003-11-11 21:09:16 +01:00
|
|
|
__glibcxx_requires_string(__s);
|
2004-02-08 05:46:42 +01:00
|
|
|
return this->insert(__pos, __s, traits_type::length(__s));
|
2003-11-11 21:09:16 +01:00
|
|
|
}
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Insert multiple characters.
|
|
|
|
* @param pos Index in string to insert at.
|
|
|
|
* @param n Number of characters to insert
|
|
|
|
* @param c The character to insert.
|
|
|
|
* @return Reference to this string.
|
|
|
|
* @throw std::length_error If new length exceeds @c max_size().
|
|
|
|
* @throw std::out_of_range If @a pos is beyond the end of this
|
|
|
|
* string.
|
|
|
|
*
|
|
|
|
* Inserts @a n copies of character @a c starting at index @a pos. If
|
|
|
|
* adding characters causes the length to exceed max_size(),
|
|
|
|
* length_error is thrown. If @a pos > length(), out_of_range is
|
|
|
|
* thrown. The value of the string doesn't change if an error is
|
|
|
|
* thrown.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2000-10-05 13:27:02 +02:00
|
|
|
insert(size_type __pos, size_type __n, _CharT __c)
|
2004-01-23 14:57:19 +01:00
|
|
|
{ return _M_replace_aux(_M_check(__pos, "basic_string::insert"),
|
|
|
|
size_type(0), __n, __c); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Insert one character.
|
|
|
|
* @param p Iterator referencing position in string to insert at.
|
|
|
|
* @param c The character to insert.
|
|
|
|
* @return Iterator referencing newly inserted char.
|
|
|
|
* @throw std::length_error If new length exceeds @c max_size().
|
|
|
|
*
|
|
|
|
* Inserts character @a c at position referenced by @a p. If adding
|
|
|
|
* character causes the length to exceed max_size(), length_error is
|
|
|
|
* thrown. If @a p is beyond end of string, out_of_range is thrown.
|
|
|
|
* The value of the string doesn't change if an error is thrown.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
iterator
|
2003-07-22 19:57:50 +02:00
|
|
|
insert(iterator __p, _CharT __c)
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
2003-11-11 21:09:16 +01:00
|
|
|
_GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
|
basic_string.h (_M_fold, [...]): Constify various variables.
2003-06-04 Paolo Carlini <pcarlini@unitus.it>
* include/bits/basic_string.h (_M_fold, insert(iterator, _CharT),
erase(iterator), erase(iterator, iterator), c_str,
compare(const basic_string&)): Constify various variables.
* include/bits/basic_string.tcc (_S_construct(_InIter, _InIter,
const _Alloc&, input_iterator_tag), _M_destroy, _M_mutate,
_S_create, resize, _M_replace, _M_replace_safe,
append(const basic_string&), append(const basic_string&, size_type,
size_type), append(const _CharT*, size_type), append(size_type,
_CharT), operator+(const _CharT*, const basic_string&),
operator+(_CharT, const basic_string&), replace(iterator, iterator,
size_type, _CharT), find(const _CharT*, size_type, size_type),
find(_CharT, size_type), rfind(const _CharT*, size_type, size_type),
rfind(_CharT, size_type), compare(size_type, size_type,
const basic_string&), compare(size_type, size_type,
const basic_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
From-SVN: r67468
2003-06-05 00:53:05 +02:00
|
|
|
const size_type __pos = __p - _M_ibegin();
|
2004-01-23 14:57:19 +01:00
|
|
|
_M_replace_aux(__pos, size_type(0), size_type(1), __c);
|
2002-09-01 02:33:53 +02:00
|
|
|
_M_rep()->_M_set_leaked();
|
basic_string.h (insert(iterator, _CharT), [...]): Avoid troubles with ADL, user defined operators and __normal_iterator.
2005-12-06 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (insert(iterator, _CharT),
erase(iterator), erase(iterator, iterator)): Avoid troubles
with ADL, user defined operators and __normal_iterator.
* include/bits/stl_iterator.h (operator-(const __normal_iterator
<_Iterator, _Container>&, const __normal_iterator<_Iterator,
_Container>&)): Add overload for left and right iterators of
the same type.
* include/debug/safe_iterator.h (operator-(const _Safe_iterator
<_Iterator, _Sequence>&, const _Safe_iterator<_Iterator,
_Sequence>&)): Likewise.
* testsuite/21_strings/basic_string/types/1.cc: New.
From-SVN: r108123
2005-12-06 18:19:30 +01:00
|
|
|
return iterator(_M_data() + __pos);
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Remove characters.
|
|
|
|
* @param pos Index of first character to remove (default 0).
|
|
|
|
* @param n Number of characters to remove (default remainder).
|
|
|
|
* @return Reference to this string.
|
|
|
|
* @throw std::out_of_range If @a pos is beyond the end of this
|
|
|
|
* string.
|
|
|
|
*
|
|
|
|
* Removes @a n characters from this string starting at @a pos. The
|
|
|
|
* length of the string is reduced by @a n. If there are < @a n
|
|
|
|
* characters to remove, the remainder of the string is truncated. If
|
|
|
|
* @a p is beyond end of string, out_of_range is thrown. The value of
|
|
|
|
* the string doesn't change if an error is thrown.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2000-10-05 13:27:02 +02:00
|
|
|
erase(size_type __pos = 0, size_type __n = npos)
|
2004-10-26 23:16:58 +02:00
|
|
|
{
|
|
|
|
_M_mutate(_M_check(__pos, "basic_string::erase"),
|
|
|
|
_M_limit(__pos, __n), size_type(0));
|
|
|
|
return *this;
|
|
|
|
}
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Remove one character.
|
|
|
|
* @param position Iterator referencing the character to remove.
|
|
|
|
* @return iterator referencing same location after removal.
|
|
|
|
*
|
2004-01-25 11:26:46 +01:00
|
|
|
* Removes the character at @a position from this string. The value
|
2003-07-15 09:02:40 +02:00
|
|
|
* of the string doesn't change if an error is thrown.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
iterator
|
2000-10-05 13:27:02 +02:00
|
|
|
erase(iterator __position)
|
|
|
|
{
|
2004-02-08 05:46:42 +01:00
|
|
|
_GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
|
2003-11-11 21:09:16 +01:00
|
|
|
&& __position < _M_iend());
|
2004-01-23 14:57:19 +01:00
|
|
|
const size_type __pos = __position - _M_ibegin();
|
2004-10-26 23:16:58 +02:00
|
|
|
_M_mutate(__pos, size_type(1), size_type(0));
|
2002-09-01 02:33:53 +02:00
|
|
|
_M_rep()->_M_set_leaked();
|
basic_string.h (insert(iterator, _CharT), [...]): Avoid troubles with ADL, user defined operators and __normal_iterator.
2005-12-06 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (insert(iterator, _CharT),
erase(iterator), erase(iterator, iterator)): Avoid troubles
with ADL, user defined operators and __normal_iterator.
* include/bits/stl_iterator.h (operator-(const __normal_iterator
<_Iterator, _Container>&, const __normal_iterator<_Iterator,
_Container>&)): Add overload for left and right iterators of
the same type.
* include/debug/safe_iterator.h (operator-(const _Safe_iterator
<_Iterator, _Sequence>&, const _Safe_iterator<_Iterator,
_Sequence>&)): Likewise.
* testsuite/21_strings/basic_string/types/1.cc: New.
From-SVN: r108123
2005-12-06 18:19:30 +01:00
|
|
|
return iterator(_M_data() + __pos);
|
2000-10-05 13:27:02 +02:00
|
|
|
}
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Remove a range of characters.
|
|
|
|
* @param first Iterator referencing the first character to remove.
|
|
|
|
* @param last Iterator referencing the end of the range.
|
|
|
|
* @return Iterator referencing location of first after removal.
|
|
|
|
*
|
|
|
|
* Removes the characters in the range [first,last) from this string.
|
2004-01-25 11:26:46 +01:00
|
|
|
* The value of the string doesn't change if an error is thrown.
|
2003-07-15 09:02:40 +02:00
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
iterator
|
2009-06-23 14:36:43 +02:00
|
|
|
erase(iterator __first, iterator __last);
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Replace characters with value from another string.
|
|
|
|
* @param pos Index of first character to replace.
|
|
|
|
* @param n Number of characters to be replaced.
|
|
|
|
* @param str String to insert.
|
|
|
|
* @return Reference to this string.
|
|
|
|
* @throw std::out_of_range If @a pos is beyond the end of this
|
2004-02-08 05:46:42 +01:00
|
|
|
* string.
|
2003-07-15 09:02:40 +02:00
|
|
|
* @throw std::length_error If new length exceeds @c max_size().
|
|
|
|
*
|
|
|
|
* Removes the characters in the range [pos,pos+n) from this string.
|
|
|
|
* In place, the value of @a str is inserted. If @a pos is beyond end
|
|
|
|
* of string, out_of_range is thrown. If the length of the result
|
|
|
|
* exceeds max_size(), length_error is thrown. The value of the string
|
|
|
|
* doesn't change if an error is thrown.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2000-10-05 13:27:02 +02:00
|
|
|
replace(size_type __pos, size_type __n, const basic_string& __str)
|
2002-01-14 Paolo Carlini <pcarlini@unitus.it>
Nathan Myers <ncm@cantrip.org>
* include/bits/basic_string.h
(replace(__pos, __n1, __s, __n2)): Optimize by avoiding
temporaries (i.e., call _M_replace_safe) when possible.
(replace(__pos, __n, __str)): Call replace(__pos, __n1, __s, __n2).
(replace(__pos, __n1, __s)): Call replace(__pos, __n1, __s , __n2).
(replace(__i1, __i2, __str)): Call replace(__i1, __i2, __s, __n).
(replace(__i1, __i2, __s)): Call replace(__i1, __i2, __s, __n).
(replace(__i1, __i2, __s, __n)): Call replace(__pos1, __n1, __s, __n2).
* include/bits/basic_string.tcc
(replace(__pos1, __n1, __str, __pos2, __n2)): Call
replace(__pos, __n1, __s, __n2).
* testsuite/21_strings/replace.cc (test03): New testcases.
* include/bits/basic_string.h (insert(__pos, __s, __n)):
Adjust comparison wrt overflow.
Co-Authored-By: Nathan Myers <ncm@cantrip.org>
From-SVN: r48834
2002-01-14 20:04:15 +01:00
|
|
|
{ return this->replace(__pos, __n, __str._M_data(), __str.size()); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Replace characters with value from another string.
|
|
|
|
* @param pos1 Index of first character to replace.
|
|
|
|
* @param n1 Number of characters to be replaced.
|
|
|
|
* @param str String to insert.
|
|
|
|
* @param pos2 Index of first character of str to use.
|
|
|
|
* @param n2 Number of characters from str to use.
|
|
|
|
* @return Reference to this string.
|
|
|
|
* @throw std::out_of_range If @a pos1 > size() or @a pos2 >
|
2004-02-08 05:46:42 +01:00
|
|
|
* str.size().
|
2003-07-15 09:02:40 +02:00
|
|
|
* @throw std::length_error If new length exceeds @c max_size().
|
|
|
|
*
|
|
|
|
* Removes the characters in the range [pos1,pos1 + n) from this
|
|
|
|
* string. In place, the value of @a str is inserted. If @a pos is
|
|
|
|
* beyond end of string, out_of_range is thrown. If the length of the
|
|
|
|
* result exceeds max_size(), length_error is thrown. The value of the
|
|
|
|
* string doesn't change if an error is thrown.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2000-10-05 13:27:02 +02:00
|
|
|
replace(size_type __pos1, size_type __n1, const basic_string& __str,
|
basic_string.h (assign(const basic_string&, size_type, size_type)): Define inline here.
2004-01-24 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (assign(const basic_string&,
size_type, size_type)): Define inline here.
(replace(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(_M_replace_dispatch(iterator, iterator, _InputIterator,
_InputIterator, __false_type)): Only declare.
(_M_replace(iterator, iterator, _InputIterator,
_InputIterator)): Remove.
* include/bits/basic_string.tcc (assign(const basic_string&,
size_type, size_type)): Move inline.
(replace(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(_M_replace_dispatch(iterator, iterator, _InputIterator,
_InputIterator, __false_type)): Define, now does also what
_M_replace did before.
* src/string-inst.cc (_M_replace): Don't instantiate.
* include/bits/basic_string.tcc (find(const _CharT*,
size_type, size_type)): Tidy.
(rfind(_CharT, size_type)): Ditto.
(find_first_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_first_not_of(_CharT, size_type)): Ditto.
(find_last_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(_CharT, size_type)): Ditto.
From-SVN: r76508
2004-01-24 12:34:06 +01:00
|
|
|
size_type __pos2, size_type __n2)
|
|
|
|
{ return this->replace(__pos1, __n1, __str._M_data()
|
|
|
|
+ __str._M_check(__pos2, "basic_string::replace"),
|
|
|
|
__str._M_limit(__pos2, __n2)); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Replace characters with value of a C substring.
|
|
|
|
* @param pos Index of first character to replace.
|
|
|
|
* @param n1 Number of characters to be replaced.
|
2005-06-29 14:18:08 +02:00
|
|
|
* @param s C string to insert.
|
|
|
|
* @param n2 Number of characters from @a s to use.
|
2003-07-15 09:02:40 +02:00
|
|
|
* @return Reference to this string.
|
|
|
|
* @throw std::out_of_range If @a pos1 > size().
|
|
|
|
* @throw std::length_error If new length exceeds @c max_size().
|
|
|
|
*
|
|
|
|
* Removes the characters in the range [pos,pos + n1) from this string.
|
2005-06-29 14:18:08 +02:00
|
|
|
* In place, the first @a n2 characters of @a s are inserted, or all
|
|
|
|
* of @a s if @a n2 is too large. If @a pos is beyond end of string,
|
2003-07-15 09:02:40 +02:00
|
|
|
* out_of_range is thrown. If the length of result exceeds max_size(),
|
|
|
|
* length_error is thrown. The value of the string doesn't change if
|
|
|
|
* an error is thrown.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2000-10-05 13:27:02 +02:00
|
|
|
replace(size_type __pos, size_type __n1, const _CharT* __s,
|
Move some basic_string members out of line because they are too big to reasonably be inline.
2003-04-27 Nathan Myers <ncm@cantrip.org>
Move some basic_string members out of line because
they are too big to reasonably be inline.
* include/bits/basic_string.h
(assign(const basic_string&, size_type, size_type),
assign(const _CharT*, size_type),
insert(size_type, const basic_string&, size_type, size_type),
insert(size_type, const _CharT*, size_type),
replace(size_type, size_type, const _CharT*, size_type)):
Move from here to...
* include/bits/basic_string.tcc: ...here.
From-SVN: r66132
2003-04-27 19:20:42 +02:00
|
|
|
size_type __n2);
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Replace characters with value of a C string.
|
|
|
|
* @param pos Index of first character to replace.
|
|
|
|
* @param n1 Number of characters to be replaced.
|
2005-06-29 14:18:08 +02:00
|
|
|
* @param s C string to insert.
|
2003-07-15 09:02:40 +02:00
|
|
|
* @return Reference to this string.
|
|
|
|
* @throw std::out_of_range If @a pos > size().
|
|
|
|
* @throw std::length_error If new length exceeds @c max_size().
|
|
|
|
*
|
|
|
|
* Removes the characters in the range [pos,pos + n1) from this string.
|
2005-06-29 14:18:08 +02:00
|
|
|
* In place, the first @a n characters of @a s are inserted. If @a
|
2003-07-15 09:02:40 +02:00
|
|
|
* pos is beyond end of string, out_of_range is thrown. If the length
|
|
|
|
* of result exceeds max_size(), length_error is thrown. The value of
|
|
|
|
* the string doesn't change if an error is thrown.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2000-10-05 13:27:02 +02:00
|
|
|
replace(size_type __pos, size_type __n1, const _CharT* __s)
|
2004-02-08 05:46:42 +01:00
|
|
|
{
|
2003-11-11 21:09:16 +01:00
|
|
|
__glibcxx_requires_string(__s);
|
2004-02-08 05:46:42 +01:00
|
|
|
return this->replace(__pos, __n1, __s, traits_type::length(__s));
|
2003-11-11 21:09:16 +01:00
|
|
|
}
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Replace characters with multiple characters.
|
|
|
|
* @param pos Index of first character to replace.
|
|
|
|
* @param n1 Number of characters to be replaced.
|
|
|
|
* @param n2 Number of characters to insert.
|
|
|
|
* @param c Character to insert.
|
|
|
|
* @return Reference to this string.
|
|
|
|
* @throw std::out_of_range If @a pos > size().
|
|
|
|
* @throw std::length_error If new length exceeds @c max_size().
|
|
|
|
*
|
|
|
|
* Removes the characters in the range [pos,pos + n1) from this string.
|
|
|
|
* In place, @a n2 copies of @a c are inserted. If @a pos is beyond
|
|
|
|
* end of string, out_of_range is thrown. If the length of result
|
|
|
|
* exceeds max_size(), length_error is thrown. The value of the string
|
|
|
|
* doesn't change if an error is thrown.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2000-10-05 13:27:02 +02:00
|
|
|
replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
|
2004-01-23 14:57:19 +01:00
|
|
|
{ return _M_replace_aux(_M_check(__pos, "basic_string::replace"),
|
|
|
|
_M_limit(__pos, __n1), __n2, __c); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Replace range of characters with string.
|
|
|
|
* @param i1 Iterator referencing start of range to replace.
|
|
|
|
* @param i2 Iterator referencing end of range to replace.
|
|
|
|
* @param str String value to insert.
|
|
|
|
* @return Reference to this string.
|
|
|
|
* @throw std::length_error If new length exceeds @c max_size().
|
|
|
|
*
|
|
|
|
* Removes the characters in the range [i1,i2). In place, the value of
|
|
|
|
* @a str is inserted. If the length of result exceeds max_size(),
|
|
|
|
* length_error is thrown. The value of the string doesn't change if
|
|
|
|
* an error is thrown.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2000-10-05 13:27:02 +02:00
|
|
|
replace(iterator __i1, iterator __i2, const basic_string& __str)
|
2004-01-26 13:58:53 +01:00
|
|
|
{ return this->replace(__i1, __i2, __str._M_data(), __str.size()); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Replace range of characters with C substring.
|
|
|
|
* @param i1 Iterator referencing start of range to replace.
|
|
|
|
* @param i2 Iterator referencing end of range to replace.
|
|
|
|
* @param s C string value to insert.
|
|
|
|
* @param n Number of characters from s to insert.
|
|
|
|
* @return Reference to this string.
|
|
|
|
* @throw std::length_error If new length exceeds @c max_size().
|
|
|
|
*
|
|
|
|
* Removes the characters in the range [i1,i2). In place, the first @a
|
|
|
|
* n characters of @a s are inserted. If the length of result exceeds
|
|
|
|
* max_size(), length_error is thrown. The value of the string doesn't
|
|
|
|
* change if an error is thrown.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2004-01-26 13:58:53 +01:00
|
|
|
replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n)
|
|
|
|
{
|
|
|
|
_GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
|
2004-02-08 05:46:42 +01:00
|
|
|
&& __i2 <= _M_iend());
|
2004-01-26 13:58:53 +01:00
|
|
|
return this->replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
|
|
|
|
}
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Replace range of characters with C string.
|
|
|
|
* @param i1 Iterator referencing start of range to replace.
|
|
|
|
* @param i2 Iterator referencing end of range to replace.
|
|
|
|
* @param s C string value to insert.
|
|
|
|
* @return Reference to this string.
|
|
|
|
* @throw std::length_error If new length exceeds @c max_size().
|
|
|
|
*
|
|
|
|
* Removes the characters in the range [i1,i2). In place, the
|
|
|
|
* characters of @a s are inserted. If the length of result exceeds
|
|
|
|
* max_size(), length_error is thrown. The value of the string doesn't
|
|
|
|
* change if an error is thrown.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2000-10-05 13:27:02 +02:00
|
|
|
replace(iterator __i1, iterator __i2, const _CharT* __s)
|
2004-02-08 05:46:42 +01:00
|
|
|
{
|
2003-11-11 21:09:16 +01:00
|
|
|
__glibcxx_requires_string(__s);
|
2004-02-08 05:46:42 +01:00
|
|
|
return this->replace(__i1, __i2, __s, traits_type::length(__s));
|
2003-11-11 21:09:16 +01:00
|
|
|
}
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Replace range of characters with multiple characters
|
|
|
|
* @param i1 Iterator referencing start of range to replace.
|
|
|
|
* @param i2 Iterator referencing end of range to replace.
|
|
|
|
* @param n Number of characters to insert.
|
|
|
|
* @param c Character to insert.
|
|
|
|
* @return Reference to this string.
|
|
|
|
* @throw std::length_error If new length exceeds @c max_size().
|
|
|
|
*
|
|
|
|
* Removes the characters in the range [i1,i2). In place, @a n copies
|
|
|
|
* of @a c are inserted. If the length of result exceeds max_size(),
|
|
|
|
* length_error is thrown. The value of the string doesn't change if
|
|
|
|
* an error is thrown.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2003-06-21 00:12:18 +02:00
|
|
|
replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
|
2004-02-08 05:46:42 +01:00
|
|
|
{
|
2003-11-11 21:09:16 +01:00
|
|
|
_GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
|
|
|
|
&& __i2 <= _M_iend());
|
2004-02-08 05:46:42 +01:00
|
|
|
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
|
2003-11-11 21:09:16 +01:00
|
|
|
}
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Replace range of characters with range.
|
|
|
|
* @param i1 Iterator referencing start of range to replace.
|
|
|
|
* @param i2 Iterator referencing end of range to replace.
|
|
|
|
* @param k1 Iterator referencing start of range to insert.
|
|
|
|
* @param k2 Iterator referencing end of range to insert.
|
|
|
|
* @return Reference to this string.
|
|
|
|
* @throw std::length_error If new length exceeds @c max_size().
|
|
|
|
*
|
|
|
|
* Removes the characters in the range [i1,i2). In place, characters
|
|
|
|
* in the range [k1,k2) are inserted. If the length of result exceeds
|
|
|
|
* max_size(), length_error is thrown. The value of the string doesn't
|
|
|
|
* change if an error is thrown.
|
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<class _InputIterator>
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2000-10-05 13:27:02 +02:00
|
|
|
replace(iterator __i1, iterator __i2,
|
|
|
|
_InputIterator __k1, _InputIterator __k2)
|
2004-02-08 05:46:42 +01:00
|
|
|
{
|
2003-11-11 21:09:16 +01:00
|
|
|
_GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
|
|
|
|
&& __i2 <= _M_iend());
|
|
|
|
__glibcxx_requires_valid_range(__k1, __k2);
|
cpp_type_traits.h: Add types to the structs thus making type_traits.h redundant...
2005-01-31 Paolo Carlini <pcarlini@suse.de>
Gabriel Dos Reis <gdr@integrable-solutions.net>
* include/bits/cpp_type_traits.h: Add types to the structs thus
making type_traits.h redundant; exploit new __truth_type and
__traitor helpers.
* include/bits/type_traits.h: Remove.
* include/Makefile.am: Update.
* include/Makefile.in: Regenerate.
* include/backward/tempbuf.h: Include cpp_type_traits.h instead.
* include/bits/basic_string.h (replace(iterator, iterator,
_InputIterator, _InputIterator), _S_construct(_InIterator,
_InIterator, const _Alloc&)): Use __is_integer instead.
* include/bits/stl_bvector.h (vector(_InputIterator,
_InputIterator, const allocator_type&), assign(_InputIterator,
_InputIterator), insert(iterator, _InputIterator, _InputIterator)):
Likewise.
* include/bits/stl_construct.h (_Destroy(_ForwardIterator,
_ForwardIterator)): Use __is_scalar.
* include/bits/stl_deque.h (deque(_InputIterator, _InputIterator,
const allocator_type&), assign(_InputIterator, _InputIterator),
insert(iterator, _InputIterator, _InputIterator)): Use __is_integer.
* include/bits/stl_list.h (assign(_InputIterator, _InputIterator),
insert(iterator, _InputIterator, _InputIterator)): Likewise.
* include/bits/stl_tempbuf.h (_Temporary_buffer(_ForwardIterator,
_ForwardIterator)): Use __is_scalar.
* include/bits/stl_uninitialized.h (uninitialized_copy(_InputIterator,
_InputIterator, _ForwardIterator), uninitialized_fill(_ForwardIterator,
_ForwardIterator, const _Tp&), uninitialized_fill_n(_ForwardIterator,
_Size, const _Tp&)): Likewise.
* include/bits/stl_vector.h (vector(_InputIterator, _InputIterator,
const allocator_type&), assign(_InputIterator, _InputIterator),
insert(iterator, _InputIterator, _InputIterator)): Use __is_integer.
* include/debug/debug.h (__valid_range(const _InputIterator&,
const _InputIterator&)): Use __is_integer.
* include/ext/slist (assign(_InputIterator, _InputIterator)): Likewise.
* include/std/std_string.h: Include cpp_type_traits.h instead.
Co-Authored-By: Gabriel Dos Reis <gdr@integrable-solutions.net>
From-SVN: r94484
2005-01-31 17:22:01 +01:00
|
|
|
typedef typename std::__is_integer<_InputIterator>::__type _Integral;
|
2004-02-08 05:46:42 +01:00
|
|
|
return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
|
2003-11-11 21:09:16 +01:00
|
|
|
}
|
2000-10-05 13:27:02 +02:00
|
|
|
|
basic_string.h (replace(i1, i2, _CharT* k1, _CharT* k2), [...]): New specializations to optimize for the common cases of pointers and iterators.
2002-04-02 Paolo Carlini <pcarlini@unitus.it>
Nathan Myers <ncm@cantrip.org>
Philip Martin <philip@codematters.co.uk>
* include/bits/basic_string.h
(replace(i1, i2, _CharT* k1, _CharT* k2),
replace(i2, i2, const _CharT* k1, const _CharT* k2),
replace(i1, i2, iterator k1, iterator k2,
replace(i1, i2, const_iterator k1, const_iterator k2):
New specializations to optimize for the common cases of
pointers and iterators.
(replace(pos, n1, s, n2)): Tweak.
* include/bits/basic_string.tcc: Tweak comments.
* testsuite/21_strings/replace.cc (test04): New tests.
Co-Authored-By: Nathan Myers <ncm@cantrip.org>
Co-Authored-By: Philip Martin <philip@codematters.co.uk>
From-SVN: r51746
2002-04-02 14:07:07 +02:00
|
|
|
// Specializations for the common case of pointer and iterator:
|
|
|
|
// useful to avoid the overhead of temporary buffering in _M_replace.
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2004-07-04 19:57:58 +02:00
|
|
|
replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
|
|
|
|
{
|
|
|
|
_GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
|
|
|
|
&& __i2 <= _M_iend());
|
|
|
|
__glibcxx_requires_valid_range(__k1, __k2);
|
|
|
|
return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
|
|
|
|
__k1, __k2 - __k1);
|
|
|
|
}
|
basic_string.h (replace(i1, i2, _CharT* k1, _CharT* k2), [...]): New specializations to optimize for the common cases of pointers and iterators.
2002-04-02 Paolo Carlini <pcarlini@unitus.it>
Nathan Myers <ncm@cantrip.org>
Philip Martin <philip@codematters.co.uk>
* include/bits/basic_string.h
(replace(i1, i2, _CharT* k1, _CharT* k2),
replace(i2, i2, const _CharT* k1, const _CharT* k2),
replace(i1, i2, iterator k1, iterator k2,
replace(i1, i2, const_iterator k1, const_iterator k2):
New specializations to optimize for the common cases of
pointers and iterators.
(replace(pos, n1, s, n2)): Tweak.
* include/bits/basic_string.tcc: Tweak comments.
* testsuite/21_strings/replace.cc (test04): New tests.
Co-Authored-By: Nathan Myers <ncm@cantrip.org>
Co-Authored-By: Philip Martin <philip@codematters.co.uk>
From-SVN: r51746
2002-04-02 14:07:07 +02:00
|
|
|
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2004-07-04 19:57:58 +02:00
|
|
|
replace(iterator __i1, iterator __i2,
|
|
|
|
const _CharT* __k1, const _CharT* __k2)
|
|
|
|
{
|
|
|
|
_GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
|
|
|
|
&& __i2 <= _M_iend());
|
|
|
|
__glibcxx_requires_valid_range(__k1, __k2);
|
|
|
|
return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
|
|
|
|
__k1, __k2 - __k1);
|
|
|
|
}
|
basic_string.h (replace(i1, i2, _CharT* k1, _CharT* k2), [...]): New specializations to optimize for the common cases of pointers and iterators.
2002-04-02 Paolo Carlini <pcarlini@unitus.it>
Nathan Myers <ncm@cantrip.org>
Philip Martin <philip@codematters.co.uk>
* include/bits/basic_string.h
(replace(i1, i2, _CharT* k1, _CharT* k2),
replace(i2, i2, const _CharT* k1, const _CharT* k2),
replace(i1, i2, iterator k1, iterator k2,
replace(i1, i2, const_iterator k1, const_iterator k2):
New specializations to optimize for the common cases of
pointers and iterators.
(replace(pos, n1, s, n2)): Tweak.
* include/bits/basic_string.tcc: Tweak comments.
* testsuite/21_strings/replace.cc (test04): New tests.
Co-Authored-By: Nathan Myers <ncm@cantrip.org>
Co-Authored-By: Philip Martin <philip@codematters.co.uk>
From-SVN: r51746
2002-04-02 14:07:07 +02:00
|
|
|
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2004-07-04 19:57:58 +02:00
|
|
|
replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
|
|
|
|
{
|
|
|
|
_GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
|
|
|
|
&& __i2 <= _M_iend());
|
|
|
|
__glibcxx_requires_valid_range(__k1, __k2);
|
|
|
|
return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
|
|
|
|
__k1.base(), __k2 - __k1);
|
|
|
|
}
|
basic_string.h (replace(i1, i2, _CharT* k1, _CharT* k2), [...]): New specializations to optimize for the common cases of pointers and iterators.
2002-04-02 Paolo Carlini <pcarlini@unitus.it>
Nathan Myers <ncm@cantrip.org>
Philip Martin <philip@codematters.co.uk>
* include/bits/basic_string.h
(replace(i1, i2, _CharT* k1, _CharT* k2),
replace(i2, i2, const _CharT* k1, const _CharT* k2),
replace(i1, i2, iterator k1, iterator k2,
replace(i1, i2, const_iterator k1, const_iterator k2):
New specializations to optimize for the common cases of
pointers and iterators.
(replace(pos, n1, s, n2)): Tweak.
* include/bits/basic_string.tcc: Tweak comments.
* testsuite/21_strings/replace.cc (test04): New tests.
Co-Authored-By: Nathan Myers <ncm@cantrip.org>
Co-Authored-By: Philip Martin <philip@codematters.co.uk>
From-SVN: r51746
2002-04-02 14:07:07 +02:00
|
|
|
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string&
|
2004-07-04 19:57:58 +02:00
|
|
|
replace(iterator __i1, iterator __i2,
|
|
|
|
const_iterator __k1, const_iterator __k2)
|
|
|
|
{
|
|
|
|
_GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
|
|
|
|
&& __i2 <= _M_iend());
|
|
|
|
__glibcxx_requires_valid_range(__k1, __k2);
|
|
|
|
return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
|
|
|
|
__k1.base(), __k2 - __k1);
|
|
|
|
}
|
|
|
|
|
2008-07-21 21:40:39 +02:00
|
|
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
|
|
|
/**
|
|
|
|
* @brief Replace range of characters with initializer_list.
|
|
|
|
* @param i1 Iterator referencing start of range to replace.
|
|
|
|
* @param i2 Iterator referencing end of range to replace.
|
|
|
|
* @param l The initializer_list of characters to insert.
|
|
|
|
* @return Reference to this string.
|
|
|
|
* @throw std::length_error If new length exceeds @c max_size().
|
|
|
|
*
|
|
|
|
* Removes the characters in the range [i1,i2). In place, characters
|
|
|
|
* in the range [k1,k2) are inserted. If the length of result exceeds
|
|
|
|
* max_size(), length_error is thrown. The value of the string doesn't
|
|
|
|
* change if an error is thrown.
|
|
|
|
*/
|
re PR libstdc++/41773 (Many libstdc++ failures)
2009-10-20 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/41773
Revert:
2009-10-20 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/basic_string.h (_S_construct(const _CharT*, size_type,
const _Alloc&)): New, declare.
(_S_construct(_CharT*, _CharT*, const _Alloc&),
_S_construct(const _CharT*, const _CharT*, const _Alloc&),
_S_construct(iterator, iterator, const _Alloc&),
_S_construct(const_iterator, const_iterator, const _Alloc&)): New,
forward to the latter.
* include/bits/basic_string.tcc (_S_construct(const _CharT*,
size_type, const _Alloc&)): Define.
(basic_string(const basic_string&, size_type, size_type),
basic_string(const basic_string&, size_type, size_type,
const _Alloc&), basic_string(const _CharT*, size_type,
const _Alloc&), basic_string(const _CharT*, const _Alloc&),
basic_string(initializer_list<>, const _Alloc&)): Call the latter.
* config/abi/pre/gnu.ver: Remove recently added exports.
* src/string-inst.cc: Remove instantiations.
From-SVN: r153040
2009-10-20 23:54:22 +02:00
|
|
|
basic_string& replace(iterator __i1, iterator __i2,
|
|
|
|
initializer_list<_CharT> __l)
|
2008-07-21 21:40:39 +02:00
|
|
|
{ return this->replace(__i1, __i2, __l.begin(), __l.end()); }
|
|
|
|
#endif // __GXX_EXPERIMENTAL_CXX0X__
|
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
private:
|
2003-06-21 00:12:18 +02:00
|
|
|
template<class _Integer>
|
|
|
|
basic_string&
|
2004-02-08 05:46:42 +01:00
|
|
|
_M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
|
2003-06-21 00:12:18 +02:00
|
|
|
_Integer __val, __true_type)
|
basic_string.h (_M_replace_safe): Change signatures to take size_types and const _CharT*.
2004-01-22 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_M_replace_safe): Change
signatures to take size_types and const _CharT*.
(_M_replace_aux): Likewise, takes size_types instead of
iterators.
(append(size_type, _CharT)): Update call.
(assign(size_type, _CharT)): Ditto.
(replace(iterator, iterator, size_type, _CharT)): Ditto.
(_M_replace_dispatch(iterator, iterator, _Integer,
_Integer, __true_type)): Ditto.
* include/bits/basic_string.tcc (assign(const _CharT*,
size_type)): Ditto.
(insert(size_type, const _CharT*, size_type)): Ditto.
(replace(size_type, size_type, const _CharT*,
size_type)): Ditto.
(_M_replace(iterator, iterator, _InputIterator,
_InputIterator)): Ditto.
(append(const basic_string&)): Ditto.
(append(const basic_string&, size_type, size_type): Ditto.
(append(const _CharT*, size_type): Ditto.
(_M_replace_safe, _M_replace_safe): Change definitions
accordingly, simplify.
* string-inst.cc (_M_replace_safe): Don't instantiate.
From-SVN: r76353
2004-01-22 13:46:28 +01:00
|
|
|
{ return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
|
2003-06-21 00:12:18 +02:00
|
|
|
|
|
|
|
template<class _InputIterator>
|
|
|
|
basic_string&
|
|
|
|
_M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
|
basic_string.h (assign(const basic_string&, size_type, size_type)): Define inline here.
2004-01-24 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (assign(const basic_string&,
size_type, size_type)): Define inline here.
(replace(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(_M_replace_dispatch(iterator, iterator, _InputIterator,
_InputIterator, __false_type)): Only declare.
(_M_replace(iterator, iterator, _InputIterator,
_InputIterator)): Remove.
* include/bits/basic_string.tcc (assign(const basic_string&,
size_type, size_type)): Move inline.
(replace(size_type, size_type, const basic_string&,
size_type, size_type)): Ditto.
(_M_replace_dispatch(iterator, iterator, _InputIterator,
_InputIterator, __false_type)): Define, now does also what
_M_replace did before.
* src/string-inst.cc (_M_replace): Don't instantiate.
* include/bits/basic_string.tcc (find(const _CharT*,
size_type, size_type)): Tidy.
(rfind(_CharT, size_type)): Ditto.
(find_first_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_first_not_of(_CharT, size_type)): Ditto.
(find_last_not_of(const _CharT*, size_type, size_type)): Ditto.
(find_last_not_of(_CharT, size_type)): Ditto.
From-SVN: r76508
2004-01-24 12:34:06 +01:00
|
|
|
_InputIterator __k2, __false_type);
|
2003-06-21 00:12:18 +02:00
|
|
|
|
|
|
|
basic_string&
|
2004-01-25 23:43:07 +01:00
|
|
|
_M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
|
2004-10-27 14:02:37 +02:00
|
|
|
_CharT __c);
|
2003-06-21 00:12:18 +02:00
|
|
|
|
basic_string.h (_M_replace_safe): Change signatures to take size_types and const _CharT*.
2004-01-22 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_M_replace_safe): Change
signatures to take size_types and const _CharT*.
(_M_replace_aux): Likewise, takes size_types instead of
iterators.
(append(size_type, _CharT)): Update call.
(assign(size_type, _CharT)): Ditto.
(replace(iterator, iterator, size_type, _CharT)): Ditto.
(_M_replace_dispatch(iterator, iterator, _Integer,
_Integer, __true_type)): Ditto.
* include/bits/basic_string.tcc (assign(const _CharT*,
size_type)): Ditto.
(insert(size_type, const _CharT*, size_type)): Ditto.
(replace(size_type, size_type, const _CharT*,
size_type)): Ditto.
(_M_replace(iterator, iterator, _InputIterator,
_InputIterator)): Ditto.
(append(const basic_string&)): Ditto.
(append(const basic_string&, size_type, size_type): Ditto.
(append(const _CharT*, size_type): Ditto.
(_M_replace_safe, _M_replace_safe): Change definitions
accordingly, simplify.
* string-inst.cc (_M_replace_safe): Don't instantiate.
From-SVN: r76353
2004-01-22 13:46:28 +01:00
|
|
|
basic_string&
|
|
|
|
_M_replace_safe(size_type __pos1, size_type __n1, const _CharT* __s,
|
2004-10-27 14:02:37 +02:00
|
|
|
size_type __n2);
|
2000-10-05 13:27:02 +02:00
|
|
|
|
|
|
|
// _S_construct_aux is used to implement the 21.3.1 para 15 which
|
|
|
|
// requires special behaviour if _InIter is an integral type
|
BUGS: Update from 2.90.8 snapshot.
2003-06-10 Phil Edwards <pme@gcc.gnu.org>
* docs/html/17_intro/BUGS: Update from 2.90.8 snapshot.
* docs/html/17_intro/CHECKLIST: Bring up to date with respect to
correctness of container::iterator typedefs. Fix whitespace.
* docs/html/20_util/howto.html, docs/html/ext/howto.html: Add links
to allocator docs.
* docs/html/documentation.html: Regenerate.
* include/bits/basic_string.h, include/bits/basic_string.tcc,
include/bits/deque.tcc, include/bits/list.tcc, include/bits/stl_algo.h,
include/bits/stl_algobase.h, include/bits/stl_bvector.h,
include/bits/stl_deque.h, include/bits/stl_iterator_base_funcs.h,
include/bits/stl_list.h, include/bits/stl_uninitialized.h,
include/bits/stl_vector.h, include/bits/vector.tcc,
include/ext/algorithm, include/ext/slist, include/std/std_bitset.h:
Change _Iter names to _Iterator, and __pos to __position.
* include/bits/stl_relops.h, include/bits/stl_numeric.h,
include/bits/stl_multiset.h, include/bits/stl_set.h:
Remove emacs markers.
* include/bits/stl_threads.h (_STL_auto_lock): Add __unused__.
From-SVN: r67736
2003-06-10 23:52:25 +02:00
|
|
|
template<class _InIterator>
|
2000-10-05 13:27:02 +02:00
|
|
|
static _CharT*
|
basic_string.h (_M_replace_aux): Use the __N marker in throw message.
2004-01-26 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_M_replace_aux): Use the
__N marker in throw message.
* include/bits/basic_string.tcc (assign(const _CharT*,
size_type), insert(size_type, const _CharT*, size_type),
replace(size_type, size_type, const _CharT*, size_type),
reserve, _Rep::_S_create, resize, _M_replace_dispatch):
Likewise.
* include/bits/basic_string.h, include/bits/basic_string.tcc:
Fold overlong lines, minor formatting changes.
From-SVN: r76664
2004-01-26 21:23:20 +01:00
|
|
|
_S_construct_aux(_InIterator __beg, _InIterator __end,
|
|
|
|
const _Alloc& __a, __false_type)
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
BUGS: Update from 2.90.8 snapshot.
2003-06-10 Phil Edwards <pme@gcc.gnu.org>
* docs/html/17_intro/BUGS: Update from 2.90.8 snapshot.
* docs/html/17_intro/CHECKLIST: Bring up to date with respect to
correctness of container::iterator typedefs. Fix whitespace.
* docs/html/20_util/howto.html, docs/html/ext/howto.html: Add links
to allocator docs.
* docs/html/documentation.html: Regenerate.
* include/bits/basic_string.h, include/bits/basic_string.tcc,
include/bits/deque.tcc, include/bits/list.tcc, include/bits/stl_algo.h,
include/bits/stl_algobase.h, include/bits/stl_bvector.h,
include/bits/stl_deque.h, include/bits/stl_iterator_base_funcs.h,
include/bits/stl_list.h, include/bits/stl_uninitialized.h,
include/bits/stl_vector.h, include/bits/vector.tcc,
include/ext/algorithm, include/ext/slist, include/std/std_bitset.h:
Change _Iter names to _Iterator, and __pos to __position.
* include/bits/stl_relops.h, include/bits/stl_numeric.h,
include/bits/stl_multiset.h, include/bits/stl_set.h:
Remove emacs markers.
* include/bits/stl_threads.h (_STL_auto_lock): Add __unused__.
From-SVN: r67736
2003-06-10 23:52:25 +02:00
|
|
|
typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
|
2000-10-05 13:27:02 +02:00
|
|
|
return _S_construct(__beg, __end, __a, _Tag());
|
|
|
|
}
|
2002-09-01 02:33:53 +02:00
|
|
|
|
DR 438, [DR].
2007-04-27 Paolo Carlini <pcarlini@suse.de>
DR 438, [DR].
* include/bits/basic_string.h (_S_construct_aux(_InIterator,
_InIterator, const _Alloc&, __true_type)): Do not cast the
second argument.
* include/ext/rc_string_base.h (_S_construct_aux(_Integer,
_Integer, const _Alloc&, std::__true_type)): Likewise.
* include/ext/sso_string_base.h (_M_construct_aux(_InIterator,
_InIterator, std::__true_type)): Likewise.
* include/bits/stl_deque.h (_M_initialize_dispatch(_Integer,
_Integer, __true_type)): Cast the first argument.
(_M_assign_dispatch(_Integer, _Integer, __true_type)): Do
not cast the arguments.
(_M_insert_dispatch(iterator, _Integer, _Integer, __true_type)):
Likewise.
* include/bits/stl_list.h (_M_initialize_dispatch(_Integer,
_Integer, __true_type)): Likewise.
(_M_assign_dispatch(_Integer, _Integer, __true_type)): Do
not cast both arguments.
* include/bits/stl_bvector.h (_M_initialize_dispatch(_Integer,
_Integer, __true_type)): Cast the first argument.
(_M_assign_dispatch(_Integer, _Integer, __true_type)): Do not
cast the arguments.
* include/bits/stl_vector.h (_M_initialize_dispatch(_Integer,
_Integer, __true_type)): Cast the first argument.
(_M_assign_dispatch(_Integer, _Integer, __true_type)): Do not
cast the arguments.
(_M_insert_dispatch(iterator, _Integer, _Integer, __true_type)):
Likewise.
* testsuite/21_strings/basic_string/requirements/dr438/
constructor.cc: New.
* testsuite/ext/vstring/requirements/dr438/constructor.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/deque/
assign_neg.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/deque/
constructor.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/deque/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/deque/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/deque/
insert_neg.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/list/
assign_neg.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/list/
constructor.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/list/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/list/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/list/
insert_neg.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/vector/
assign_neg.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/vector/
constructor.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/vector/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/vector/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/vector/
insert_neg.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/vector/
bool/constructor.cc: Likewise.
* docs/html/ext/howto.html: Add an entry for DR 438.
From-SVN: r124243
2007-04-28 00:59:36 +02:00
|
|
|
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
|
|
// 438. Ambiguity in the "do the right thing" clause
|
|
|
|
template<class _Integer>
|
2000-10-05 13:27:02 +02:00
|
|
|
static _CharT*
|
DR 438, [DR].
2007-04-27 Paolo Carlini <pcarlini@suse.de>
DR 438, [DR].
* include/bits/basic_string.h (_S_construct_aux(_InIterator,
_InIterator, const _Alloc&, __true_type)): Do not cast the
second argument.
* include/ext/rc_string_base.h (_S_construct_aux(_Integer,
_Integer, const _Alloc&, std::__true_type)): Likewise.
* include/ext/sso_string_base.h (_M_construct_aux(_InIterator,
_InIterator, std::__true_type)): Likewise.
* include/bits/stl_deque.h (_M_initialize_dispatch(_Integer,
_Integer, __true_type)): Cast the first argument.
(_M_assign_dispatch(_Integer, _Integer, __true_type)): Do
not cast the arguments.
(_M_insert_dispatch(iterator, _Integer, _Integer, __true_type)):
Likewise.
* include/bits/stl_list.h (_M_initialize_dispatch(_Integer,
_Integer, __true_type)): Likewise.
(_M_assign_dispatch(_Integer, _Integer, __true_type)): Do
not cast both arguments.
* include/bits/stl_bvector.h (_M_initialize_dispatch(_Integer,
_Integer, __true_type)): Cast the first argument.
(_M_assign_dispatch(_Integer, _Integer, __true_type)): Do not
cast the arguments.
* include/bits/stl_vector.h (_M_initialize_dispatch(_Integer,
_Integer, __true_type)): Cast the first argument.
(_M_assign_dispatch(_Integer, _Integer, __true_type)): Do not
cast the arguments.
(_M_insert_dispatch(iterator, _Integer, _Integer, __true_type)):
Likewise.
* testsuite/21_strings/basic_string/requirements/dr438/
constructor.cc: New.
* testsuite/ext/vstring/requirements/dr438/constructor.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/deque/
assign_neg.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/deque/
constructor.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/deque/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/deque/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/deque/
insert_neg.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/list/
assign_neg.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/list/
constructor.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/list/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/list/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/list/
insert_neg.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/vector/
assign_neg.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/vector/
constructor.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/vector/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/vector/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/vector/
insert_neg.cc: Likewise.
* testsuite/23_containers/requirements/sequences/dr438/vector/
bool/constructor.cc: Likewise.
* docs/html/ext/howto.html: Add an entry for DR 438.
From-SVN: r124243
2007-04-28 00:59:36 +02:00
|
|
|
_S_construct_aux(_Integer __beg, _Integer __end,
|
basic_string.h (_M_replace_aux): Use the __N marker in throw message.
2004-01-26 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_M_replace_aux): Use the
__N marker in throw message.
* include/bits/basic_string.tcc (assign(const _CharT*,
size_type), insert(size_type, const _CharT*, size_type),
replace(size_type, size_type, const _CharT*, size_type),
reserve, _Rep::_S_create, resize, _M_replace_dispatch):
Likewise.
* include/bits/basic_string.h, include/bits/basic_string.tcc:
Fold overlong lines, minor formatting changes.
From-SVN: r76664
2004-01-26 21:23:20 +01:00
|
|
|
const _Alloc& __a, __true_type)
|
PR libstdc++/42261 (take 2)
2009-12-10 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/42261 (take 2)
* include/bits/basic_string.h (_S_construct_aux_2(size_type, _CharT,
const _Alloc&)): Add.
(_S_construct_aux(_Integer, _Integer, const _Alloc&, __true_type)):
Call it.
* include/ext/sso_string_base.h (_M_construct_aux_2(size_type,
_CharT): Add.
(_M_construct_aux(_Integer, _Integer, std::__true_type)): Call it.
* include/ext/rc_string_base.h (_S_construct_aux_2(size_type, _CharT,
const _Alloc&)): Add.
(_S_construct_aux(_Integer, _Integer, const _Alloc&, __true_type)):
Call it.
* config/abi/pre/gnu.ver: Export basic_string::_S_construct_aux_2.
* testsuite/21_strings/basic_string/cons/char/42261.cc: New.
* testsuite/21_strings/basic_string/cons/wchar_t/42261.cc: Likewise.
From-SVN: r155137
2009-12-10 20:17:27 +01:00
|
|
|
{ return _S_construct_aux_2(static_cast<size_type>(__beg),
|
|
|
|
__end, __a); }
|
|
|
|
|
|
|
|
static _CharT*
|
|
|
|
_S_construct_aux_2(size_type __req, _CharT __c, const _Alloc& __a)
|
|
|
|
{ return _S_construct(__req, __c, __a); }
|
2002-09-01 02:33:53 +02:00
|
|
|
|
BUGS: Update from 2.90.8 snapshot.
2003-06-10 Phil Edwards <pme@gcc.gnu.org>
* docs/html/17_intro/BUGS: Update from 2.90.8 snapshot.
* docs/html/17_intro/CHECKLIST: Bring up to date with respect to
correctness of container::iterator typedefs. Fix whitespace.
* docs/html/20_util/howto.html, docs/html/ext/howto.html: Add links
to allocator docs.
* docs/html/documentation.html: Regenerate.
* include/bits/basic_string.h, include/bits/basic_string.tcc,
include/bits/deque.tcc, include/bits/list.tcc, include/bits/stl_algo.h,
include/bits/stl_algobase.h, include/bits/stl_bvector.h,
include/bits/stl_deque.h, include/bits/stl_iterator_base_funcs.h,
include/bits/stl_list.h, include/bits/stl_uninitialized.h,
include/bits/stl_vector.h, include/bits/vector.tcc,
include/ext/algorithm, include/ext/slist, include/std/std_bitset.h:
Change _Iter names to _Iterator, and __pos to __position.
* include/bits/stl_relops.h, include/bits/stl_numeric.h,
include/bits/stl_multiset.h, include/bits/stl_set.h:
Remove emacs markers.
* include/bits/stl_threads.h (_STL_auto_lock): Add __unused__.
From-SVN: r67736
2003-06-10 23:52:25 +02:00
|
|
|
template<class _InIterator>
|
2000-10-05 13:27:02 +02:00
|
|
|
static _CharT*
|
BUGS: Update from 2.90.8 snapshot.
2003-06-10 Phil Edwards <pme@gcc.gnu.org>
* docs/html/17_intro/BUGS: Update from 2.90.8 snapshot.
* docs/html/17_intro/CHECKLIST: Bring up to date with respect to
correctness of container::iterator typedefs. Fix whitespace.
* docs/html/20_util/howto.html, docs/html/ext/howto.html: Add links
to allocator docs.
* docs/html/documentation.html: Regenerate.
* include/bits/basic_string.h, include/bits/basic_string.tcc,
include/bits/deque.tcc, include/bits/list.tcc, include/bits/stl_algo.h,
include/bits/stl_algobase.h, include/bits/stl_bvector.h,
include/bits/stl_deque.h, include/bits/stl_iterator_base_funcs.h,
include/bits/stl_list.h, include/bits/stl_uninitialized.h,
include/bits/stl_vector.h, include/bits/vector.tcc,
include/ext/algorithm, include/ext/slist, include/std/std_bitset.h:
Change _Iter names to _Iterator, and __pos to __position.
* include/bits/stl_relops.h, include/bits/stl_numeric.h,
include/bits/stl_multiset.h, include/bits/stl_set.h:
Remove emacs markers.
* include/bits/stl_threads.h (_STL_auto_lock): Add __unused__.
From-SVN: r67736
2003-06-10 23:52:25 +02:00
|
|
|
_S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a)
|
2000-10-05 13:27:02 +02:00
|
|
|
{
|
cpp_type_traits.h: Add types to the structs thus making type_traits.h redundant...
2005-01-31 Paolo Carlini <pcarlini@suse.de>
Gabriel Dos Reis <gdr@integrable-solutions.net>
* include/bits/cpp_type_traits.h: Add types to the structs thus
making type_traits.h redundant; exploit new __truth_type and
__traitor helpers.
* include/bits/type_traits.h: Remove.
* include/Makefile.am: Update.
* include/Makefile.in: Regenerate.
* include/backward/tempbuf.h: Include cpp_type_traits.h instead.
* include/bits/basic_string.h (replace(iterator, iterator,
_InputIterator, _InputIterator), _S_construct(_InIterator,
_InIterator, const _Alloc&)): Use __is_integer instead.
* include/bits/stl_bvector.h (vector(_InputIterator,
_InputIterator, const allocator_type&), assign(_InputIterator,
_InputIterator), insert(iterator, _InputIterator, _InputIterator)):
Likewise.
* include/bits/stl_construct.h (_Destroy(_ForwardIterator,
_ForwardIterator)): Use __is_scalar.
* include/bits/stl_deque.h (deque(_InputIterator, _InputIterator,
const allocator_type&), assign(_InputIterator, _InputIterator),
insert(iterator, _InputIterator, _InputIterator)): Use __is_integer.
* include/bits/stl_list.h (assign(_InputIterator, _InputIterator),
insert(iterator, _InputIterator, _InputIterator)): Likewise.
* include/bits/stl_tempbuf.h (_Temporary_buffer(_ForwardIterator,
_ForwardIterator)): Use __is_scalar.
* include/bits/stl_uninitialized.h (uninitialized_copy(_InputIterator,
_InputIterator, _ForwardIterator), uninitialized_fill(_ForwardIterator,
_ForwardIterator, const _Tp&), uninitialized_fill_n(_ForwardIterator,
_Size, const _Tp&)): Likewise.
* include/bits/stl_vector.h (vector(_InputIterator, _InputIterator,
const allocator_type&), assign(_InputIterator, _InputIterator),
insert(iterator, _InputIterator, _InputIterator)): Use __is_integer.
* include/debug/debug.h (__valid_range(const _InputIterator&,
const _InputIterator&)): Use __is_integer.
* include/ext/slist (assign(_InputIterator, _InputIterator)): Likewise.
* include/std/std_string.h: Include cpp_type_traits.h instead.
Co-Authored-By: Gabriel Dos Reis <gdr@integrable-solutions.net>
From-SVN: r94484
2005-01-31 17:22:01 +01:00
|
|
|
typedef typename std::__is_integer<_InIterator>::__type _Integral;
|
2000-10-05 13:27:02 +02:00
|
|
|
return _S_construct_aux(__beg, __end, __a, _Integral());
|
|
|
|
}
|
|
|
|
|
|
|
|
// For Input Iterators, used in istreambuf_iterators, etc.
|
BUGS: Update from 2.90.8 snapshot.
2003-06-10 Phil Edwards <pme@gcc.gnu.org>
* docs/html/17_intro/BUGS: Update from 2.90.8 snapshot.
* docs/html/17_intro/CHECKLIST: Bring up to date with respect to
correctness of container::iterator typedefs. Fix whitespace.
* docs/html/20_util/howto.html, docs/html/ext/howto.html: Add links
to allocator docs.
* docs/html/documentation.html: Regenerate.
* include/bits/basic_string.h, include/bits/basic_string.tcc,
include/bits/deque.tcc, include/bits/list.tcc, include/bits/stl_algo.h,
include/bits/stl_algobase.h, include/bits/stl_bvector.h,
include/bits/stl_deque.h, include/bits/stl_iterator_base_funcs.h,
include/bits/stl_list.h, include/bits/stl_uninitialized.h,
include/bits/stl_vector.h, include/bits/vector.tcc,
include/ext/algorithm, include/ext/slist, include/std/std_bitset.h:
Change _Iter names to _Iterator, and __pos to __position.
* include/bits/stl_relops.h, include/bits/stl_numeric.h,
include/bits/stl_multiset.h, include/bits/stl_set.h:
Remove emacs markers.
* include/bits/stl_threads.h (_STL_auto_lock): Add __unused__.
From-SVN: r67736
2003-06-10 23:52:25 +02:00
|
|
|
template<class _InIterator>
|
2000-10-05 13:27:02 +02:00
|
|
|
static _CharT*
|
BUGS: Update from 2.90.8 snapshot.
2003-06-10 Phil Edwards <pme@gcc.gnu.org>
* docs/html/17_intro/BUGS: Update from 2.90.8 snapshot.
* docs/html/17_intro/CHECKLIST: Bring up to date with respect to
correctness of container::iterator typedefs. Fix whitespace.
* docs/html/20_util/howto.html, docs/html/ext/howto.html: Add links
to allocator docs.
* docs/html/documentation.html: Regenerate.
* include/bits/basic_string.h, include/bits/basic_string.tcc,
include/bits/deque.tcc, include/bits/list.tcc, include/bits/stl_algo.h,
include/bits/stl_algobase.h, include/bits/stl_bvector.h,
include/bits/stl_deque.h, include/bits/stl_iterator_base_funcs.h,
include/bits/stl_list.h, include/bits/stl_uninitialized.h,
include/bits/stl_vector.h, include/bits/vector.tcc,
include/ext/algorithm, include/ext/slist, include/std/std_bitset.h:
Change _Iter names to _Iterator, and __pos to __position.
* include/bits/stl_relops.h, include/bits/stl_numeric.h,
include/bits/stl_multiset.h, include/bits/stl_set.h:
Remove emacs markers.
* include/bits/stl_threads.h (_STL_auto_lock): Add __unused__.
From-SVN: r67736
2003-06-10 23:52:25 +02:00
|
|
|
_S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
|
2000-10-05 13:27:02 +02:00
|
|
|
input_iterator_tag);
|
2002-09-01 02:33:53 +02:00
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
// For forward_iterators up to random_access_iterators, used for
|
|
|
|
// string::iterator, _CharT*, etc.
|
BUGS: Update from 2.90.8 snapshot.
2003-06-10 Phil Edwards <pme@gcc.gnu.org>
* docs/html/17_intro/BUGS: Update from 2.90.8 snapshot.
* docs/html/17_intro/CHECKLIST: Bring up to date with respect to
correctness of container::iterator typedefs. Fix whitespace.
* docs/html/20_util/howto.html, docs/html/ext/howto.html: Add links
to allocator docs.
* docs/html/documentation.html: Regenerate.
* include/bits/basic_string.h, include/bits/basic_string.tcc,
include/bits/deque.tcc, include/bits/list.tcc, include/bits/stl_algo.h,
include/bits/stl_algobase.h, include/bits/stl_bvector.h,
include/bits/stl_deque.h, include/bits/stl_iterator_base_funcs.h,
include/bits/stl_list.h, include/bits/stl_uninitialized.h,
include/bits/stl_vector.h, include/bits/vector.tcc,
include/ext/algorithm, include/ext/slist, include/std/std_bitset.h:
Change _Iter names to _Iterator, and __pos to __position.
* include/bits/stl_relops.h, include/bits/stl_numeric.h,
include/bits/stl_multiset.h, include/bits/stl_set.h:
Remove emacs markers.
* include/bits/stl_threads.h (_STL_auto_lock): Add __unused__.
From-SVN: r67736
2003-06-10 23:52:25 +02:00
|
|
|
template<class _FwdIterator>
|
2000-10-05 13:27:02 +02:00
|
|
|
static _CharT*
|
BUGS: Update from 2.90.8 snapshot.
2003-06-10 Phil Edwards <pme@gcc.gnu.org>
* docs/html/17_intro/BUGS: Update from 2.90.8 snapshot.
* docs/html/17_intro/CHECKLIST: Bring up to date with respect to
correctness of container::iterator typedefs. Fix whitespace.
* docs/html/20_util/howto.html, docs/html/ext/howto.html: Add links
to allocator docs.
* docs/html/documentation.html: Regenerate.
* include/bits/basic_string.h, include/bits/basic_string.tcc,
include/bits/deque.tcc, include/bits/list.tcc, include/bits/stl_algo.h,
include/bits/stl_algobase.h, include/bits/stl_bvector.h,
include/bits/stl_deque.h, include/bits/stl_iterator_base_funcs.h,
include/bits/stl_list.h, include/bits/stl_uninitialized.h,
include/bits/stl_vector.h, include/bits/vector.tcc,
include/ext/algorithm, include/ext/slist, include/std/std_bitset.h:
Change _Iter names to _Iterator, and __pos to __position.
* include/bits/stl_relops.h, include/bits/stl_numeric.h,
include/bits/stl_multiset.h, include/bits/stl_set.h:
Remove emacs markers.
* include/bits/stl_threads.h (_STL_auto_lock): Add __unused__.
From-SVN: r67736
2003-06-10 23:52:25 +02:00
|
|
|
_S_construct(_FwdIterator __beg, _FwdIterator __end, const _Alloc& __a,
|
2000-10-05 13:27:02 +02:00
|
|
|
forward_iterator_tag);
|
|
|
|
|
2002-09-01 02:33:53 +02:00
|
|
|
static _CharT*
|
2000-10-05 13:27:02 +02:00
|
|
|
_S_construct(size_type __req, _CharT __c, const _Alloc& __a);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Copy substring into C string.
|
|
|
|
* @param s C string to copy value into.
|
|
|
|
* @param n Number of characters to copy.
|
|
|
|
* @param pos Index of first character to copy.
|
|
|
|
* @return Number of characters actually copied
|
|
|
|
* @throw std::out_of_range If pos > size().
|
|
|
|
*
|
|
|
|
* Copies up to @a n characters starting at @a pos into the C string @a
|
|
|
|
* s. If @a pos is greater than size(), out_of_range is thrown.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
copy(_CharT* __s, size_type __n, size_type __pos = 0) const;
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Swap contents with another string.
|
|
|
|
* @param s String to swap with.
|
|
|
|
*
|
|
|
|
* Exchanges the contents of this string with that of @a s in constant
|
|
|
|
* time.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
void
|
2003-05-02 17:50:53 +02:00
|
|
|
swap(basic_string& __s);
|
2000-10-05 13:27:02 +02:00
|
|
|
|
|
|
|
// String operations:
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Return const pointer to null-terminated contents.
|
|
|
|
*
|
|
|
|
* This is a handle to internal data. Do not modify or dire things may
|
|
|
|
* happen.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
const _CharT*
|
2004-10-18 10:43:17 +02:00
|
|
|
c_str() const
|
|
|
|
{ return _M_data(); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Return const pointer to contents.
|
|
|
|
*
|
2004-01-31 18:50:46 +01:00
|
|
|
* This is a handle to internal data. Do not modify or dire things may
|
|
|
|
* happen.
|
2003-07-15 09:02:40 +02:00
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
const _CharT*
|
2004-10-18 10:43:17 +02:00
|
|
|
data() const
|
|
|
|
{ return _M_data(); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Return copy of allocator used to construct this string.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
allocator_type
|
2004-10-18 10:43:17 +02:00
|
|
|
get_allocator() const
|
|
|
|
{ return _M_dataplus; }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Find position of a C substring.
|
|
|
|
* @param s C string to locate.
|
|
|
|
* @param pos Index of character to search from.
|
|
|
|
* @param n Number of characters from @a s to search for.
|
|
|
|
* @return Index of start of first occurrence.
|
|
|
|
*
|
|
|
|
* Starting from @a pos, searches forward for the first @a n characters
|
|
|
|
* in @a s within this string. If found, returns the index where it
|
|
|
|
* begins. If not found, returns npos.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
find(const _CharT* __s, size_type __pos, size_type __n) const;
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Find position of a string.
|
|
|
|
* @param str String to locate.
|
|
|
|
* @param pos Index of character to search from (default 0).
|
|
|
|
* @return Index of start of first occurrence.
|
|
|
|
*
|
|
|
|
* Starting from @a pos, searches forward for value of @a str within
|
|
|
|
* this string. If found, returns the index where it begins. If not
|
|
|
|
* found, returns npos.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
find(const basic_string& __str, size_type __pos = 0) const
|
|
|
|
{ return this->find(__str.data(), __pos, __str.size()); }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Find position of a C string.
|
|
|
|
* @param s C string to locate.
|
|
|
|
* @param pos Index of character to search from (default 0).
|
|
|
|
* @return Index of start of first occurrence.
|
|
|
|
*
|
|
|
|
* Starting from @a pos, searches forward for the value of @a s within
|
|
|
|
* this string. If found, returns the index where it begins. If not
|
|
|
|
* found, returns npos.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
find(const _CharT* __s, size_type __pos = 0) const
|
2004-02-08 05:46:42 +01:00
|
|
|
{
|
2003-11-11 21:09:16 +01:00
|
|
|
__glibcxx_requires_string(__s);
|
2004-02-08 05:46:42 +01:00
|
|
|
return this->find(__s, __pos, traits_type::length(__s));
|
2003-11-11 21:09:16 +01:00
|
|
|
}
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Find position of a character.
|
|
|
|
* @param c Character to locate.
|
|
|
|
* @param pos Index of character to search from (default 0).
|
|
|
|
* @return Index of first occurrence.
|
|
|
|
*
|
|
|
|
* Starting from @a pos, searches forward for @a c within this string.
|
|
|
|
* If found, returns the index where it was found. If not found,
|
|
|
|
* returns npos.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
find(_CharT __c, size_type __pos = 0) const;
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Find last position of a string.
|
|
|
|
* @param str String to locate.
|
|
|
|
* @param pos Index of character to search back from (default end).
|
|
|
|
* @return Index of start of last occurrence.
|
|
|
|
*
|
|
|
|
* Starting from @a pos, searches backward for value of @a str within
|
|
|
|
* this string. If found, returns the index where it begins. If not
|
|
|
|
* found, returns npos.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
rfind(const basic_string& __str, size_type __pos = npos) const
|
|
|
|
{ return this->rfind(__str.data(), __pos, __str.size()); }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Find last position of a C substring.
|
|
|
|
* @param s C string to locate.
|
|
|
|
* @param pos Index of character to search back from.
|
|
|
|
* @param n Number of characters from s to search for.
|
|
|
|
* @return Index of start of last occurrence.
|
|
|
|
*
|
|
|
|
* Starting from @a pos, searches backward for the first @a n
|
|
|
|
* characters in @a s within this string. If found, returns the index
|
|
|
|
* where it begins. If not found, returns npos.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
rfind(const _CharT* __s, size_type __pos, size_type __n) const;
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Find last position of a C string.
|
|
|
|
* @param s C string to locate.
|
2006-10-06 13:47:56 +02:00
|
|
|
* @param pos Index of character to start search at (default end).
|
2003-07-15 09:02:40 +02:00
|
|
|
* @return Index of start of last occurrence.
|
|
|
|
*
|
|
|
|
* Starting from @a pos, searches backward for the value of @a s within
|
|
|
|
* this string. If found, returns the index where it begins. If not
|
|
|
|
* found, returns npos.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
rfind(const _CharT* __s, size_type __pos = npos) const
|
2004-02-08 05:46:42 +01:00
|
|
|
{
|
2003-11-11 21:09:16 +01:00
|
|
|
__glibcxx_requires_string(__s);
|
2004-02-08 05:46:42 +01:00
|
|
|
return this->rfind(__s, __pos, traits_type::length(__s));
|
2003-11-11 21:09:16 +01:00
|
|
|
}
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Find last position of a character.
|
|
|
|
* @param c Character to locate.
|
2006-10-06 13:47:56 +02:00
|
|
|
* @param pos Index of character to search back from (default end).
|
2003-07-15 09:02:40 +02:00
|
|
|
* @return Index of last occurrence.
|
|
|
|
*
|
|
|
|
* Starting from @a pos, searches backward for @a c within this string.
|
|
|
|
* If found, returns the index where it was found. If not found,
|
|
|
|
* returns npos.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
rfind(_CharT __c, size_type __pos = npos) const;
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Find position of a character of string.
|
|
|
|
* @param str String containing characters to locate.
|
|
|
|
* @param pos Index of character to search from (default 0).
|
|
|
|
* @return Index of first occurrence.
|
|
|
|
*
|
|
|
|
* Starting from @a pos, searches forward for one of the characters of
|
|
|
|
* @a str within this string. If found, returns the index where it was
|
|
|
|
* found. If not found, returns npos.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
find_first_of(const basic_string& __str, size_type __pos = 0) const
|
|
|
|
{ return this->find_first_of(__str.data(), __pos, __str.size()); }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Find position of a character of C substring.
|
|
|
|
* @param s String containing characters to locate.
|
2007-10-01 22:49:39 +02:00
|
|
|
* @param pos Index of character to search from.
|
2003-07-15 09:02:40 +02:00
|
|
|
* @param n Number of characters from s to search for.
|
|
|
|
* @return Index of first occurrence.
|
|
|
|
*
|
|
|
|
* Starting from @a pos, searches forward for one of the first @a n
|
|
|
|
* characters of @a s within this string. If found, returns the index
|
|
|
|
* where it was found. If not found, returns npos.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
find_first_of(const _CharT* __s, size_type __pos, size_type __n) const;
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Find position of a character of C string.
|
|
|
|
* @param s String containing characters to locate.
|
|
|
|
* @param pos Index of character to search from (default 0).
|
|
|
|
* @return Index of first occurrence.
|
|
|
|
*
|
|
|
|
* Starting from @a pos, searches forward for one of the characters of
|
|
|
|
* @a s within this string. If found, returns the index where it was
|
|
|
|
* found. If not found, returns npos.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
find_first_of(const _CharT* __s, size_type __pos = 0) const
|
2004-02-08 05:46:42 +01:00
|
|
|
{
|
2003-11-11 21:09:16 +01:00
|
|
|
__glibcxx_requires_string(__s);
|
2004-02-08 05:46:42 +01:00
|
|
|
return this->find_first_of(__s, __pos, traits_type::length(__s));
|
2003-11-11 21:09:16 +01:00
|
|
|
}
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Find position of a character.
|
|
|
|
* @param c Character to locate.
|
|
|
|
* @param pos Index of character to search from (default 0).
|
|
|
|
* @return Index of first occurrence.
|
|
|
|
*
|
|
|
|
* Starting from @a pos, searches forward for the character @a c within
|
|
|
|
* this string. If found, returns the index where it was found. If
|
|
|
|
* not found, returns npos.
|
|
|
|
*
|
|
|
|
* Note: equivalent to find(c, pos).
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
find_first_of(_CharT __c, size_type __pos = 0) const
|
|
|
|
{ return this->find(__c, __pos); }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Find last position of a character of string.
|
|
|
|
* @param str String containing characters to locate.
|
|
|
|
* @param pos Index of character to search back from (default end).
|
|
|
|
* @return Index of last occurrence.
|
|
|
|
*
|
|
|
|
* Starting from @a pos, searches backward for one of the characters of
|
|
|
|
* @a str within this string. If found, returns the index where it was
|
|
|
|
* found. If not found, returns npos.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
find_last_of(const basic_string& __str, size_type __pos = npos) const
|
|
|
|
{ return this->find_last_of(__str.data(), __pos, __str.size()); }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Find last position of a character of C substring.
|
|
|
|
* @param s C string containing characters to locate.
|
2007-10-01 22:49:39 +02:00
|
|
|
* @param pos Index of character to search back from.
|
2003-07-15 09:02:40 +02:00
|
|
|
* @param n Number of characters from s to search for.
|
|
|
|
* @return Index of last occurrence.
|
|
|
|
*
|
|
|
|
* Starting from @a pos, searches backward for one of the first @a n
|
|
|
|
* characters of @a s within this string. If found, returns the index
|
|
|
|
* where it was found. If not found, returns npos.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
find_last_of(const _CharT* __s, size_type __pos, size_type __n) const;
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Find last position of a character of C string.
|
|
|
|
* @param s C string containing characters to locate.
|
|
|
|
* @param pos Index of character to search back from (default end).
|
|
|
|
* @return Index of last occurrence.
|
|
|
|
*
|
|
|
|
* Starting from @a pos, searches backward for one of the characters of
|
|
|
|
* @a s within this string. If found, returns the index where it was
|
|
|
|
* found. If not found, returns npos.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
find_last_of(const _CharT* __s, size_type __pos = npos) const
|
2004-02-08 05:46:42 +01:00
|
|
|
{
|
2003-11-11 21:09:16 +01:00
|
|
|
__glibcxx_requires_string(__s);
|
2004-02-08 05:46:42 +01:00
|
|
|
return this->find_last_of(__s, __pos, traits_type::length(__s));
|
2003-11-11 21:09:16 +01:00
|
|
|
}
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Find last position of a character.
|
|
|
|
* @param c Character to locate.
|
2007-10-01 22:49:39 +02:00
|
|
|
* @param pos Index of character to search back from (default end).
|
2003-07-15 09:02:40 +02:00
|
|
|
* @return Index of last occurrence.
|
|
|
|
*
|
|
|
|
* Starting from @a pos, searches backward for @a c within this string.
|
|
|
|
* If found, returns the index where it was found. If not found,
|
|
|
|
* returns npos.
|
|
|
|
*
|
|
|
|
* Note: equivalent to rfind(c, pos).
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
find_last_of(_CharT __c, size_type __pos = npos) const
|
|
|
|
{ return this->rfind(__c, __pos); }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Find position of a character not in string.
|
|
|
|
* @param str String containing characters to avoid.
|
|
|
|
* @param pos Index of character to search from (default 0).
|
|
|
|
* @return Index of first occurrence.
|
|
|
|
*
|
|
|
|
* Starting from @a pos, searches forward for a character not contained
|
|
|
|
* in @a str within this string. If found, returns the index where it
|
|
|
|
* was found. If not found, returns npos.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
find_first_not_of(const basic_string& __str, size_type __pos = 0) const
|
|
|
|
{ return this->find_first_not_of(__str.data(), __pos, __str.size()); }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Find position of a character not in C substring.
|
|
|
|
* @param s C string containing characters to avoid.
|
2007-10-01 22:49:39 +02:00
|
|
|
* @param pos Index of character to search from.
|
2003-07-15 09:02:40 +02:00
|
|
|
* @param n Number of characters from s to consider.
|
|
|
|
* @return Index of first occurrence.
|
|
|
|
*
|
|
|
|
* Starting from @a pos, searches forward for a character not contained
|
|
|
|
* in the first @a n characters of @a s within this string. If found,
|
|
|
|
* returns the index where it was found. If not found, returns npos.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
|
|
|
find_first_not_of(const _CharT* __s, size_type __pos,
|
2000-10-05 13:27:02 +02:00
|
|
|
size_type __n) const;
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Find position of a character not in C string.
|
|
|
|
* @param s C string containing characters to avoid.
|
|
|
|
* @param pos Index of character to search from (default 0).
|
|
|
|
* @return Index of first occurrence.
|
|
|
|
*
|
|
|
|
* Starting from @a pos, searches forward for a character not contained
|
|
|
|
* in @a s within this string. If found, returns the index where it
|
|
|
|
* was found. If not found, returns npos.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
find_first_not_of(const _CharT* __s, size_type __pos = 0) const
|
2004-02-08 05:46:42 +01:00
|
|
|
{
|
2003-11-11 21:09:16 +01:00
|
|
|
__glibcxx_requires_string(__s);
|
2004-02-08 05:46:42 +01:00
|
|
|
return this->find_first_not_of(__s, __pos, traits_type::length(__s));
|
2003-11-11 21:09:16 +01:00
|
|
|
}
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Find position of a different character.
|
|
|
|
* @param c Character to avoid.
|
|
|
|
* @param pos Index of character to search from (default 0).
|
|
|
|
* @return Index of first occurrence.
|
|
|
|
*
|
|
|
|
* Starting from @a pos, searches forward for a character other than @a c
|
|
|
|
* within this string. If found, returns the index where it was found.
|
|
|
|
* If not found, returns npos.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
find_first_not_of(_CharT __c, size_type __pos = 0) const;
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Find last position of a character not in string.
|
|
|
|
* @param str String containing characters to avoid.
|
2007-10-01 22:49:39 +02:00
|
|
|
* @param pos Index of character to search back from (default end).
|
|
|
|
* @return Index of last occurrence.
|
2003-07-15 09:02:40 +02:00
|
|
|
*
|
|
|
|
* Starting from @a pos, searches backward for a character not
|
|
|
|
* contained in @a str within this string. If found, returns the index
|
|
|
|
* where it was found. If not found, returns npos.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
find_last_not_of(const basic_string& __str, size_type __pos = npos) const
|
|
|
|
{ return this->find_last_not_of(__str.data(), __pos, __str.size()); }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Find last position of a character not in C substring.
|
|
|
|
* @param s C string containing characters to avoid.
|
2007-10-01 22:49:39 +02:00
|
|
|
* @param pos Index of character to search back from.
|
2003-07-15 09:02:40 +02:00
|
|
|
* @param n Number of characters from s to consider.
|
2007-10-01 22:49:39 +02:00
|
|
|
* @return Index of last occurrence.
|
2003-07-15 09:02:40 +02:00
|
|
|
*
|
|
|
|
* Starting from @a pos, searches backward for a character not
|
|
|
|
* contained in the first @a n characters of @a s within this string.
|
|
|
|
* If found, returns the index where it was found. If not found,
|
|
|
|
* returns npos.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
|
|
|
find_last_not_of(const _CharT* __s, size_type __pos,
|
2000-10-05 13:27:02 +02:00
|
|
|
size_type __n) const;
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
2007-10-01 22:49:39 +02:00
|
|
|
* @brief Find last position of a character not in C string.
|
2003-07-15 09:02:40 +02:00
|
|
|
* @param s C string containing characters to avoid.
|
2007-10-01 22:49:39 +02:00
|
|
|
* @param pos Index of character to search back from (default end).
|
|
|
|
* @return Index of last occurrence.
|
2003-07-15 09:02:40 +02:00
|
|
|
*
|
|
|
|
* Starting from @a pos, searches backward for a character not
|
|
|
|
* contained in @a s within this string. If found, returns the index
|
|
|
|
* where it was found. If not found, returns npos.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
find_last_not_of(const _CharT* __s, size_type __pos = npos) const
|
2004-02-08 05:46:42 +01:00
|
|
|
{
|
2003-11-11 21:09:16 +01:00
|
|
|
__glibcxx_requires_string(__s);
|
2004-02-08 05:46:42 +01:00
|
|
|
return this->find_last_not_of(__s, __pos, traits_type::length(__s));
|
2003-11-11 21:09:16 +01:00
|
|
|
}
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Find last position of a different character.
|
|
|
|
* @param c Character to avoid.
|
2007-10-01 22:49:39 +02:00
|
|
|
* @param pos Index of character to search back from (default end).
|
|
|
|
* @return Index of last occurrence.
|
2003-07-15 09:02:40 +02:00
|
|
|
*
|
|
|
|
* Starting from @a pos, searches backward for a character other than
|
|
|
|
* @a c within this string. If found, returns the index where it was
|
|
|
|
* found. If not found, returns npos.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
size_type
|
2000-10-05 13:27:02 +02:00
|
|
|
find_last_not_of(_CharT __c, size_type __pos = npos) const;
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Get a substring.
|
|
|
|
* @param pos Index of first character (default 0).
|
|
|
|
* @param n Number of characters in substring (default remainder).
|
|
|
|
* @return The new string.
|
|
|
|
* @throw std::out_of_range If pos > size().
|
|
|
|
*
|
|
|
|
* Construct and return a new string using the @a n characters starting
|
|
|
|
* at @a pos. If the string is too short, use the remainder of the
|
|
|
|
* characters. If @a pos is beyond the end of the string, out_of_range
|
|
|
|
* is thrown.
|
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
basic_string
|
2000-10-05 13:27:02 +02:00
|
|
|
substr(size_type __pos = 0, size_type __n = npos) const
|
basic_string.h (_M_replace_aux): Use the __N marker in throw message.
2004-01-26 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_M_replace_aux): Use the
__N marker in throw message.
* include/bits/basic_string.tcc (assign(const _CharT*,
size_type), insert(size_type, const _CharT*, size_type),
replace(size_type, size_type, const _CharT*, size_type),
reserve, _Rep::_S_create, resize, _M_replace_dispatch):
Likewise.
* include/bits/basic_string.h, include/bits/basic_string.tcc:
Fold overlong lines, minor formatting changes.
From-SVN: r76664
2004-01-26 21:23:20 +01:00
|
|
|
{ return basic_string(*this,
|
|
|
|
_M_check(__pos, "basic_string::substr"), __n); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Compare to a string.
|
|
|
|
* @param str String to compare against.
|
|
|
|
* @return Integer < 0, 0, or > 0.
|
|
|
|
*
|
|
|
|
* Returns an integer < 0 if this string is ordered before @a str, 0 if
|
|
|
|
* their values are equivalent, or > 0 if this string is ordered after
|
2005-04-25 12:59:21 +02:00
|
|
|
* @a str. Determines the effective length rlen of the strings to
|
|
|
|
* compare as the smallest of size() and str.size(). The function
|
|
|
|
* then compares the two strings by calling traits::compare(data(),
|
|
|
|
* str.data(),rlen). If the result of the comparison is nonzero returns
|
|
|
|
* it, otherwise the shorter one is ordered first.
|
2003-07-15 09:02:40 +02:00
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
int
|
2000-10-05 13:27:02 +02:00
|
|
|
compare(const basic_string& __str) const
|
|
|
|
{
|
basic_string.h (_M_fold, [...]): Constify various variables.
2003-06-04 Paolo Carlini <pcarlini@unitus.it>
* include/bits/basic_string.h (_M_fold, insert(iterator, _CharT),
erase(iterator), erase(iterator, iterator), c_str,
compare(const basic_string&)): Constify various variables.
* include/bits/basic_string.tcc (_S_construct(_InIter, _InIter,
const _Alloc&, input_iterator_tag), _M_destroy, _M_mutate,
_S_create, resize, _M_replace, _M_replace_safe,
append(const basic_string&), append(const basic_string&, size_type,
size_type), append(const _CharT*, size_type), append(size_type,
_CharT), operator+(const _CharT*, const basic_string&),
operator+(_CharT, const basic_string&), replace(iterator, iterator,
size_type, _CharT), find(const _CharT*, size_type, size_type),
find(_CharT, size_type), rfind(const _CharT*, size_type, size_type),
rfind(_CharT, size_type), compare(size_type, size_type,
const basic_string&), compare(size_type, size_type,
const basic_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
From-SVN: r67468
2003-06-05 00:53:05 +02:00
|
|
|
const size_type __size = this->size();
|
|
|
|
const size_type __osize = __str.size();
|
|
|
|
const size_type __len = std::min(__size, __osize);
|
2002-09-01 02:33:53 +02:00
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
int __r = traits_type::compare(_M_data(), __str.data(), __len);
|
|
|
|
if (!__r)
|
basic_string.h (basic_string<>::_S_compare): Add.
2007-01-18 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (basic_string<>::_S_compare): Add.
(compare(const basic_string&)): Use it.
* include/bits/basic_string.tcc (compare(size_type, size_type,
const basic_string&), compare(size_type, size_type,
const basic_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
* include/ext/vstring_util.h (__vstring_utility<>::_S_compare): Add.
* include/ext/vstring.h (compare(const __versa_string&)): Use it.
* include/ext/vstring.tcc (compare(size_type, size_type,
const __versa_string&), compare(size_type, size_type,
const __versa_string&, size_type, size_type), compare(const _CharT*),
compare(size_type, size_type, const _CharT*), compare(size_type,
size_type, const _CharT*, size_type)): Likewise.
From-SVN: r120896
2007-01-18 13:03:35 +01:00
|
|
|
__r = _S_compare(__size, __osize);
|
2000-10-05 13:27:02 +02:00
|
|
|
return __r;
|
|
|
|
}
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Compare substring to a string.
|
|
|
|
* @param pos Index of first character of substring.
|
|
|
|
* @param n Number of characters in substring.
|
|
|
|
* @param str String to compare against.
|
|
|
|
* @return Integer < 0, 0, or > 0.
|
|
|
|
*
|
|
|
|
* Form the substring of this string from the @a n characters starting
|
|
|
|
* at @a pos. Returns an integer < 0 if the substring is ordered
|
|
|
|
* before @a str, 0 if their values are equivalent, or > 0 if the
|
2005-04-25 12:59:21 +02:00
|
|
|
* substring is ordered after @a str. Determines the effective length
|
|
|
|
* rlen of the strings to compare as the smallest of the length of the
|
|
|
|
* substring and @a str.size(). The function then compares the two
|
|
|
|
* strings by calling traits::compare(substring.data(),str.data(),rlen).
|
|
|
|
* If the result of the comparison is nonzero returns it, otherwise the
|
|
|
|
* shorter one is ordered first.
|
2003-07-15 09:02:40 +02:00
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
int
|
2000-10-05 13:27:02 +02:00
|
|
|
compare(size_type __pos, size_type __n, const basic_string& __str) const;
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Compare substring to a substring.
|
|
|
|
* @param pos1 Index of first character of substring.
|
|
|
|
* @param n1 Number of characters in substring.
|
|
|
|
* @param str String to compare against.
|
|
|
|
* @param pos2 Index of first character of substring of str.
|
|
|
|
* @param n2 Number of characters in substring of str.
|
|
|
|
* @return Integer < 0, 0, or > 0.
|
|
|
|
*
|
|
|
|
* Form the substring of this string from the @a n1 characters starting
|
|
|
|
* at @a pos1. Form the substring of @a str from the @a n2 characters
|
|
|
|
* starting at @a pos2. Returns an integer < 0 if this substring is
|
|
|
|
* ordered before the substring of @a str, 0 if their values are
|
|
|
|
* equivalent, or > 0 if this substring is ordered after the substring
|
2005-04-25 12:59:21 +02:00
|
|
|
* of @a str. Determines the effective length rlen of the strings
|
|
|
|
* to compare as the smallest of the lengths of the substrings. The
|
|
|
|
* function then compares the two strings by calling
|
|
|
|
* traits::compare(substring.data(),str.substr(pos2,n2).data(),rlen).
|
|
|
|
* If the result of the comparison is nonzero returns it, otherwise the
|
|
|
|
* shorter one is ordered first.
|
2003-07-15 09:02:40 +02:00
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
int
|
2000-10-05 13:27:02 +02:00
|
|
|
compare(size_type __pos1, size_type __n1, const basic_string& __str,
|
|
|
|
size_type __pos2, size_type __n2) const;
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Compare to a C string.
|
|
|
|
* @param s C string to compare against.
|
|
|
|
* @return Integer < 0, 0, or > 0.
|
|
|
|
*
|
|
|
|
* Returns an integer < 0 if this string is ordered before @a s, 0 if
|
|
|
|
* their values are equivalent, or > 0 if this string is ordered after
|
2005-04-25 12:59:21 +02:00
|
|
|
* @a s. Determines the effective length rlen of the strings to
|
|
|
|
* compare as the smallest of size() and the length of a string
|
|
|
|
* constructed from @a s. The function then compares the two strings
|
|
|
|
* by calling traits::compare(data(),s,rlen). If the result of the
|
|
|
|
* comparison is nonzero returns it, otherwise the shorter one is
|
|
|
|
* ordered first.
|
2003-07-15 09:02:40 +02:00
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
int
|
2000-10-05 13:27:02 +02:00
|
|
|
compare(const _CharT* __s) const;
|
|
|
|
|
2003-07-05 06:05:45 +02:00
|
|
|
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
2003-06-06 19:19:56 +02:00
|
|
|
// 5 String::compare specification questionable
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Compare substring to a C string.
|
|
|
|
* @param pos Index of first character of substring.
|
|
|
|
* @param n1 Number of characters in substring.
|
|
|
|
* @param s C string to compare against.
|
|
|
|
* @return Integer < 0, 0, or > 0.
|
|
|
|
*
|
|
|
|
* Form the substring of this string from the @a n1 characters starting
|
|
|
|
* at @a pos. Returns an integer < 0 if the substring is ordered
|
|
|
|
* before @a s, 0 if their values are equivalent, or > 0 if the
|
2005-04-25 12:59:21 +02:00
|
|
|
* substring is ordered after @a s. Determines the effective length
|
|
|
|
* rlen of the strings to compare as the smallest of the length of the
|
|
|
|
* substring and the length of a string constructed from @a s. The
|
|
|
|
* function then compares the two string by calling
|
|
|
|
* traits::compare(substring.data(),s,rlen). If the result of the
|
|
|
|
* comparison is nonzero returns it, otherwise the shorter one is
|
|
|
|
* ordered first.
|
2003-07-15 09:02:40 +02:00
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
int
|
2001-06-12 04:30:37 +02:00
|
|
|
compare(size_type __pos, size_type __n1, const _CharT* __s) const;
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
2004-01-13 12:12:38 +01:00
|
|
|
* @brief Compare substring against a character array.
|
2003-07-15 09:02:40 +02:00
|
|
|
* @param pos1 Index of first character of substring.
|
|
|
|
* @param n1 Number of characters in substring.
|
2004-01-13 12:12:38 +01:00
|
|
|
* @param s character array to compare against.
|
|
|
|
* @param n2 Number of characters of s.
|
2003-07-15 09:02:40 +02:00
|
|
|
* @return Integer < 0, 0, or > 0.
|
|
|
|
*
|
|
|
|
* Form the substring of this string from the @a n1 characters starting
|
2004-01-13 12:12:38 +01:00
|
|
|
* at @a pos1. Form a string from the first @a n2 characters of @a s.
|
|
|
|
* Returns an integer < 0 if this substring is ordered before the string
|
|
|
|
* from @a s, 0 if their values are equivalent, or > 0 if this substring
|
2005-04-25 12:59:21 +02:00
|
|
|
* is ordered after the string from @a s. Determines the effective
|
|
|
|
* length rlen of the strings to compare as the smallest of the length
|
|
|
|
* of the substring and @a n2. The function then compares the two
|
|
|
|
* strings by calling traits::compare(substring.data(),s,rlen). If the
|
|
|
|
* result of the comparison is nonzero returns it, otherwise the shorter
|
|
|
|
* one is ordered first.
|
2004-01-13 12:12:38 +01:00
|
|
|
*
|
2009-03-11 16:16:21 +01:00
|
|
|
* NB: s must have at least n2 characters, '\\0' has no special
|
2004-01-13 12:12:38 +01:00
|
|
|
* meaning.
|
2003-07-15 09:02:40 +02:00
|
|
|
*/
|
2002-09-01 02:33:53 +02:00
|
|
|
int
|
|
|
|
compare(size_type __pos, size_type __n1, const _CharT* __s,
|
2001-06-12 04:30:37 +02:00
|
|
|
size_type __n2) const;
|
2000-10-05 13:27:02 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// operator+
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Concatenate two strings.
|
|
|
|
* @param lhs First string.
|
|
|
|
* @param rhs Last string.
|
|
|
|
* @return New string with value of @a lhs followed by @a rhs.
|
2004-02-08 05:46:42 +01:00
|
|
|
*/
|
2004-04-19 13:30:20 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
2000-10-05 13:27:02 +02:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>
|
|
|
|
operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
|
|
|
const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
|
|
|
{
|
|
|
|
basic_string<_CharT, _Traits, _Alloc> __str(__lhs);
|
|
|
|
__str.append(__rhs);
|
|
|
|
return __str;
|
|
|
|
}
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Concatenate C string and string.
|
|
|
|
* @param lhs First string.
|
|
|
|
* @param rhs Last string.
|
|
|
|
* @return New string with value of @a lhs followed by @a rhs.
|
2004-02-08 05:46:42 +01:00
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
basic_string<_CharT,_Traits,_Alloc>
|
|
|
|
operator+(const _CharT* __lhs,
|
|
|
|
const basic_string<_CharT,_Traits,_Alloc>& __rhs);
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Concatenate character and string.
|
|
|
|
* @param lhs First string.
|
|
|
|
* @param rhs Last string.
|
|
|
|
* @return New string with @a lhs followed by @a rhs.
|
2004-02-08 05:46:42 +01:00
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
basic_string<_CharT,_Traits,_Alloc>
|
|
|
|
operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs);
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Concatenate string and C string.
|
|
|
|
* @param lhs First string.
|
|
|
|
* @param rhs Last string.
|
|
|
|
* @return New string with @a lhs followed by @a rhs.
|
2004-02-08 05:46:42 +01:00
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
inline basic_string<_CharT, _Traits, _Alloc>
|
|
|
|
operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
|
|
|
const _CharT* __rhs)
|
|
|
|
{
|
|
|
|
basic_string<_CharT, _Traits, _Alloc> __str(__lhs);
|
|
|
|
__str.append(__rhs);
|
|
|
|
return __str;
|
|
|
|
}
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Concatenate string and character.
|
|
|
|
* @param lhs First string.
|
|
|
|
* @param rhs Last string.
|
|
|
|
* @return New string with @a lhs followed by @a rhs.
|
2004-02-08 05:46:42 +01:00
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
inline basic_string<_CharT, _Traits, _Alloc>
|
|
|
|
operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs)
|
|
|
|
{
|
2004-02-08 05:46:42 +01:00
|
|
|
typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
|
2000-10-05 13:27:02 +02:00
|
|
|
typedef typename __string_type::size_type __size_type;
|
|
|
|
__string_type __str(__lhs);
|
|
|
|
__str.append(__size_type(1), __rhs);
|
|
|
|
return __str;
|
|
|
|
}
|
|
|
|
|
|
|
|
// operator ==
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Test equivalence of two strings.
|
|
|
|
* @param lhs First string.
|
|
|
|
* @param rhs Second string.
|
|
|
|
* @return True if @a lhs.compare(@a rhs) == 0. False otherwise.
|
2004-02-08 05:46:42 +01:00
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
inline bool
|
|
|
|
operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
|
|
|
const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
|
|
|
{ return __lhs.compare(__rhs) == 0; }
|
|
|
|
|
2007-07-27 19:25:04 +02:00
|
|
|
template<typename _CharT>
|
|
|
|
inline
|
|
|
|
typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, bool>::__type
|
|
|
|
operator==(const basic_string<_CharT>& __lhs,
|
|
|
|
const basic_string<_CharT>& __rhs)
|
|
|
|
{ return (__lhs.size() == __rhs.size()
|
|
|
|
&& !std::char_traits<_CharT>::compare(__lhs.data(), __rhs.data(),
|
|
|
|
__lhs.size())); }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Test equivalence of C string and string.
|
|
|
|
* @param lhs C string.
|
|
|
|
* @param rhs String.
|
|
|
|
* @return True if @a rhs.compare(@a lhs) == 0. False otherwise.
|
2004-02-08 05:46:42 +01:00
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
inline bool
|
|
|
|
operator==(const _CharT* __lhs,
|
|
|
|
const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
|
|
|
{ return __rhs.compare(__lhs) == 0; }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Test equivalence of string and C string.
|
|
|
|
* @param lhs String.
|
|
|
|
* @param rhs C string.
|
|
|
|
* @return True if @a lhs.compare(@a rhs) == 0. False otherwise.
|
2004-02-08 05:46:42 +01:00
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
inline bool
|
|
|
|
operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
|
|
|
const _CharT* __rhs)
|
|
|
|
{ return __lhs.compare(__rhs) == 0; }
|
|
|
|
|
|
|
|
// operator !=
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Test difference of two strings.
|
|
|
|
* @param lhs First string.
|
|
|
|
* @param rhs Second string.
|
|
|
|
* @return True if @a lhs.compare(@a rhs) != 0. False otherwise.
|
2004-02-08 05:46:42 +01:00
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
inline bool
|
|
|
|
operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
|
|
|
const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
2007-07-27 19:25:04 +02:00
|
|
|
{ return !(__lhs == __rhs); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Test difference of C string and string.
|
|
|
|
* @param lhs C string.
|
|
|
|
* @param rhs String.
|
|
|
|
* @return True if @a rhs.compare(@a lhs) != 0. False otherwise.
|
2004-02-08 05:46:42 +01:00
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
inline bool
|
|
|
|
operator!=(const _CharT* __lhs,
|
|
|
|
const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
2007-07-27 19:25:04 +02:00
|
|
|
{ return !(__lhs == __rhs); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Test difference of string and C string.
|
|
|
|
* @param lhs String.
|
|
|
|
* @param rhs C string.
|
|
|
|
* @return True if @a lhs.compare(@a rhs) != 0. False otherwise.
|
2004-02-08 05:46:42 +01:00
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
inline bool
|
|
|
|
operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
|
|
|
const _CharT* __rhs)
|
2007-07-27 19:25:04 +02:00
|
|
|
{ return !(__lhs == __rhs); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
|
|
|
// operator <
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Test if string precedes string.
|
|
|
|
* @param lhs First string.
|
|
|
|
* @param rhs Second string.
|
|
|
|
* @return True if @a lhs precedes @a rhs. False otherwise.
|
2004-02-08 05:46:42 +01:00
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
inline bool
|
|
|
|
operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
|
|
|
const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
|
|
|
{ return __lhs.compare(__rhs) < 0; }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Test if string precedes C string.
|
|
|
|
* @param lhs String.
|
|
|
|
* @param rhs C string.
|
|
|
|
* @return True if @a lhs precedes @a rhs. False otherwise.
|
2004-02-08 05:46:42 +01:00
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
inline bool
|
|
|
|
operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
|
|
|
const _CharT* __rhs)
|
|
|
|
{ return __lhs.compare(__rhs) < 0; }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Test if C string precedes string.
|
|
|
|
* @param lhs C string.
|
|
|
|
* @param rhs String.
|
|
|
|
* @return True if @a lhs precedes @a rhs. False otherwise.
|
2004-02-08 05:46:42 +01:00
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
inline bool
|
|
|
|
operator<(const _CharT* __lhs,
|
|
|
|
const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
|
|
|
{ return __rhs.compare(__lhs) > 0; }
|
|
|
|
|
|
|
|
// operator >
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Test if string follows string.
|
|
|
|
* @param lhs First string.
|
|
|
|
* @param rhs Second string.
|
|
|
|
* @return True if @a lhs follows @a rhs. False otherwise.
|
2004-02-08 05:46:42 +01:00
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
inline bool
|
|
|
|
operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
|
|
|
const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
|
|
|
{ return __lhs.compare(__rhs) > 0; }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Test if string follows C string.
|
|
|
|
* @param lhs String.
|
|
|
|
* @param rhs C string.
|
|
|
|
* @return True if @a lhs follows @a rhs. False otherwise.
|
2004-02-08 05:46:42 +01:00
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
inline bool
|
|
|
|
operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
|
|
|
const _CharT* __rhs)
|
|
|
|
{ return __lhs.compare(__rhs) > 0; }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Test if C string follows string.
|
|
|
|
* @param lhs C string.
|
|
|
|
* @param rhs String.
|
|
|
|
* @return True if @a lhs follows @a rhs. False otherwise.
|
2004-02-08 05:46:42 +01:00
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
inline bool
|
|
|
|
operator>(const _CharT* __lhs,
|
|
|
|
const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
|
|
|
{ return __rhs.compare(__lhs) < 0; }
|
|
|
|
|
|
|
|
// operator <=
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Test if string doesn't follow string.
|
|
|
|
* @param lhs First string.
|
|
|
|
* @param rhs Second string.
|
|
|
|
* @return True if @a lhs doesn't follow @a rhs. False otherwise.
|
2004-02-08 05:46:42 +01:00
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
inline bool
|
|
|
|
operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
|
|
|
const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
|
|
|
{ return __lhs.compare(__rhs) <= 0; }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Test if string doesn't follow C string.
|
|
|
|
* @param lhs String.
|
|
|
|
* @param rhs C string.
|
|
|
|
* @return True if @a lhs doesn't follow @a rhs. False otherwise.
|
2004-02-08 05:46:42 +01:00
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
inline bool
|
|
|
|
operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
|
|
|
const _CharT* __rhs)
|
|
|
|
{ return __lhs.compare(__rhs) <= 0; }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Test if C string doesn't follow string.
|
|
|
|
* @param lhs C string.
|
|
|
|
* @param rhs String.
|
|
|
|
* @return True if @a lhs doesn't follow @a rhs. False otherwise.
|
2004-02-08 05:46:42 +01:00
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
inline bool
|
|
|
|
operator<=(const _CharT* __lhs,
|
|
|
|
const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
2004-11-17 10:04:14 +01:00
|
|
|
{ return __rhs.compare(__lhs) >= 0; }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
|
|
|
// operator >=
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Test if string doesn't precede string.
|
|
|
|
* @param lhs First string.
|
|
|
|
* @param rhs Second string.
|
|
|
|
* @return True if @a lhs doesn't precede @a rhs. False otherwise.
|
2004-02-08 05:46:42 +01:00
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
inline bool
|
|
|
|
operator>=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
|
|
|
const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
|
|
|
{ return __lhs.compare(__rhs) >= 0; }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Test if string doesn't precede C string.
|
|
|
|
* @param lhs String.
|
|
|
|
* @param rhs C string.
|
|
|
|
* @return True if @a lhs doesn't precede @a rhs. False otherwise.
|
2004-02-08 05:46:42 +01:00
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
inline bool
|
|
|
|
operator>=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
|
|
|
const _CharT* __rhs)
|
|
|
|
{ return __lhs.compare(__rhs) >= 0; }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Test if C string doesn't precede string.
|
|
|
|
* @param lhs C string.
|
|
|
|
* @param rhs String.
|
|
|
|
* @return True if @a lhs doesn't precede @a rhs. False otherwise.
|
2004-02-08 05:46:42 +01:00
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
inline bool
|
|
|
|
operator>=(const _CharT* __lhs,
|
|
|
|
const basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
|
|
|
{ return __rhs.compare(__lhs) <= 0; }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Swap contents of two strings.
|
|
|
|
* @param lhs First string.
|
|
|
|
* @param rhs Second string.
|
|
|
|
*
|
2004-02-08 05:46:42 +01:00
|
|
|
* Exchanges the contents of @a lhs and @a rhs in constant time.
|
2003-07-15 09:02:40 +02:00
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
inline void
|
|
|
|
swap(basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>& __rhs)
|
|
|
|
{ __lhs.swap(__rhs); }
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Read stream into a string.
|
|
|
|
* @param is Input stream.
|
|
|
|
* @param str Buffer to store into.
|
|
|
|
* @return Reference to the input stream.
|
|
|
|
*
|
|
|
|
* Stores characters from @a is into @a str until whitespace is found, the
|
|
|
|
* end of the stream is encountered, or str.max_size() is reached. If
|
|
|
|
* is.width() is non-zero, that is the limit on the number of characters
|
|
|
|
* stored into @a str. Any previous contents of @a str are erased.
|
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
|
|
|
basic_istream<_CharT, _Traits>&
|
|
|
|
operator>>(basic_istream<_CharT, _Traits>& __is,
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>& __str);
|
|
|
|
|
2005-07-25 10:47:33 +02:00
|
|
|
template<>
|
|
|
|
basic_istream<char>&
|
|
|
|
operator>>(basic_istream<char>& __is, basic_string<char>& __str);
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Write string to a stream.
|
|
|
|
* @param os Output stream.
|
|
|
|
* @param str String to write out.
|
|
|
|
* @return Reference to the output stream.
|
|
|
|
*
|
|
|
|
* Output characters of @a str into os following the same rules as for
|
|
|
|
* writing a C string.
|
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
2006-10-15 16:43:50 +02:00
|
|
|
inline basic_ostream<_CharT, _Traits>&
|
2000-10-05 13:27:02 +02:00
|
|
|
operator<<(basic_ostream<_CharT, _Traits>& __os,
|
PR libstdc++/28277 (partial: ostream bits 2)
2006-10-13 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/28277 (partial: ostream bits 2)
* include/std/std_ostream.h (basic_ostream<>::_M_insert(const
char_type*, streamsize)): New.
(basic_ostream<>::_M_write(char_type, streamsize)): Likewise.
(operator<<(basic_ostream<>&, _CharT), operator<<(basic_ostream<>&,
char), operator<<(basic_ostream<>&, const _CharT*),
operator<<(basic_ostream<>&, const char*)): Use the latter.
* include/bits/ostream.tcc (basic_ostream<>::_M_insert(const
char_type*, streamsize)): Define.
(operator<<(basic_ostream<>&, const char*)): Use the latter.
(operator<<(basic_ostream<>&, _CharT), operator<<(basic_ostream<>&,
char), operator<<(basic_ostream<>&, const _CharT*),
operator<<(basic_ostream<>&, const char*),
operator<<(basic_ostream<>&, const basic_string<>&)): Remove.
* include/bits/basic_string.h (operator<<(basic_ostream<>&,
const basic_string<>&)): Use the latter, implement DR 586.
* config/abi/pre/gnu.ver: Adjust, export the new _M_insert.
* docs/html/ext/howto.html: Add an entry for DR 586.
* testsuite/21_strings/basic_string/inserters_extractors/char/
28277.cc: New.
* testsuite/21_strings/basic_string/inserters_extractors/wchar_t/
28277.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_character/char/
28277-3.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_character/char/
28277-4.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_character/wchar_t/
28277-2.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_character/wchar_t/
28277-3.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_character/wchar_t/
28277-4.cc: Likewise.
From-SVN: r117689
2006-10-13 11:00:31 +02:00
|
|
|
const basic_string<_CharT, _Traits, _Alloc>& __str)
|
|
|
|
{
|
|
|
|
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
|
|
// 586. string inserter not a formatted function
|
PR libstdc++/28277 (partial: vstring bits)
2007-04-10 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/28277 (partial: vstring bits)
* include/bits/ostream_insert.h: New.
* include/Makefile.am: Add.
* include/ext/vstring.h (operator<<(basic_ostream<>&,
const __versa_string<>&): Forward to __ostream_insert.
* include/bits/basic_string.h (operator<<(basic_ostream<>&,
const string<>&)): Likewise.
* include/std/ostream (operator<<(basic_ostream<>&, _CharT),
operator<<(basic_ostream<char,>&, char), operator<<(basic_ostream<>&,
const _CharT*), operator<<(basic_ostream<char,>&, const char*)):
Likewise.
* include/ext/vstring.tcc (operator<<(basic_ostream<>&,
const __versa_string<>&)): Remove.
(class basic_ostream): Remove friend declarations.
(basic_ostream<>::_M_write(char_type, streamsize),
_M_insert(const char_type*, streamsize)): Remove.
* include/bits/ostream.tcc (_M_insert(const char_type*, streamsize)):
Remove definition.
(operator<<(basic_ostream<>&, const char*)): Use __ostream_insert.
* config/abi/pre/gnu.ver: Adjust.
* src/ostream-inst.cc: Add __ostream_insert instantiations.
* include/bits/locale_facets.h (__pad<>::_S_pad): Remove __num
parameter.
* include/bits/locale_facets.tcc (__pad<>::_S_pad): Adjust.
(num_put<>::_M_pad(_CharT, streamsize, ios_base&, _CharT*,
const _CharT*, int&)): Likewise.
* include/Makefile.in: Rebuild.
* testsuite/ext/vstring/inserters_extractors/char/28277.cc: New.
* testsuite/ext/vstring/inserters_extractors/wchar_t/28277.cc: New.
* include/ext/vstring_util.h: Do not include the whole <locale>.
* include/ext/vstring.tcc (operator>>(basic_istream<>&,
__versa_string<>&, getline(basic_istream<>&, __versa_string<>&,
_CharT)): Tweak to refer to ios_base as a base of istream; do not
refer to non-standard types of istream.
* include/bits/istream.tcc (operator>>(basic_istream<>&, _CharT*),
ws(basic_istream<>&)): Do not refer to non-standard types of istream.
* include/std/bitset (operator>>(std::basic_istream<>&, bitset<>&)):
Avoid using basic_streambuf<>*.
* include/bits/istream.tcc (operator>>(basic_istream<>&,
basic_string<>&), getline(basic_istream<>&, basic_string<>&, _CharT)):
Move...
* include/bits/basic_string.tcc: ... here; tweak to refer to ios_base
as a base of istream; do not refer to non-standard types of istream.
* include/std/string: Tweak includes.
* include/ext/type_traits.h (__is_null_pointer): Add.
* include/ext/rc_string_base.h: Use it.
* include/ext/sso_string_base.h: Likewise.
* include/bits/basic_string.tcc (__is_null_pointer): Remove, use
the above.
* include/ext/vstring_util.h (__vstring_utility<>::_S_is_null_pointer):
Remove.
From-SVN: r123692
2007-04-10 12:38:50 +02:00
|
|
|
return __ostream_insert(__os, __str.data(), __str.size());
|
PR libstdc++/28277 (partial: ostream bits 2)
2006-10-13 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/28277 (partial: ostream bits 2)
* include/std/std_ostream.h (basic_ostream<>::_M_insert(const
char_type*, streamsize)): New.
(basic_ostream<>::_M_write(char_type, streamsize)): Likewise.
(operator<<(basic_ostream<>&, _CharT), operator<<(basic_ostream<>&,
char), operator<<(basic_ostream<>&, const _CharT*),
operator<<(basic_ostream<>&, const char*)): Use the latter.
* include/bits/ostream.tcc (basic_ostream<>::_M_insert(const
char_type*, streamsize)): Define.
(operator<<(basic_ostream<>&, const char*)): Use the latter.
(operator<<(basic_ostream<>&, _CharT), operator<<(basic_ostream<>&,
char), operator<<(basic_ostream<>&, const _CharT*),
operator<<(basic_ostream<>&, const char*),
operator<<(basic_ostream<>&, const basic_string<>&)): Remove.
* include/bits/basic_string.h (operator<<(basic_ostream<>&,
const basic_string<>&)): Use the latter, implement DR 586.
* config/abi/pre/gnu.ver: Adjust, export the new _M_insert.
* docs/html/ext/howto.html: Add an entry for DR 586.
* testsuite/21_strings/basic_string/inserters_extractors/char/
28277.cc: New.
* testsuite/21_strings/basic_string/inserters_extractors/wchar_t/
28277.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_character/char/
28277-3.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_character/char/
28277-4.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_character/wchar_t/
28277-2.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_character/wchar_t/
28277-3.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_character/wchar_t/
28277-4.cc: Likewise.
From-SVN: r117689
2006-10-13 11:00:31 +02:00
|
|
|
}
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Read a line from stream into a string.
|
|
|
|
* @param is Input stream.
|
|
|
|
* @param str Buffer to store into.
|
|
|
|
* @param delim Character marking end of line.
|
|
|
|
* @return Reference to the input stream.
|
|
|
|
*
|
|
|
|
* Stores characters from @a is into @a str until @a delim is found, the
|
|
|
|
* end of the stream is encountered, or str.max_size() is reached. If
|
|
|
|
* is.width() is non-zero, that is the limit on the number of characters
|
|
|
|
* stored into @a str. Any previous contents of @a str are erased. If @a
|
|
|
|
* delim was encountered, it is extracted but not stored into @a str.
|
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
2004-11-17 10:04:14 +01:00
|
|
|
basic_istream<_CharT, _Traits>&
|
2000-10-05 13:27:02 +02:00
|
|
|
getline(basic_istream<_CharT, _Traits>& __is,
|
|
|
|
basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
|
|
|
|
|
2003-07-15 09:02:40 +02:00
|
|
|
/**
|
|
|
|
* @brief Read a line from stream into a string.
|
|
|
|
* @param is Input stream.
|
|
|
|
* @param str Buffer to store into.
|
|
|
|
* @return Reference to the input stream.
|
|
|
|
*
|
|
|
|
* Stores characters from is into @a str until '\n' is found, the end of
|
|
|
|
* the stream is encountered, or str.max_size() is reached. If is.width()
|
|
|
|
* is non-zero, that is the limit on the number of characters stored into
|
|
|
|
* @a str. Any previous contents of @a str are erased. If end of line was
|
|
|
|
* encountered, it is extracted but not stored into @a str.
|
|
|
|
*/
|
2000-10-05 13:27:02 +02:00
|
|
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
2004-11-17 10:04:14 +01:00
|
|
|
inline basic_istream<_CharT, _Traits>&
|
2000-10-05 13:27:02 +02:00
|
|
|
getline(basic_istream<_CharT, _Traits>& __is,
|
2006-10-15 16:43:50 +02:00
|
|
|
basic_string<_CharT, _Traits, _Alloc>& __str)
|
|
|
|
{ return getline(__is, __str, __is.widen('\n')); }
|
|
|
|
|
2004-11-17 10:04:14 +01:00
|
|
|
template<>
|
|
|
|
basic_istream<char>&
|
|
|
|
getline(basic_istream<char>& __in, basic_string<char>& __str,
|
|
|
|
char __delim);
|
|
|
|
|
|
|
|
#ifdef _GLIBCXX_USE_WCHAR_T
|
|
|
|
template<>
|
|
|
|
basic_istream<wchar_t>&
|
|
|
|
getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
|
|
|
|
wchar_t __delim);
|
|
|
|
#endif
|
2005-12-19 01:56:05 +01:00
|
|
|
|
2008-06-29 17:46:50 +02:00
|
|
|
_GLIBCXX_END_NAMESPACE
|
basic_string.h (stod, [...]): Declare in C++0x mode.
2008-06-16 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/basic_string.h (stod, stof, stoi, stol, stold, stoll,
stoul, stoull, to_string, to_wstring): Declare in C++0x mode.
* src/string_conversions.cc: Add.
* src/Makefile.am: Update.
* config/abi/pre/gnu.ver: Adjust exports.
* src/Makefile.in: Regenerate.
* testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc:
New.
* testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/
to_string.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stod.cc: New.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stof.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stoi.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stol.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stold.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stoll.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stoul.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stoull.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
to_wstring.cc: Likewise.
From-SVN: r136841
2008-06-16 11:58:54 +02:00
|
|
|
|
2008-10-27 16:01:28 +01:00
|
|
|
#if (defined(__GXX_EXPERIMENTAL_CXX0X__) && defined(_GLIBCXX_USE_C99) \
|
|
|
|
&& !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF))
|
basic_string.h (stod, [...]): Declare in C++0x mode.
2008-06-16 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/basic_string.h (stod, stof, stoi, stol, stold, stoll,
stoul, stoull, to_string, to_wstring): Declare in C++0x mode.
* src/string_conversions.cc: Add.
* src/Makefile.am: Update.
* config/abi/pre/gnu.ver: Adjust exports.
* src/Makefile.in: Regenerate.
* testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc:
New.
* testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/
to_string.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stod.cc: New.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stof.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stoi.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stol.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stold.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stoll.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stoul.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stoull.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
to_wstring.cc: Likewise.
From-SVN: r136841
2008-06-16 11:58:54 +02:00
|
|
|
|
2008-06-29 17:46:50 +02:00
|
|
|
#include <ext/string_conversions.h>
|
basic_string.h (stod, [...]): Declare in C++0x mode.
2008-06-16 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/basic_string.h (stod, stof, stoi, stol, stold, stoll,
stoul, stoull, to_string, to_wstring): Declare in C++0x mode.
* src/string_conversions.cc: Add.
* src/Makefile.am: Update.
* config/abi/pre/gnu.ver: Adjust exports.
* src/Makefile.in: Regenerate.
* testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc:
New.
* testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/
to_string.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stod.cc: New.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stof.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stoi.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stol.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stold.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stoll.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stoul.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stoull.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
to_wstring.cc: Likewise.
From-SVN: r136841
2008-06-16 11:58:54 +02:00
|
|
|
|
2008-06-29 17:46:50 +02:00
|
|
|
_GLIBCXX_BEGIN_NAMESPACE(std)
|
basic_string.h (stod, [...]): Declare in C++0x mode.
2008-06-16 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/basic_string.h (stod, stof, stoi, stol, stold, stoll,
stoul, stoull, to_string, to_wstring): Declare in C++0x mode.
* src/string_conversions.cc: Add.
* src/Makefile.am: Update.
* config/abi/pre/gnu.ver: Adjust exports.
* src/Makefile.in: Regenerate.
* testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc:
New.
* testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/
to_string.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stod.cc: New.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stof.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stoi.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stol.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stold.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stoll.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stoul.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stoull.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
to_wstring.cc: Likewise.
From-SVN: r136841
2008-06-16 11:58:54 +02:00
|
|
|
|
2008-06-29 17:46:50 +02:00
|
|
|
// 21.4 Numeric Conversions [string.conversions].
|
|
|
|
inline int
|
|
|
|
stoi(const string& __str, size_t* __idx = 0, int __base = 10)
|
|
|
|
{ return __gnu_cxx::__stoa<long, int>(&std::strtol, "stoi", __str.c_str(),
|
|
|
|
__idx, __base); }
|
|
|
|
|
|
|
|
inline long
|
|
|
|
stol(const string& __str, size_t* __idx = 0, int __base = 10)
|
|
|
|
{ return __gnu_cxx::__stoa(&std::strtol, "stol", __str.c_str(),
|
|
|
|
__idx, __base); }
|
|
|
|
|
|
|
|
inline unsigned long
|
|
|
|
stoul(const string& __str, size_t* __idx = 0, int __base = 10)
|
|
|
|
{ return __gnu_cxx::__stoa(&std::strtoul, "stoul", __str.c_str(),
|
|
|
|
__idx, __base); }
|
|
|
|
|
|
|
|
inline long long
|
|
|
|
stoll(const string& __str, size_t* __idx = 0, int __base = 10)
|
|
|
|
{ return __gnu_cxx::__stoa(&std::strtoll, "stoll", __str.c_str(),
|
|
|
|
__idx, __base); }
|
|
|
|
|
|
|
|
inline unsigned long long
|
|
|
|
stoull(const string& __str, size_t* __idx = 0, int __base = 10)
|
|
|
|
{ return __gnu_cxx::__stoa(&std::strtoull, "stoull", __str.c_str(),
|
|
|
|
__idx, __base); }
|
|
|
|
|
|
|
|
// NB: strtof vs strtod.
|
|
|
|
inline float
|
|
|
|
stof(const string& __str, size_t* __idx = 0)
|
|
|
|
{ return __gnu_cxx::__stoa(&std::strtof, "stof", __str.c_str(), __idx); }
|
|
|
|
|
|
|
|
inline double
|
|
|
|
stod(const string& __str, size_t* __idx = 0)
|
|
|
|
{ return __gnu_cxx::__stoa(&std::strtod, "stod", __str.c_str(), __idx); }
|
|
|
|
|
|
|
|
inline long double
|
|
|
|
stold(const string& __str, size_t* __idx = 0)
|
|
|
|
{ return __gnu_cxx::__stoa(&std::strtold, "stold", __str.c_str(), __idx); }
|
|
|
|
|
|
|
|
// NB: (v)snprintf vs sprintf.
|
basic_string.h (to_string(int), [...]): Add, per resolution of DR 1261.
2009-11-11 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/basic_string.h (to_string(int), to_string(unsigned),
to_string(long), to_string(unsigned long), to_string(float),
to_string(double), to_wstring(int), to_wstring(unsigned),
to_wstring(long), to_wstring(unsigned long), to_wstring(float),
to_wstring(double)): Add, per resolution of DR 1261.
* include/ext/vstring.h: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/
dr1261.cc: Add.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
dr1261.cc: Likewise.
From-SVN: r154102
2009-11-11 20:57:48 +01:00
|
|
|
|
|
|
|
// DR 1261.
|
|
|
|
inline string
|
|
|
|
to_string(int __val)
|
|
|
|
{ return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 * sizeof(int),
|
|
|
|
"%d", __val); }
|
|
|
|
|
|
|
|
inline string
|
|
|
|
to_string(unsigned __val)
|
|
|
|
{ return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
|
|
|
|
4 * sizeof(unsigned),
|
|
|
|
"%u", __val); }
|
|
|
|
|
|
|
|
inline string
|
|
|
|
to_string(long __val)
|
|
|
|
{ return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 * sizeof(long),
|
|
|
|
"%ld", __val); }
|
|
|
|
|
|
|
|
inline string
|
|
|
|
to_string(unsigned long __val)
|
|
|
|
{ return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
|
|
|
|
4 * sizeof(unsigned long),
|
|
|
|
"%lu", __val); }
|
|
|
|
|
2008-06-29 17:46:50 +02:00
|
|
|
inline string
|
|
|
|
to_string(long long __val)
|
|
|
|
{ return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
|
|
|
|
4 * sizeof(long long),
|
|
|
|
"%lld", __val); }
|
|
|
|
|
|
|
|
inline string
|
|
|
|
to_string(unsigned long long __val)
|
|
|
|
{ return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
|
|
|
|
4 * sizeof(unsigned long long),
|
|
|
|
"%llu", __val); }
|
|
|
|
|
basic_string.h (to_string(int), [...]): Add, per resolution of DR 1261.
2009-11-11 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/basic_string.h (to_string(int), to_string(unsigned),
to_string(long), to_string(unsigned long), to_string(float),
to_string(double), to_wstring(int), to_wstring(unsigned),
to_wstring(long), to_wstring(unsigned long), to_wstring(float),
to_wstring(double)): Add, per resolution of DR 1261.
* include/ext/vstring.h: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/
dr1261.cc: Add.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
dr1261.cc: Likewise.
From-SVN: r154102
2009-11-11 20:57:48 +01:00
|
|
|
inline string
|
|
|
|
to_string(float __val)
|
|
|
|
{
|
|
|
|
const int __n =
|
|
|
|
__gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
|
|
|
|
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
|
|
|
|
"%f", __val);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline string
|
|
|
|
to_string(double __val)
|
|
|
|
{
|
|
|
|
const int __n =
|
|
|
|
__gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
|
|
|
|
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
|
|
|
|
"%f", __val);
|
|
|
|
}
|
|
|
|
|
2008-06-29 17:46:50 +02:00
|
|
|
inline string
|
|
|
|
to_string(long double __val)
|
|
|
|
{
|
|
|
|
const int __n =
|
|
|
|
__gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
|
|
|
|
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
|
|
|
|
"%Lf", __val);
|
|
|
|
}
|
basic_string.h (stod, [...]): Declare in C++0x mode.
2008-06-16 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/basic_string.h (stod, stof, stoi, stol, stold, stoll,
stoul, stoull, to_string, to_wstring): Declare in C++0x mode.
* src/string_conversions.cc: Add.
* src/Makefile.am: Update.
* config/abi/pre/gnu.ver: Adjust exports.
* src/Makefile.in: Regenerate.
* testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc:
New.
* testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/
to_string.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stod.cc: New.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stof.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stoi.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stol.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stold.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stoll.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stoul.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stoull.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
to_wstring.cc: Likewise.
From-SVN: r136841
2008-06-16 11:58:54 +02:00
|
|
|
|
|
|
|
#ifdef _GLIBCXX_USE_WCHAR_T
|
2008-06-29 17:46:50 +02:00
|
|
|
inline int
|
|
|
|
stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
|
|
|
|
{ return __gnu_cxx::__stoa<long, int>(&std::wcstol, "stoi", __str.c_str(),
|
|
|
|
__idx, __base); }
|
|
|
|
|
|
|
|
inline long
|
|
|
|
stol(const wstring& __str, size_t* __idx = 0, int __base = 10)
|
|
|
|
{ return __gnu_cxx::__stoa(&std::wcstol, "stol", __str.c_str(),
|
|
|
|
__idx, __base); }
|
|
|
|
|
|
|
|
inline unsigned long
|
|
|
|
stoul(const wstring& __str, size_t* __idx = 0, int __base = 10)
|
|
|
|
{ return __gnu_cxx::__stoa(&std::wcstoul, "stoul", __str.c_str(),
|
|
|
|
__idx, __base); }
|
|
|
|
|
|
|
|
inline long long
|
|
|
|
stoll(const wstring& __str, size_t* __idx = 0, int __base = 10)
|
|
|
|
{ return __gnu_cxx::__stoa(&std::wcstoll, "stoll", __str.c_str(),
|
|
|
|
__idx, __base); }
|
|
|
|
|
|
|
|
inline unsigned long long
|
|
|
|
stoull(const wstring& __str, size_t* __idx = 0, int __base = 10)
|
|
|
|
{ return __gnu_cxx::__stoa(&std::wcstoull, "stoull", __str.c_str(),
|
|
|
|
__idx, __base); }
|
|
|
|
|
|
|
|
// NB: wcstof vs wcstod.
|
|
|
|
inline float
|
|
|
|
stof(const wstring& __str, size_t* __idx = 0)
|
|
|
|
{ return __gnu_cxx::__stoa(&std::wcstof, "stof", __str.c_str(), __idx); }
|
|
|
|
|
|
|
|
inline double
|
|
|
|
stod(const wstring& __str, size_t* __idx = 0)
|
|
|
|
{ return __gnu_cxx::__stoa(&std::wcstod, "stod", __str.c_str(), __idx); }
|
|
|
|
|
|
|
|
inline long double
|
|
|
|
stold(const wstring& __str, size_t* __idx = 0)
|
|
|
|
{ return __gnu_cxx::__stoa(&std::wcstold, "stold", __str.c_str(), __idx); }
|
|
|
|
|
basic_string.h (to_string(int), [...]): Add, per resolution of DR 1261.
2009-11-11 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/basic_string.h (to_string(int), to_string(unsigned),
to_string(long), to_string(unsigned long), to_string(float),
to_string(double), to_wstring(int), to_wstring(unsigned),
to_wstring(long), to_wstring(unsigned long), to_wstring(float),
to_wstring(double)): Add, per resolution of DR 1261.
* include/ext/vstring.h: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/
dr1261.cc: Add.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
dr1261.cc: Likewise.
From-SVN: r154102
2009-11-11 20:57:48 +01:00
|
|
|
// DR 1261.
|
|
|
|
inline wstring
|
|
|
|
to_wstring(int __val)
|
|
|
|
{ return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 * sizeof(int),
|
|
|
|
L"%d", __val); }
|
|
|
|
|
|
|
|
inline wstring
|
|
|
|
to_wstring(unsigned __val)
|
|
|
|
{ return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
|
|
|
|
4 * sizeof(unsigned),
|
|
|
|
L"%u", __val); }
|
|
|
|
|
|
|
|
inline wstring
|
|
|
|
to_wstring(long __val)
|
|
|
|
{ return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 * sizeof(long),
|
|
|
|
L"%ld", __val); }
|
|
|
|
|
|
|
|
inline wstring
|
|
|
|
to_wstring(unsigned long __val)
|
|
|
|
{ return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
|
|
|
|
4 * sizeof(unsigned long),
|
|
|
|
L"%lu", __val); }
|
|
|
|
|
2008-06-29 17:46:50 +02:00
|
|
|
inline wstring
|
|
|
|
to_wstring(long long __val)
|
|
|
|
{ return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
|
|
|
|
4 * sizeof(long long),
|
|
|
|
L"%lld", __val); }
|
|
|
|
|
|
|
|
inline wstring
|
|
|
|
to_wstring(unsigned long long __val)
|
|
|
|
{ return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
|
|
|
|
4 * sizeof(unsigned long long),
|
|
|
|
L"%llu", __val); }
|
|
|
|
|
basic_string.h (to_string(int), [...]): Add, per resolution of DR 1261.
2009-11-11 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/basic_string.h (to_string(int), to_string(unsigned),
to_string(long), to_string(unsigned long), to_string(float),
to_string(double), to_wstring(int), to_wstring(unsigned),
to_wstring(long), to_wstring(unsigned long), to_wstring(float),
to_wstring(double)): Add, per resolution of DR 1261.
* include/ext/vstring.h: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/
dr1261.cc: Add.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
dr1261.cc: Likewise.
From-SVN: r154102
2009-11-11 20:57:48 +01:00
|
|
|
inline wstring
|
|
|
|
to_wstring(float __val)
|
|
|
|
{
|
|
|
|
const int __n =
|
|
|
|
__gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
|
|
|
|
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
|
|
|
|
L"%f", __val);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline wstring
|
|
|
|
to_wstring(double __val)
|
|
|
|
{
|
|
|
|
const int __n =
|
|
|
|
__gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
|
|
|
|
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
|
|
|
|
L"%f", __val);
|
|
|
|
}
|
|
|
|
|
2008-06-29 17:46:50 +02:00
|
|
|
inline wstring
|
|
|
|
to_wstring(long double __val)
|
|
|
|
{
|
|
|
|
const int __n =
|
|
|
|
__gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
|
|
|
|
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
|
|
|
|
L"%Lf", __val);
|
|
|
|
}
|
basic_string.h (stod, [...]): Declare in C++0x mode.
2008-06-16 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/basic_string.h (stod, stof, stoi, stol, stold, stoll,
stoul, stoull, to_string, to_wstring): Declare in C++0x mode.
* src/string_conversions.cc: Add.
* src/Makefile.am: Update.
* config/abi/pre/gnu.ver: Adjust exports.
* src/Makefile.in: Regenerate.
* testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc:
New.
* testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/
to_string.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stod.cc: New.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stof.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stoi.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stol.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stold.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stoll.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stoul.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
stoull.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/
to_wstring.cc: Likewise.
From-SVN: r136841
2008-06-16 11:58:54 +02:00
|
|
|
#endif
|
|
|
|
|
2005-12-19 01:56:05 +01:00
|
|
|
_GLIBCXX_END_NAMESPACE
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2008-06-29 17:46:50 +02:00
|
|
|
#endif
|
|
|
|
|
2003-07-05 06:05:45 +02:00
|
|
|
#endif /* _BASIC_STRING_H */
|