libstdc++: __gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc > Class Template Reference

libstdc++

__gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc > Class Template Reference

`#include <rc_string_base.h>`

Inheritance diagram for __gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >:
[legend]

## Public Types
typedef _Util_Base::_CharT_alloc_type | _CharT_alloc_type
typedef __vstring_utility< _CharT, _Traits, _Alloc > | _Util_Base
typedef _Alloc | allocator_type
typedef _CharT_alloc_type::size_type | size_type
typedef _Traits | traits_type
typedef _Traits::char_type | value_type

## Public Member Functions
| __rc_string_base (__rc_string_base &&__rcs)
template<typename _InputIterator>
| __rc_string_base (_InputIterator __beg, _InputIterator __end, const _Alloc &__a)
| __rc_string_base (const __rc_string_base &__rcs)
| __rc_string_base (const _Alloc &__a)
| __rc_string_base (size_type __n, _CharT __c, const _Alloc &__a)
void | _M_assign (const __rc_string_base &__rcs)
size_type | _M_capacity () const
void | _M_clear ()
bool | _M_compare (const __rc_string_base &) const
bool | _M_compare (const __rc_string_base &__rcs) const
bool | _M_compare (const __rc_string_base &__rcs) const
_CharT * | _M_data () const
void | _M_erase (size_type __pos, size_type __n)
allocator_type & | _M_get_allocator ()
const allocator_type & | _M_get_allocator () const
bool | _M_is_shared () const
void | _M_leak ()
size_type | _M_length () const
size_type | _M_max_size () const
void | _M_mutate (size_type __pos, size_type __len1, const _CharT *__s, size_type __len2)
void | _M_reserve (size_type __res)
void | _M_set_leaked ()
void | _M_set_length (size_type __n)
void | _M_swap (__rc_string_base &__rcs)
template<typename _InIterator>
_CharT * | _S_construct (_InIterator __beg, _InIterator __end, const _Alloc &__a, std::forward_iterator_tag)

## Protected Types
typedef __gnu_cxx::__normal_iterator< const_pointer, __gnu_cxx::__versa_string< _CharT, _Traits, _Alloc, __rc_string_base > > | __const_rc_iterator
typedef __gnu_cxx::__normal_iterator< const_pointer, __gnu_cxx::__versa_string< _CharT, _Traits, _Alloc, __sso_string_base > > | __const_sso_iterator
typedef __gnu_cxx::__normal_iterator< pointer, __gnu_cxx::__versa_string< _CharT, _Traits, _Alloc, __rc_string_base > > | __rc_iterator
typedef __gnu_cxx::__normal_iterator< pointer, __gnu_cxx::__versa_string< _CharT, _Traits, _Alloc, __sso_string_base > > | __sso_iterator
typedef __alloc_traits< _CharT_alloc_type > | _CharT_alloc_traits
typedef _CharT_alloc_traits::const_pointer | const_pointer
typedef _CharT_alloc_type::difference_type | difference_type
typedef _CharT_alloc_traits::pointer | pointer

## Static Protected Member Functions
static void | _S_assign (_CharT *__d, size_type __n, _CharT __c)
static int | _S_compare (size_type __n1, size_type __n2)
static void | _S_copy (_CharT *__d, const _CharT *__s, size_type __n)
static void | _S_copy_chars (_CharT *__p, __const_rc_iterator __k1, __const_rc_iterator __k2)
static void | _S_copy_chars (_CharT *__p, __const_sso_iterator __k1, __const_sso_iterator __k2)
static void | _S_copy_chars (_CharT *__p, __rc_iterator __k1, __rc_iterator __k2)
static void | _S_copy_chars (_CharT *__p, __sso_iterator __k1, __sso_iterator __k2)
static void | _S_copy_chars (_CharT *__p, _CharT *__k1, _CharT *__k2)
template<typename _Iterator>
static void | _S_copy_chars (_CharT *__p, _Iterator __k1, _Iterator __k2)
static void | _S_copy_chars (_CharT *__p, const _CharT *__k1, const _CharT *__k2)
static void | _S_move (_CharT *__d, const _CharT *__s, size_type __n)

## Detailed Description

template<typename _CharT, typename _Traits, typename _Alloc>
class __gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >

Documentation? What's that? Nathan Myers ncm@c.nosp@m.antr.nosp@m.ip.or.nosp@m.g.

A string looks like this:

[_Rep]
_M_length
[__rc_string_base<char_type>] _M_capacity
_M_dataplus _M_refcount
_M_p ----------------> unnamed array of char_type

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_refdata(), and __rc_string_base::_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.

Definition at line 85 of file rc_string_base.h.

## Member Typedef Documentation

## ◆ __const_rc_iterator

template<typename _CharT, typename _Traits, typename _Alloc>

typedef __gnu_cxx:: __normal_iterator<const_pointer, __gnu_cxx:: __versa_string<_CharT, _Traits, _Alloc, __rc_string_base> > __gnu_cxx::__vstring_utility< _CharT, _Traits, _Alloc >::__const_rc_iterator
| inherited

Definition at line 91 of file vstring_util.h.

## ◆ __const_sso_iterator

template<typename _CharT, typename _Traits, typename _Alloc>

typedef __gnu_cxx:: __normal_iterator<const_pointer, __gnu_cxx:: __versa_string<_CharT, _Traits, _Alloc, __sso_string_base> > __gnu_cxx::__vstring_utility< _CharT, _Traits, _Alloc >::__const_sso_iterator
| inherited

Definition at line 79 of file vstring_util.h.

## ◆ __rc_iterator

template<typename _CharT, typename _Traits, typename _Alloc>

typedef __gnu_cxx:: __normal_iterator<pointer, __gnu_cxx:: __versa_string<_CharT, _Traits, _Alloc, __rc_string_base> > __gnu_cxx::__vstring_utility< _CharT, _Traits, _Alloc >::__rc_iterator
| inherited

Definition at line 86 of file vstring_util.h.

## ◆ __sso_iterator

template<typename _CharT, typename _Traits, typename _Alloc>

typedef __gnu_cxx:: __normal_iterator<pointer, __gnu_cxx:: __versa_string<_CharT, _Traits, _Alloc, __sso_string_base> > __gnu_cxx::__vstring_utility< _CharT, _Traits, _Alloc >::__sso_iterator
| inherited

Definition at line 74 of file vstring_util.h.

## ◆ _CharT_alloc_traits

template<typename _CharT, typename _Traits, typename _Alloc>

typedef __alloc_traits<_CharT_alloc_type> __gnu_cxx::__vstring_utility< _CharT, _Traits, _Alloc >::_CharT_alloc_traits
| inherited

Definition at line 60 of file vstring_util.h.

## ◆ _CharT_alloc_type

template<typename _CharT, typename _Traits, typename _Alloc>

typedef _Util_Base::_CharT_alloc_type __gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::_CharT_alloc_type

Definition at line 94 of file rc_string_base.h.

## ◆ _Util_Base

template<typename _CharT, typename _Traits, typename _Alloc>

typedef __vstring_utility<_CharT, _Traits, _Alloc> __gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::_Util_Base

Definition at line 93 of file rc_string_base.h.

## ◆ allocator_type

template<typename _CharT, typename _Traits, typename _Alloc>

typedef _Alloc __gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::allocator_type

Definition at line 91 of file rc_string_base.h.

## ◆ const_pointer

template<typename _CharT, typename _Traits, typename _Alloc>

typedef _CharT_alloc_traits::const_pointer __gnu_cxx::__vstring_utility< _CharT, _Traits, _Alloc >::const_pointer
| inherited

Definition at line 67 of file vstring_util.h.

## ◆ difference_type

template<typename _CharT, typename _Traits, typename _Alloc>

typedef _CharT_alloc_type::difference_type __gnu_cxx::__vstring_utility< _CharT, _Traits, _Alloc >::difference_type
| inherited

Definition at line 65 of file vstring_util.h.

## ◆ pointer

template<typename _CharT, typename _Traits, typename _Alloc>

typedef _CharT_alloc_traits::pointer __gnu_cxx::__vstring_utility< _CharT, _Traits, _Alloc >::pointer
| inherited

Definition at line 66 of file vstring_util.h.

## ◆ size_type

template<typename _CharT, typename _Traits, typename _Alloc>

typedef _CharT_alloc_type::size_type __gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::size_type

Definition at line 95 of file rc_string_base.h.

## ◆ traits_type

template<typename _CharT, typename _Traits, typename _Alloc>

typedef _Traits __gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::traits_type

Definition at line 89 of file rc_string_base.h.

## ◆ value_type

template<typename _CharT, typename _Traits, typename _Alloc>

typedef _Traits::char_type __gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::value_type

Definition at line 90 of file rc_string_base.h.

## Constructor & Destructor Documentation

## ◆ __rc_string_base() [1/6]

template<typename _CharT, typename _Traits, typename _Alloc>

__gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::__rc_string_base | ( |  | ) |
| inline

Definition at line 314 of file rc_string_base.h.

## ◆ __rc_string_base() [2/6]

template<typename _CharT, typename _Traits, typename _Alloc>

__gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::__rc_string_base | ( | const _Alloc & | __a | ) |

Definition at line 478 of file rc_string_base.h.

## ◆ __rc_string_base() [3/6]

template<typename _CharT, typename _Traits, typename _Alloc>

__gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::__rc_string_base | ( | const __rc_string_base< _CharT, _Traits, _Alloc > & | __rcs | ) |

Definition at line 483 of file rc_string_base.h.

## ◆ __rc_string_base() [4/6]

template<typename _CharT, typename _Traits, typename _Alloc>

__gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::__rc_string_base | ( | __rc_string_base< _CharT, _Traits, _Alloc > && | __rcs | ) |
| inline

Definition at line 322 of file rc_string_base.h.

## ◆ __rc_string_base() [5/6]

template<typename _CharT, typename _Traits, typename _Alloc>

__gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::__rc_string_base | ( | size_type | __n,
|  | _CharT | __c,
|  | const _Alloc & | __a )

Definition at line 489 of file rc_string_base.h.

## ◆ __rc_string_base() [6/6]

template<typename _CharT, typename _Traits, typename _Alloc>
template<typename _InputIterator>

__gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::__rc_string_base | ( | _InputIterator | __beg,
|  | _InputIterator | __end,
|  | const _Alloc & | __a )

Definition at line 495 of file rc_string_base.h.

## ◆ ~__rc_string_base()

template<typename _CharT, typename _Traits, typename _Alloc>

__gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::~__rc_string_base | ( |  | ) |
| inline

Definition at line 333 of file rc_string_base.h.

## Member Function Documentation

## ◆ _M_assign()

template<typename _CharT, typename _Traits, typename _Alloc>

void __gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::_M_assign | ( | const __rc_string_base< _CharT, _Traits, _Alloc > & | __rcs | ) |

Definition at line 628 of file rc_string_base.h.

## ◆ _M_capacity()

template<typename _CharT, typename _Traits, typename _Alloc>

size_type __gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::_M_capacity | ( |  | ) | const
| inline

Definition at line 292 of file rc_string_base.h.

## ◆ _M_clear()

template<typename _CharT, typename _Traits, typename _Alloc>

void __gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::_M_clear | ( |  | ) |
| inline

Definition at line 361 of file rc_string_base.h.

## ◆ _M_compare() [1/3]

template<typename _CharT, typename _Traits, typename _Alloc>

bool __gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::_M_compare | ( | const __rc_string_base< _CharT, _Traits, _Alloc > & |  | ) | const
| inline

Definition at line 368 of file rc_string_base.h.

## ◆ _M_compare() [2/3]

bool __gnu_cxx::__rc_string_base< char, std::char_traits< char >, std::allocator< char > >::_M_compare | ( | const __rc_string_base< _CharT, _Traits, _Alloc > & | __rcs | ) | const
| inline

Definition at line 716 of file rc_string_base.h.

## ◆ _M_compare() [3/3]

