__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__Cbc life's too shorttypedef _Rope_RopeFunction< _CharT, _Alloc > __Fβ the function node type, a.k.a.__Ftypedef _Rope_RopeLeaf< _CharT, _Alloc > __Lβ the leaf node type,__L, the little guy holding actual charstypedef _Rope_RopeSubstring< _CharT, _Alloc > __Sβ the substring node type,__Stypedef __alloc_traits< _Alloc >::template rebind< __C >::other _CAllocβ an allocator rebound for__Ctypedef __alloc_traits< _Alloc >::template rebind< _CharT >::other _DataAllocβ an allocator rebound for_CharT, the raw data onetypedef __alloc_traits< _Alloc >::template rebind< __F >::other _FAllocβ allocator, but for__Ftypedef __alloc_traits< _Alloc >::template rebind< __L >::other _LAllocβ allocator, but for__Ltypedef __alloc_traits< _Alloc >::template rebind< __S >::other _SAllocβ allocator, but for__Stypedef _Rope_const_iterator< _CharT, _Alloc > const_iteratorβ your const iterator, no touchingtypedef const _CharT * const_pointerβ a const pointer to_CharTtypedef _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 ittypedef std::reverse_iterator< const_iterator > const_reverse_iteratorβ const iterator, but backwards π«typedef std::ptrdiff_t difference_typeβ the difference type, standard issuetypedef _Rope_iterator< _CharT, _Alloc > iteratorβ the iterator you can actually write throughtypedef _Rope_char_ptr_proxy< _CharT, _Alloc > pointerβ the pointer is a proxy, not a raw pointer, iconic honestlytypedef _Rope_char_ref_proxy< _CharT, _Alloc > referenceβ same deal for referencestypedef std::reverse_iterator< iterator > reverse_iteratorβ reverse iterator, but mutabletypedef std::size_t size_typeβ sizes arestd::size_ttypedef _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 __crope (char_producer< _CharT > *__fn, size_type __len, bool __delete_fn, const allocator_type &__a=allocator_type())β builds from achar_producer< _CharT > *__fn,__lenlong, and__delete_fndecides whether that producer gets deletedrope (const _CharT *__s, const _CharT *__e, const allocator_type &__a=allocator_type())β from the range__sto__erope (const _CharT *__s, const allocator_type &__a=allocator_type())β from a plain C string__srope (const _CharT *__s, size_type __len, const allocator_type &__a=allocator_type())β__s, but only__lenof itrope (const allocator_type &__a=allocator_type())β the empty one, the blank canvasrope (const const_iterator &__s, const const_iterator &__e, const allocator_type &__a=allocator_type())β from aconst_iteratorrangerope (const iterator &__s, const iterator &__e, const allocator_type &__a=allocator_type())β from aniteratorrangerope (const rope &__x, const allocator_type &__a=allocator_type())β the copy constructor,__xsaid it firstrope (size_type __n, _CharT __c, const allocator_type &__a=allocator_type())β__ncopies of__c, no notesallocator_type & _M_get_allocator ()β hands you the allocatorconst allocator_type & _M_get_allocator () constβ same allocator, but const-codedrope & append ()β append nothing?? yes. it's in the API. periodt πrope & append (_CharT __c)β tack on one charrope & append (const _CharT *__c_string)β tack on a C stringrope & append (const _CharT *__iter, size_type __n)β__nchars starting at__iterrope & append (const _CharT *__s, const _CharT *__e)β everything in[__s, __e)rope & append (const rope &__y)β another whole rope, absorbedrope & append (const_iterator __s, const_iterator __e)β append an iterator rangerope & append (size_type __n, _CharT __c)β__ncopies of__c, againvoid apply_to_pieces (size_type __begin, size_type __end, _Rope_char_consumer< _CharT > &__c) constβ run a_Rope_char_consumer< _CharT > &__cover the pieces from__beginto__end_CharT at (size_type __pos) constβ the char at__pos_CharT back () constβ last char, come throughvoid balance ()β balance the tree, self-care π§const_iterator begin ()β start of it allconst_iterator begin () constβ start of it all, constconst _CharT * c_str () constβ C string timevoid clear ()β wipe it, we moveint compare (const rope &__y) constβ compare against__y, returns anintconst_iterator const_begin () constβ const begin, explicitlyconst_iterator const_end () constβ const end, explicitlyconst_reverse_iterator const_rbegin () constβ const reverse beginconst_reverse_iterator const_rend () constβ const reverse endvoid copy (_CharT *__buffer) constβ copy the whole thing into__buffersize_type copy (size_type __pos, size_type __n, _CharT *__buffer) constβ copy__nchars from__posinto__buffer, returns asize_typevoid delete_c_str ()β bye to the C stringvoid dump ()β dump it, no thoughtsbool empty () constβ is it empty? yes/noconst_iterator end ()β the end, bestieconst_iterator end () constβ the end, const editioniterator erase (const iterator &__p)β erase whatever__ppoints at, get an iterator backiterator erase (const iterator &__p, const iterator &__q)β erase everything from__pto__qvoid erase (size_type __p, size_type __n)β erase__nthings starting at__psize_type find (_CharT __c, size_type __pos=0) constβ hunt for__c, starting at__pos(defaults to0)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-lyiterator insert (const iterator &__p)β insert at__p, iterator in, iterator outiterator insert (const iterator &__p, _CharT __c)β drop a__cin at__piterator insert (const iterator &__p, const _CharT *__i, const _CharT *__j)β drop in the range__ito__jiterator insert (const iterator &__p, const _CharT *__i, size_type __n)β drop in__nchars from__iiterator insert (const iterator &__p, const _CharT *c_string)β drop in a whole C stringiterator insert (const iterator &__p, const const_iterator &__i, const const_iterator &__j)βconst_iteratorrange, insertediterator insert (const iterator &__p, const iterator &__i, const iterator &__j)βiteratorrange, insertediterator insert (const iterator &__p, const rope &__r)β shove an entire rope__rin thereiterator insert (const iterator &__p, size_type __n, _CharT __c)β__ncopies of__c, at__pvoid insert (size_type __p)β the void-returning insert, no args past the positionvoid insert (size_type __p, _CharT __c)β one char at__pvoid insert (size_type __p, const _CharT *__c_string)β a C string at__pvoid insert (size_type __p, const _CharT *__i, const _CharT *__j)β range__ito__jat__pvoid insert (size_type __p, const _CharT *__i, size_type __n)β__nchars from__i, at__pvoid insert (size_type __p, const const_iterator &__i, const const_iterator &__j)βconst_iteratorrange, at__pvoid insert (size_type __p, const iterator &__i, const iterator &__j)βiteratorrange, at__pvoid insert (size_type __p, const rope &__r)β the whole rope__r, at__pvoid insert (size_type __p, size_type __n, _CharT __c)β__ncopies of__c, at__psize_type length () constβ how long is itsize_type max_size () constβ how long could it be, hypotheticallyiterator mutable_begin ()β begin, but mutable, so you can actually change thingsiterator mutable_end ()β mutable end, matching setreverse_iterator mutable_rbegin ()β mutable reverse beginreference mutable_reference_at (size_type __pos)β a mutablereferenceat__pos, yes that proxy typereverse_iterator mutable_rend ()β mutable reverse endrope & operator= (const rope &__x)β assignment,__xgets copied over_CharT operator[] (size_type __pos) constβ index into it at__pos, returns a_CharTvoid pop_back ()β yeet the last charvoid pop_front ()β yeet the first charvoid push_back (_CharT __x)β add__xto the backvoid push_front (_CharT __x)β add__xto the frontconst_reverse_iterator rbegin ()β reverse begin, here we go backwardsconst_reverse_iterator rbegin () constβ reverse begin, constconst_reverse_iterator rend ()β reverse endconst_reverse_iterator rend () constβ reverse end, constvoid replace (const iterator &__p, _CharT __c)β swap what's at__pfor__cvoid replace (const iterator &__p, const _CharT *__c_string)β swap it for a C stringvoid replace (const iterator &__p, const _CharT *__i, const _CharT *__j)β swap it for the range__ito__jvoid replace (const iterator &__p, const _CharT *__i, size_type __n)β swap it for__nchars from__ivoid replace (const iterator &__p, const iterator &__q, _CharT __c)β replace__pthrough__qwith__cvoid replace (const iterator &__p, const iterator &__q, const _CharT *__c_string)β replace that range with a C stringvoid replace (const iterator &__p, const iterator &__q, const _CharT *__i, const _CharT *__j)β replace that range with__ito__jvoid replace (const iterator &__p, const iterator &__q, const _CharT *__i, size_type __n)β replace that range with__nchars from__ivoid replace (const iterator &__p, const iterator &__q, const const_iterator &__i, const const_iterator &__j)β replace that range with aconst_iteratorrangevoid replace (const iterator &__p, const iterator &__q, const iterator &__i, const iterator &__j)β replace that range with aniteratorrangevoid replace (const iterator &__p, const iterator &__q, const rope &__r)β replace that range with a whole rope__rvoid replace (const iterator &__p, const rope &__r)β replace from__pwith a ropevoid replace (const iterator &__p, const_iterator __i, const_iterator __j)β replace from__pwith__ito__jvoid replace (const iterator &__p, iterator __i, iterator __j)β same but the iterators aren't const-ref'd, note the difference bestievoid replace (size_type __p, _CharT __c)β index-based version, swap in__cat__pvoid replace (size_type __p, const _CharT *__c_string)β index-based, C string invoid replace (size_type __p, const _CharT *__i, const _CharT *__j)β index-based, range__ito__jvoid replace (size_type __p, const _CharT *__i, size_type __i_len)β index-based,__i_lenchars 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_iteratorrangevoid replace (size_type __p, const iterator &__i, const iterator &__j)β index-based,iteratorrangevoid replace (size_type __p, const rope &__r)β index-based, whole rope__rvoid replace (size_type __p, size_type __n, _CharT __c)β__nchars at__p, all__cvoid replace (size_type __p, size_type __n, const _CharT *__c_string)β__nchars at__p, C string editionvoid replace (size_type __p, size_type __n, const _CharT *__i, const _CharT *__j)β__nchars at__p, from range__ito__jvoid replace (size_type __p, size_type __n, const _CharT *__i, size_type __i_len)β__nchars at__p, from__i_lenchars of__ivoid replace (size_type __p, size_type __n, const const_iterator &__i, const const_iterator &__j)β__nchars at__p,const_iteratorrangevoid replace (size_type __p, size_type __n, const iterator &__i, const iterator &__j)β__nchars at__p,iteratorrangevoid replace (size_type __p, size_type __n, const rope &__r)β__nchars at__p, filled with rope__rconst _CharT * replace_with_c_str ()β swap the whole thing out for a C string and hand you the pointersize_type size () constβ the size, bestierope< _CharT, _Alloc > substr (const_iterator __start)β a sub-rope from__starton (note: this one saysrope< _CharT, _Alloc >in full, not justrope)rope substr (const_iterator __start, const_iterator __end) constβ sub-rope from__startto__endrope substr (iterator __start) constβ from__start, mutable iterator flavourrope substr (iterator __start, iterator __end) constβ__startto__end, mutable iterator flavourrope substr (size_type __start, size_type __len=1) constβ index-based,__lenlong, and it defaults to1void 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__Cstatic void _C_deallocate (__C *__p, std::size_t __n)β deallocate__Cstatic _CharT * _Data_allocate (std::size_t __n)β allocate raw_CharTdatastatic void _Data_deallocate (_CharT *__p, std::size_t __n)β deallocate that datastatic __F * _F_allocate (std::size_t __n)β allocate for__Fstatic void _F_deallocate (__F *__p, std::size_t __n)β deallocate__Fstatic __L * _L_allocate (std::size_t __n)β allocate for__Lstatic void _L_deallocate (__L *__p, std::size_t __n)β deallocate__Lstatic __S * _S_allocate (std::size_t __n)β allocate for__Sstatic 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 classicnpos, 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_maxtypedef _Rope_base< _CharT, _Alloc > _Baseβ the base class, shortened to_Basetypedef _CharT * _Cstrptrβ a_CharT *, but with a cuter nametypedef _Rope_RopeConcatenation< _CharT, _Alloc > _RopeConcatenationβ the concatenation node, full name this timetypedef _Rope_RopeFunction< _CharT, _Alloc > _RopeFunctionβ the function node, full nametypedef _Rope_RopeLeaf< _CharT, _Alloc > _RopeLeafβ the leaf node, full nametypedef _Rope_RopeRep< _CharT, _Alloc > _RopeRepβ the representation node, full nametypedef _Rope_RopeSubstring< _CharT, _Alloc > _RopeSubstringβ the substring node, full nametypedef _Rope_self_destruct_ptr< _CharT, _Alloc > _Self_destruct_ptrβ a self-destructing pointer, dramatic and usefultypedef _Base::allocator_type allocator_typeβallocator_typeborrowed 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