aboutsummaryrefslogtreecommitdiff
path: root/libstdc++/std
diff options
context:
space:
mode:
authorJason Merrill <jason@yorick.cygnus.com>1997-11-26 07:19:11 +0000
committerJason Merrill <jason@yorick.cygnus.com>1997-11-26 07:19:11 +0000
commitde1081f92bdb869fb741cc949bd9fbd501663f3c (patch)
tree85d965149086f3ac6e9f3f524177fc78b28e79f2 /libstdc++/std
parent247bbfba0f74ac98cd5596eb0cea73ce8cee80bf (diff)
London changes to string:
* std/bastring.cc (check_realloc): Don't be selfish anymore. * std/bastring.h (non-const operator[]): Be selfish. (iterator forms of insert and erase): Stay selfish. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@16722 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++/std')
-rw-r--r--libstdc++/std/bastring.cc1
-rw-r--r--libstdc++/std/bastring.h10
2 files changed, 6 insertions, 5 deletions
diff --git a/libstdc++/std/bastring.cc b/libstdc++/std/bastring.cc
index aa151da69d1..444797096dc 100644
--- a/libstdc++/std/bastring.cc
+++ b/libstdc++/std/bastring.cc
@@ -87,6 +87,7 @@ inline bool basic_string <charT, traits>::
check_realloc (size_t s) const
{
s += sizeof (charT);
+ rep ()->selfish = false;
return (rep ()->ref > 1
|| s > capacity ()
|| Rep::excess_slop (s, capacity ()));
diff --git a/libstdc++/std/bastring.h b/libstdc++/std/bastring.h
index 59a59958302..f8fe279b158 100644
--- a/libstdc++/std/bastring.h
+++ b/libstdc++/std/bastring.h
@@ -220,9 +220,9 @@ public:
basic_string& insert (size_type pos, size_type n, charT c)
{ return replace (pos, 0, n, c); }
iterator insert(iterator p, charT c)
- { insert (p - ibegin (), 1, c); return p; }
+ { insert (p - ibegin (), 1, c); selfish (); return p; }
iterator insert(iterator p, size_type n, charT c)
- { insert (p - ibegin (), n, c); return p; }
+ { insert (p - ibegin (), n, c); selfish (); return p; }
#ifdef __STL_MEMBER_TEMPLATES
template<class InputIterator>
void insert(iterator p, InputIterator first, InputIterator last)
@@ -234,9 +234,9 @@ public:
basic_string& erase (size_type pos = 0, size_type n = npos)
{ return replace (pos, n, (size_type)0, (charT)0); }
iterator erase(iterator p)
- { replace (p - ibegin (), 1, (size_type)0, (charT)0); return p; }
+ { replace (p-ibegin (), 1, (size_type)0, (charT)0); selfish (); return p; }
iterator erase(iterator f, iterator l)
- { replace (f - ibegin (), l - f, (size_type)0, (charT)0); return f; }
+ { replace (f-ibegin (), l-f, (size_type)0, (charT)0);selfish ();return f; }
basic_string& replace (size_type pos1, size_type n1, const basic_string& str,
size_type pos2 = 0, size_type n2 = npos);
@@ -278,7 +278,7 @@ public:
}
reference operator[] (size_type pos)
- { unique (); return (*rep ())[pos]; }
+ { selfish (); return (*rep ())[pos]; }
reference at (size_type pos)
{