public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] libstdc++: Remove __gnu_cxx::rope::erase(size_type) [PR102048]
@ 2021-08-25 21:29 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2021-08-25 21:29 UTC (permalink / raw)
  To: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1217 bytes --]

This function claims to remove a single character at index p, but it
actually removes p+1 characters beginning at p. So r.erase(0) removes
the first character, but r.erase(1) removes the second and third, and
r.erase(2) removes the second, third and fourth. This is not a useful
API.

The overload is present in the SGI STL <stl_rope.h> header that we
imported, but it isn't documented in the API reference. The erase
overloads that are documented are:

erase(const iterator& p)
erase(const iterator& f, const iterator& l)
erase(size_type i, size_type n);

Having an erase(size_type p) overload that erases a single character (as
the comment says it does) might be useful, but would be inconsistent
with std::basic_string::erase(size_type p = 0, size_type n = npos),
which erases from p to the end of the string when called with a single
argument.

Since the function isn't part of the documented API, doesn't do what it
claims to do (or anything useful) and "fixing" it would leave it
inconsistent with basic_string, I'm just removing that overload.

libstdc++-v3/ChangeLog:

	PR libstdc++/102048
	* include/ext/rope (rope::erase(size_type)): Remove broken
	function.

Tested powerpc64le-linux. Committed to trunk.


[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 2003 bytes --]

commit 2cd229dec8d6716938de5052479d059d306969da
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Aug 25 16:42:49 2021

    libstdc++: Remove __gnu_cxx::rope::erase(size_type) [PR102048]
    
    This function claims to remove a single character at index p, but it
    actually removes p+1 characters beginning at p. So r.erase(0) removes
    the first character, but r.erase(1) removes the second and third, and
    r.erase(2) removes the second, third and fourth. This is not a useful
    API.
    
    The overload is present in the SGI STL <stl_rope.h> header that we
    imported, but it isn't documented in the API reference. The erase
    overloads that are documented are:
    
    erase(const iterator& p)
    erase(const iterator& f, const iterator& l)
    erase(size_type i, size_type n);
    
    Having an erase(size_type p) overload that erases a single character (as
    the comment says it does) might be useful, but would be inconsistent
    with std::basic_string::erase(size_type p = 0, size_type n = npos),
    which erases from p to the end of the string when called with a single
    argument.
    
    Since the function isn't part of the documented API, doesn't do what it
    claims to do (or anything useful) and "fixing" it would leave it
    inconsistent with basic_string, I'm just removing that overload.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/102048
            * include/ext/rope (rope::erase(size_type)): Remove broken
            function.

diff --git a/libstdc++-v3/include/ext/rope b/libstdc++-v3/include/ext/rope
index 9681dbc6225..d4406a942b6 100644
--- a/libstdc++-v3/include/ext/rope
+++ b/libstdc++-v3/include/ext/rope
@@ -2401,11 +2401,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	this->_M_tree_ptr = __result;
       }
 
-      // Erase, single character
-      void
-      erase(size_type __p)
-      { erase(__p, __p + 1); }
-
       // Insert, iterator variants.
       iterator
       insert(const iterator& __p, const rope& __r)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-25 21:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-25 21:29 [committed] libstdc++: Remove __gnu_cxx::rope::erase(size_type) [PR102048] Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).