bool __gnu_cxx::__rc_string_base< wchar_t, std::char_traits< wchar_t >, std::allocator< wchar_t > >::_M_compare | ( | const __rc_string_base< _CharT, _Traits, _Alloc > & | __rcs | ) | const
| inline

Definition at line 727 of file rc_string_base.h.

## ◆ _M_data()

template<typename _CharT, typename _Traits, typename _Alloc>

_CharT * __gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::_M_data | ( |  | ) | const
| inline

Definition at line 284 of file rc_string_base.h.

## ◆ _M_erase()

template<typename _CharT, typename _Traits, typename _Alloc>

void __gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::_M_erase | ( | size_type | __pos,
|  | size_type | __n )

Definition at line 682 of file rc_string_base.h.

## ◆ _M_get_allocator() [1/2]

template<typename _CharT, typename _Traits, typename _Alloc>

allocator_type & __gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::_M_get_allocator | ( |  | ) |
| inline

Definition at line 337 of file rc_string_base.h.

## ◆ _M_get_allocator() [2/2]

template<typename _CharT, typename _Traits, typename _Alloc>

const allocator_type & __gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::_M_get_allocator | ( |  | ) | const
| inline

Definition at line 341 of file rc_string_base.h.

## ◆ _M_is_shared()

template<typename _CharT, typename _Traits, typename _Alloc>

bool __gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::_M_is_shared | ( |  | ) | const
| inline

Definition at line 296 of file rc_string_base.h.

## ◆ _M_leak()

template<typename _CharT, typename _Traits, typename _Alloc>

void __gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::_M_leak | ( |  | ) |
| inline

Definition at line 304 of file rc_string_base.h.

## ◆ _M_length()

template<typename _CharT, typename _Traits, typename _Alloc>

size_type __gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::_M_length | ( |  | ) | const
| inline

Definition at line 288 of file rc_string_base.h.

## ◆ _M_max_size()

template<typename _CharT, typename _Traits, typename _Alloc>

size_type __gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::_M_max_size | ( |  | ) | const
| inline

Definition at line 280 of file rc_string_base.h.

## ◆ _M_mutate()

template<typename _CharT, typename _Traits, typename _Alloc>

void __gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::_M_mutate | ( | size_type | __pos,
|  | size_type | __len1,
|  | const _CharT * | __s,
|  | size_type | __len2 )

Definition at line 659 of file rc_string_base.h.

## ◆ _M_reserve()

template<typename _CharT, typename _Traits, typename _Alloc>

void __gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::_M_reserve | ( | size_type | __res | ) |

Definition at line 641 of file rc_string_base.h.

## ◆ _M_set_leaked()

template<typename _CharT, typename _Traits, typename _Alloc>

void __gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::_M_set_leaked | ( |  | ) |
| inline

Definition at line 300 of file rc_string_base.h.

## ◆ _M_set_length()

template<typename _CharT, typename _Traits, typename _Alloc>

void __gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::_M_set_length | ( | size_type | __n | ) |
| inline

Definition at line 311 of file rc_string_base.h.

## ◆ _M_swap()

template<typename _CharT, typename _Traits, typename _Alloc>

void __gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::_M_swap | ( | __rc_string_base< _CharT, _Traits, _Alloc > & | __rcs | ) |

Definition at line 608 of file rc_string_base.h.

## ◆ _S_assign()

template<typename _CharT, typename _Traits, typename _Alloc>

void __gnu_cxx::__vstring_utility< _CharT, _Traits, _Alloc >::_S_assign | ( | _CharT * | __d,
|  | size_type | __n,
|  | _CharT | __c )
| inlinestaticinherited

Definition at line 129 of file vstring_util.h.

## ◆ _S_compare()

template<typename _CharT, typename _Traits, typename _Alloc>

int __gnu_cxx::__vstring_utility< _CharT, _Traits, _Alloc >::_S_compare | ( | size_type | __n1,
|  | size_type | __n2 )
| inlinestaticinherited

Definition at line 174 of file vstring_util.h.

## ◆ _S_construct()

template<typename _CharT, typename _Traits, typename _Alloc>
template<typename _InIterator>

_CharT * __gnu_cxx::__rc_string_base< _CharT, _Traits, _Alloc >::_S_construct | ( | _InIterator | __beg,
|  | _InIterator | __end,
|  | const _Alloc & | __a,
|  | std::forward_iterator_tag | )

Definition at line 562 of file rc_string_base.h.

## ◆ _S_copy()

template<typename _CharT, typename _Traits, typename _Alloc>

void __gnu_cxx::__vstring_utility< _CharT, _Traits, _Alloc >::_S_copy | ( | _CharT * | __d,
|  | const _CharT * | __s,
|  | size_type | __n )
| inlinestaticinherited

Definition at line 111 of file vstring_util.h.

## ◆ _S_copy_chars() [1/7]

template<typename _CharT, typename _Traits, typename _Alloc>

void __gnu_cxx::__vstring_utility< _CharT, _Traits, _Alloc >::_S_copy_chars | ( | _CharT * | __p,
|  | __const_rc_iterator | __k1,
|  | __const_rc_iterator | __k2 )
| inlinestaticinherited

Definition at line 161 of file vstring_util.h.

## ◆ _S_copy_chars() [2/7]

template<typename _CharT, typename _Traits, typename _Alloc>

void __gnu_cxx::__vstring_utility< _CharT, _Traits, _Alloc >::_S_copy_chars | ( | _CharT * | __p,
|  | __const_sso_iterator | __k1,
|  | __const_sso_iterator | __k2 )
| inlinestaticinherited

Definition at line 152 of file vstring_util.h.

## ◆ _S_copy_chars() [3/7]

template<typename _CharT, typename _Traits, typename _Alloc>

void __gnu_cxx::__vstring_utility< _CharT, _Traits, _Alloc >::_S_copy_chars | ( | _CharT * | __p,
|  | __rc_iterator | __k1,
|  | __rc_iterator | __k2 )
| inlinestaticinherited

Definition at line 157 of file vstring_util.h.

## ◆ _S_copy_chars() [4/7]

template<typename _CharT, typename _Traits, typename _Alloc>

void __gnu_cxx::__vstring_utility< _CharT, _Traits, _Alloc >::_S_copy_chars | ( | _CharT * | __p,
|  | __sso_iterator | __k1,
|  | __sso_iterator | __k2 )
| inlinestaticinherited

Definition at line 148 of file vstring_util.h.

## ◆ _S_copy_chars() [5/7]

template<typename _CharT, typename _Traits, typename _Alloc>

void __gnu_cxx::__vstring_utility< _CharT, _Traits, _Alloc >::_S_copy_chars | ( | _CharT * | __p,
|  | _CharT * | __k1,
|  | _CharT * | __k2 )
| inlinestaticinherited

Definition at line 166 of file vstring_util.h.

## ◆ _S_copy_chars() [6/7]

template<typename _CharT, typename _Traits, typename _Alloc>
template<typename _Iterator>

void __gnu_cxx::__vstring_utility< _CharT, _Traits, _Alloc >::_S_copy_chars | ( | _CharT * | __p,
|  | _Iterator | __k1,
|  | _Iterator | __k2 )
| inlinestaticinherited

Definition at line 141 of file vstring_util.h.

## ◆ _S_copy_chars() [7/7]

template<typename _CharT, typename _Traits, typename _Alloc>

void __gnu_cxx::__vstring_utility< _CharT, _Traits, _Alloc >::_S_copy_chars | ( | _CharT * | __p,
|  | const _CharT * | __k1,
|  | const _CharT * | __k2 )
| inlinestaticinherited

Definition at line 170 of file vstring_util.h.

## ◆ _S_move()

template<typename _CharT, typename _Traits, typename _Alloc>

void __gnu_cxx::__vstring_utility< _CharT, _Traits, _Alloc >::_S_move | ( | _CharT * | __d,
|  | const _CharT * | __s,
|  | size_type | __n )
| inlinestaticinherited

Definition at line 120 of file vstring_util.h.

The documentation for this class was generated from the following file:

- rc_string_base.h