__GNU_CXX::ROPE(3)

🌸 NAME 🌸

__gnu_cxx::rope< _CharT, _Alloc >

okay so real talk, this is a page from the Library Functions Manual (that's the (3) energy, iykyk) and it's all about __gnu_cxx::rope< _CharT, _Alloc >. bestie, this thing is massive β€” a whole tree of nodes pretending to be a string. grab a snack. πŸ“


✨ SYNOPSIS ✨

#include <rope>

πŸ’– Public Types πŸ’–

these are the building blocks, the little labels everything else points at:

  • typedef _Rope_RopeConcatenation< _CharT, _Alloc > __C β€” the concatenation node type, nicknamed __C bc life's too short
  • typedef _Rope_RopeFunction< _CharT, _Alloc > __F β€” the function node type, a.k.a. __F
  • typedef _Rope_RopeLeaf< _CharT, _Alloc > __L β€” the leaf node type, __L, the little guy holding actual chars
  • typedef _Rope_RopeSubstring< _CharT, _Alloc > __S β€” the substring node type, __S
  • typedef __alloc_traits< _Alloc >::template rebind< __C >::other _CAlloc β€” an allocator rebound for __C
  • typedef __alloc_traits< _Alloc >::template rebind< _CharT >::other _DataAlloc β€” an allocator rebound for _CharT, the raw data one
  • typedef __alloc_traits< _Alloc >::template rebind< __F >::other _FAlloc β€” allocator, but for __F
  • typedef __alloc_traits< _Alloc >::template rebind< __L >::other _LAlloc β€” allocator, but for __L
  • typedef __alloc_traits< _Alloc >::template rebind< __S >::other _SAlloc β€” allocator, but for __S
  • typedef _Rope_const_iterator< _CharT, _Alloc > const_iterator β€” your const iterator, no touching
  • typedef const _CharT * const_pointer β€” a const pointer to _CharT
  • typedef _CharT const_reference β€” ok this one is not a reference at all, it's a bare _CharT. yes fr. it's giving proxy, and we respect it
  • typedef std::reverse_iterator< const_iterator > const_reverse_iterator β€” const iterator, but backwards πŸ’«
  • typedef std::ptrdiff_t difference_type β€” the difference type, standard issue
  • typedef _Rope_iterator< _CharT, _Alloc > iterator β€” the iterator you can actually write through
  • typedef _Rope_char_ptr_proxy< _CharT, _Alloc > pointer β€” the pointer is a proxy, not a raw pointer, iconic honestly
  • typedef _Rope_char_ref_proxy< _CharT, _Alloc > reference β€” same deal for references
  • typedef std::reverse_iterator< iterator > reverse_iterator β€” reverse iterator, but mutable
  • typedef std::size_t size_type β€” sizes are std::size_t
  • typedef _CharT value_type β€” and the value type is just _CharT, clean

πŸ¦‹ Public Member Functions πŸ¦‹

strap in, this is the long part. every single one is here, in order, no skipping:

  • rope (_CharT __c, const allocator_type &__a=allocator_type()) β€” a whole rope out of one single _CharT __c
  • rope (char_producer< _CharT > *__fn, size_type __len, bool __delete_fn, const allocator_type &__a=allocator_type()) β€” builds from a char_producer< _CharT > *__fn, __len long, and __delete_fn decides whether that producer gets deleted
  • rope (const _CharT *__s, const _CharT *__e, const allocator_type &__a=allocator_type()) β€” from the range __s to __e
  • rope (const _CharT *__s, const allocator_type &__a=allocator_type()) β€” from a plain C string __s
  • rope (const _CharT *__s, size_type __len, const allocator_type &__a=allocator_type()) β€” __s, but only __len of it
  • rope (const allocator_type &__a=allocator_type()) β€” the empty one, the blank canvas
  • rope (const const_iterator &__s, const const_iterator &__e, const allocator_type &__a=allocator_type()) β€” from a const_iterator range
  • rope (const iterator &__s, const iterator &__e, const allocator_type &__a=allocator_type()) β€” from an iterator range
  • rope (const rope &__x, const allocator_type &__a=allocator_type()) β€” the copy constructor, __x said it first
  • rope (size_type __n, _CharT __c, const allocator_type &__a=allocator_type()) β€” __n copies of __c, no notes
  • allocator_type & _M_get_allocator () β€” hands you the allocator
  • const allocator_type & _M_get_allocator () const β€” same allocator, but const-coded
  • rope & append () β€” append nothing?? yes. it's in the API. periodt πŸ’…
  • rope & append (_CharT __c) β€” tack on one char
  • rope & append (const _CharT *__c_string) β€” tack on a C string
  • rope & append (const _CharT *__iter, size_type __n) β€” __n chars starting at __iter
  • rope & append (const _CharT *__s, const _CharT *__e) β€” everything in [__s, __e)
  • rope & append (const rope &__y) β€” another whole rope, absorbed
  • rope & append (const_iterator __s, const_iterator __e) β€” append an iterator range
  • rope & append (size_type __n, _CharT __c) β€” __n copies of __c, again
  • void apply_to_pieces (size_type __begin, size_type __end, _Rope_char_consumer< _CharT > &__c) const β€” run a _Rope_char_consumer< _CharT > &__c over the pieces from __begin to __end
  • _CharT at (size_type __pos) const β€” the char at __pos
  • _CharT back () const β€” last char, come through
  • void balance () β€” balance the tree, self-care 🧘
  • const_iterator begin () β€” start of it all
  • const_iterator begin () const β€” start of it all, const
  • const _CharT * c_str () const β€” C string time
  • void clear () β€” wipe it, we move
  • int compare (const rope &__y) const β€” compare against __y, returns an int
  • const_iterator const_begin () const β€” const begin, explicitly
  • const_iterator const_end () const β€” const end, explicitly
  • const_reverse_iterator const_rbegin () const β€” const reverse begin
  • const_reverse_iterator const_rend () const β€” const reverse end
  • void copy (_CharT *__buffer) const β€” copy the whole thing into __buffer
  • size_type copy (size_type __pos, size_type __n, _CharT *__buffer) const β€” copy __n chars from __pos into __buffer, returns a size_type
  • void delete_c_str () β€” bye to the C string
  • void dump () β€” dump it, no thoughts
  • bool empty () const β€” is it empty? yes/no
  • const_iterator end () β€” the end, bestie
  • const_iterator end () const β€” the end, const edition
  • iterator erase (const iterator &__p) β€” erase whatever __p points at, get an iterator back
  • iterator erase (const iterator &__p, const iterator &__q) β€” erase everything from __p to __q
  • void erase (size_type __p, size_type __n) β€” erase __n things starting at __p
  • size_type find (_CharT __c, size_type __pos=0) const β€” hunt for __c, starting at __pos (defaults to 0)
  • size_type find (const _CharT *__s, size_type __pos=0) const β€” hunt for the string __s, starting at __pos (again, 0)
  • _CharT front () const β€” first char, main character energy πŸ‘‘
  • allocator_type get_allocator () const β€” hand over the allocator, const-ly
  • iterator insert (const iterator &__p) β€” insert at __p, iterator in, iterator out
  • iterator insert (const iterator &__p, _CharT __c) β€” drop a __c in at __p
  • iterator insert (const iterator &__p, const _CharT *__i, const _CharT *__j) β€” drop in the range __i to __j
  • iterator insert (const iterator &__p, const _CharT *__i, size_type __n) β€” drop in __n chars from __i
  • iterator insert (const iterator &__p, const _CharT *c_string) β€” drop in a whole C string
  • iterator insert (const iterator &__p, const const_iterator &__i, const const_iterator &__j) β€” const_iterator range, inserted
  • iterator insert (const iterator &__p, const iterator &__i, const iterator &__j) β€” iterator range, inserted
  • iterator insert (const iterator &__p, const rope &__r) β€” shove an entire rope __r in there
  • iterator insert (const iterator &__p, size_type __n, _CharT __c) β€” __n copies of __c, at __p
  • void insert (size_type __p) β€” the void-returning insert, no args past the position
  • void insert (size_type __p, _CharT __c) β€” one char at __p
  • void insert (size_type __p, const _CharT *__c_string) β€” a C string at __p
  • void insert (size_type __p, const _CharT *__i, const _CharT *__j) β€” range __i to __j at __p
  • void insert (size_type __p, const _CharT *__i, size_type __n) β€” __n chars from __i, at __p
  • void insert (size_type __p, const const_iterator &__i, const const_iterator &__j) β€” const_iterator range, at __p
  • void insert (size_type __p, const iterator &__i, const iterator &__j) β€” iterator range, at __p
  • void insert (size_type __p, const rope &__r) β€” the whole rope __r, at __p
  • void insert (size_type __p, size_type __n, _CharT __c) β€” __n copies of __c, at __p
  • size_type length () const β€” how long is it
  • size_type max_size () const β€” how long could it be, hypothetically
  • iterator mutable_begin () β€” begin, but mutable, so you can actually change things
  • iterator mutable_end () β€” mutable end, matching set
  • reverse_iterator mutable_rbegin () β€” mutable reverse begin
  • reference mutable_reference_at (size_type __pos) β€” a mutable reference at __pos, yes that proxy type
  • reverse_iterator mutable_rend () β€” mutable reverse end
  • rope & operator= (const rope &__x) β€” assignment, __x gets copied over
  • _CharT operator[] (size_type __pos) const β€” index into it at __pos, returns a _CharT
  • void pop_back () β€” yeet the last char
  • void pop_front () β€” yeet the first char
  • void push_back (_CharT __x) β€” add __x to the back
  • void push_front (_CharT __x) β€” add __x to the front
  • const_reverse_iterator rbegin () β€” reverse begin, here we go backwards
  • const_reverse_iterator rbegin () const β€” reverse begin, const
  • const_reverse_iterator rend () β€” reverse end
  • const_reverse_iterator rend () const β€” reverse end, const
  • void replace (const iterator &__p, _CharT __c) β€” swap what's at __p for __c
  • void replace (const iterator &__p, const _CharT *__c_string) β€” swap it for a C string
  • void replace (const iterator &__p, const _CharT *__i, const _CharT *__j) β€” swap it for the range __i to __j
  • void replace (const iterator &__p, const _CharT *__i, size_type __n) β€” swap it for __n chars from __i
  • void replace (const iterator &__p, const iterator &__q, _CharT __c) β€” replace __p through __q with __c
  • void replace (const iterator &__p, const iterator &__q, const _CharT *__c_string) β€” replace that range with a C string
  • void replace (const iterator &__p, const iterator &__q, const _CharT *__i, const _CharT *__j) β€” replace that range with __i to __j
  • void replace (const iterator &__p, const iterator &__q, const _CharT *__i, size_type __n) β€” replace that range with __n chars from __i
  • void replace (const iterator &__p, const iterator &__q, const const_iterator &__i, const const_iterator &__j) β€” replace that range with a const_iterator range
  • void replace (const iterator &__p, const iterator &__q, const iterator &__i, const iterator &__j) β€” replace that range with an iterator range
  • void replace (const iterator &__p, const iterator &__q, const rope &__r) β€” replace that range with a whole rope __r
  • void replace (const iterator &__p, const rope &__r) β€” replace from __p with a rope
  • void replace (const iterator &__p, const_iterator __i, const_iterator __j) β€” replace from __p with __i to __j
  • void replace (const iterator &__p, iterator __i, iterator __j) β€” same but the iterators aren't const-ref'd, note the difference bestie
  • void replace (size_type __p, _CharT __c) β€” index-based version, swap in __c at __p
  • void replace (size_type __p, const _CharT *__c_string) β€” index-based, C string in
  • void replace (size_type __p, const _CharT *__i, const _CharT *__j) β€” index-based, range __i to __j
  • void replace (size_type __p, const _CharT *__i, size_type __i_len) β€” index-based, __i_len chars from __i (yes, __i_len, not __n, they really did that)
  • void replace (size_type __p, const const_iterator &__i, const const_iterator &__j) β€” index-based, const_iterator range
  • void replace (size_type __p, const iterator &__i, const iterator &__j) β€” index-based, iterator range
  • void replace (size_type __p, const rope &__r) β€” index-based, whole rope __r
  • void replace (size_type __p, size_type __n, _CharT __c) β€” __n chars at __p, all __c
  • void replace (size_type __p, size_type __n, const _CharT *__c_string) β€” __n chars at __p, C string edition
  • void replace (size_type __p, size_type __n, const _CharT *__i, const _CharT *__j) β€” __n chars at __p, from range __i to __j
  • void replace (size_type __p, size_type __n, const _CharT *__i, size_type __i_len) β€” __n chars at __p, from __i_len chars of __i
  • void replace (size_type __p, size_type __n, const const_iterator &__i, const const_iterator &__j) β€” __n chars at __p, const_iterator range
  • void replace (size_type __p, size_type __n, const iterator &__i, const iterator &__j) β€” __n chars at __p, iterator range
  • void replace (size_type __p, size_type __n, const rope &__r) β€” __n chars at __p, filled with rope __r
  • const _CharT * replace_with_c_str () β€” swap the whole thing out for a C string and hand you the pointer
  • size_type size () const β€” the size, bestie
  • rope< _CharT, _Alloc > substr (const_iterator __start) β€” a sub-rope from __start on (note: this one says rope< _CharT, _Alloc > in full, not just rope)
  • rope substr (const_iterator __start, const_iterator __end) const β€” sub-rope from __start to __end
  • rope substr (iterator __start) const β€” from __start, mutable iterator flavour
  • rope substr (iterator __start, iterator __end) const β€” __start to __end, mutable iterator flavour
  • rope substr (size_type __start, size_type __len=1) const β€” index-based, __len long, and it defaults to 1
  • void swap (rope &__b) β€” trade contents with __b, mutual exchange, very demure

πŸ’… Static Public Member Functions πŸ’…

all static, all about raw allocation. the node factory floor:

  • static __C * _C_allocate (std::size_t __n) β€” allocate for __C
  • static void _C_deallocate (__C *__p, std::size_t __n) β€” deallocate __C
  • static _CharT * _Data_allocate (std::size_t __n) β€” allocate raw _CharT data
  • static void _Data_deallocate (_CharT *__p, std::size_t __n) β€” deallocate that data
  • static __F * _F_allocate (std::size_t __n) β€” allocate for __F
  • static void _F_deallocate (__F *__p, std::size_t __n) β€” deallocate __F
  • static __L * _L_allocate (std::size_t __n) β€” allocate for __L
  • static void _L_deallocate (__L *__p, std::size_t __n) β€” deallocate __L
  • static __S * _S_allocate (std::size_t __n) β€” allocate for __S
  • static void _S_deallocate (__S *__p, std::size_t __n) β€” deallocate __S

πŸ“ Public Attributes πŸ“

  • _RopeRep * _M_tree_ptr β€” the one and only public data member, the pointer to the whole tree. everything else is vibes

⭐ Static Public Attributes ⭐

  • static const size_type npos β€” the classic npos, static and const, doing its thing

πŸŽ€ Protected Types πŸŽ€

for the subclasses and the inner circle only:

  • enum { _S_copy_max } β€” an anonymous enum with the member _S_copy_max
  • typedef _Rope_base< _CharT, _Alloc > _Base β€” the base class, shortened to _Base
  • typedef _CharT * _Cstrptr β€” a _CharT *, but with a cuter name
  • typedef _Rope_RopeConcatenation< _CharT, _Alloc > _RopeConcatenation β€” the concatenation node, full name this time
  • typedef _Rope_RopeFunction< _CharT, _Alloc > _RopeFunction β€” the function node, full name
  • typedef _Rope_RopeLeaf< _CharT, _Alloc > _RopeLeaf β€” the leaf node, full name
  • typedef _Rope_RopeRep< _CharT, _Alloc > _RopeRep β€” the representation node, full name
  • typedef _Rope_RopeSubstring< _CharT, _Alloc > _RopeSubstring β€” the substring node, full name
  • typedef _Rope_self_destruct_ptr< _CharT, _Alloc > _Self_destruct_ptr β€” a self-destructing pointer, dramatic and useful
  • typedef _Base::allocator_type allocator_type β€” allocator_type borrowed straight from _Base

and that's the whole type sheet and every single member, bestie β€” no crumbs left behind. there's more of this page still to come, so don't go anywhere πŸ’œ


✨ Static Protected Member Functions ✨

okay bestie, so behind the scenes of this rope class there's a whole squad of static protected member functions doing the absolute most. no cap, they're the backstage crew that keeps everything from unraveling. πŸ’… here's the full lineup, exactly as they appear:

  • static size_type _S_allocated_capacity (size_type __n) 🌸
  • static bool _S_apply_to_pieces (_Rope_char_consumer< _CharT > &__c, const _RopeRep *__r, size_type __begin, size_type __end) ✨
  • static _RopeRep * _S_concat (_RopeRep *__left, _RopeRep *__right) πŸ’–
  • static _RopeRep * _S_concat_char_iter (_RopeRep *__r, const _CharT *__iter, size_type __slen, allocator_type &__a) πŸ¦‹
  • static _RopeRep * _S_destr_concat_char_iter (_RopeRep *__r, const _CharT *__iter, size_type __slen, allocator_type &__a) 🌈
  • static _RopeLeaf * _S_destr_leaf_concat_char_iter (_RopeLeaf *__r, const _CharT *__iter, size_type __slen) πŸŽ€
  • static _CharT _S_fetch (_RopeRep *__r, size_type __pos) πŸ‘‘
  • static _CharT * _S_fetch_ptr (_RopeRep *__r, size_type __pos) ⭐
  • static bool _S_is0 (_CharT __c) πŸ’œ
  • static _RopeLeaf * _S_leaf_concat_char_iter (_RopeLeaf *__r, const _CharT *__iter, size_type __slen) 🧚
  • static _RopeConcatenation * _S_new_RopeConcatenation (_RopeRep *__left, _RopeRep *__right, allocator_type &__a) πŸ’€
  • static _RopeFunction * _S_new_RopeFunction (char_producer< _CharT > *__f, size_type __size, bool __d, allocator_type &__a) πŸ”₯
  • static _RopeLeaf * _S_new_RopeLeaf (_CharT *__s, size_type __size, allocator_type &__a) πŸ“
  • static _RopeSubstring * _S_new_RopeSubstring (_Rope_RopeRep< _CharT, _Alloc > *__b, size_type __s, size_type __l, allocator_type &__a) 🌟
  • static void _S_ref (_RopeRep *__t) πŸ’–
  • static _RopeLeaf * _S_RopeLeaf_from_unowned_char_ptr (const _CharT *__s, size_type __size, allocator_type &__a) 🌸
  • static size_type _S_rounded_up_size (size_type __n) ✨
  • static _RopeRep * _S_substring (_RopeRep *__base, size_type __start, size_type __endp1) πŸ¦‹
  • static _RopeRep * _S_tree_concat (_RopeRep *__left, _RopeRep *__right) 🌈
  • static void _S_unref (_RopeRep *__t) πŸŽ€
  • static _RopeRep * replace (_RopeRep *__old, size_type __pos1, size_type __pos2, _RopeRep *__r) πŸ‘‘

✨ Static Protected Attributes ✨

just one iconic static attribute holding it down:

  • static _CharT _S_empty_c_str [1] πŸ’…

✨ Friends ✨

these are the besties this class trusts with its whole heart. lowkey a whole friend group:

  • class _Rope_char_ptr_proxy< _CharT, _Alloc > 🌸
  • class _Rope_char_ref_proxy< _CharT, _Alloc > ✨
  • class _Rope_const_iterator< _CharT, _Alloc > πŸ’–
  • class _Rope_iterator< _CharT, _Alloc > πŸ¦‹
  • class _Rope_iterator_base< _CharT, _Alloc > 🌈
  • struct _Rope_RopeRep< _CharT, _Alloc > πŸŽ€
  • struct _Rope_RopeSubstring< _CharT, _Alloc > πŸ‘‘
  • template<class _CharT2, class _Alloc2> rope< _CharT2, _Alloc2 > operator+ (const rope< _CharT2, _Alloc2 > &__left, _CharT2 __right) ⭐
  • template<class _CharT2, class _Alloc2> rope< _CharT2, _Alloc2 > operator+ (const rope< _CharT2, _Alloc2 > &__left, const _CharT2 *__right) πŸ’œ
  • template<class _CharT2, class _Alloc2> rope< _CharT2, _Alloc2 > operator+ (const rope< _CharT2, _Alloc2 > &__left, const rope< _CharT2, _Alloc2 > &__right) 🧚

🌸 Detailed Description 🌸

so the class itself is defined like this, and it literally says it's an SGI extension. the quote mark situation is a little wild but we're keeping it exactly as the original:

template<class _CharT, class _Alloc>
    class __gnu_cxx::rope< _CharT, _Alloc >"This is an SGI extension.
Todo: Needs documentation! See http://gcc.gnu.org/onlinedocs/libstdc++/manual/documentation_style.html

πŸ’– Author πŸ’–

this whole thing was generated automatically by Doxygen for libstdc++ from the source code. no human author, just vibes. periodt. πŸ’…


anyway bestie, that's the whole tea. this page is from libstdc++, and it's the manpage for __gnu_cxx:...T, _Alloc >(3). slay, you made it to the end. ✨🫢

πŸ“¦ where this page comes from
  • arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
  • fedora 44: libstdc++-docs 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • fedora 44: libstdc++-docs 16.2.1-2.fc44
  • fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms