// <http://www.gnu.org/licenses/>.
/** @file ext/rc_string_base.h
- * This file is a GNU extension to the Standard C++ Library.
* This is an internal header file, included by other library headers.
- * You should not attempt to use it directly.
+ * Do not attempt to use it directly. @headername{ext/vstring.h}
*/
#ifndef _RC_STRING_BASE_H
size_type _M_capacity;
_Atomic_word _M_refcount;
} _M_info;
-
+
// Only for alignment purposes.
_CharT _M_align;
};
__atomic_add_dispatch(&_M_info._M_refcount, 1);
return _M_refdata();
} // XXX MT
-
+
void
_M_set_length(size_type __n)
- {
+ {
_M_info._M_refcount = 0; // One reference.
_M_info._M_length = __n;
// grrr. (per 21.3.4)
_M_grab(const _Alloc& __alloc) const
{
return (!_M_is_leaked() && _M_get_allocator() == __alloc)
- ? _M_rep()->_M_refcopy() : _M_rep()->_M_clone(__alloc);
+ ? _M_rep()->_M_refcopy() : _M_rep()->_M_clone(__alloc);
}
void
// _S_construct_aux is used to implement the 21.3.1 para 15 which
// requires special behaviour if _InIterator is an integral type
template<typename _InIterator>
- static _CharT*
- _S_construct_aux(_InIterator __beg, _InIterator __end,
+ static _CharT*
+ _S_construct_aux(_InIterator __beg, _InIterator __end,
const _Alloc& __a, std::__false_type)
{
- typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
- return _S_construct(__beg, __end, __a, _Tag());
+ typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
+ return _S_construct(__beg, __end, __a, _Tag());
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 438. Ambiguity in the "do the right thing" clause
template<typename _Integer>
- static _CharT*
- _S_construct_aux(_Integer __beg, _Integer __end,
+ static _CharT*
+ _S_construct_aux(_Integer __beg, _Integer __end,
const _Alloc& __a, std::__true_type)
{ return _S_construct_aux_2(static_cast<size_type>(__beg),
__end, __a); }
{ return _S_construct(__req, __c, __a); }
template<typename _InIterator>
- static _CharT*
- _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a)
+ static _CharT*
+ _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a)
{
typedef typename std::__is_integer<_InIterator>::__type _Integral;
return _S_construct_aux(__beg, __end, __a, _Integral());
- }
+ }
// For Input Iterators, used in istreambuf_iterators, etc.
template<typename _InIterator>
- static _CharT*
- _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
+ static _CharT*
+ _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
std::input_iterator_tag);
-
+
// For forward_iterators up to random_access_iterators, used for
// string::iterator, _CharT*, etc.
template<typename _FwdIterator>
- static _CharT*
- _S_construct(_FwdIterator __beg, _FwdIterator __end, const _Alloc& __a,
+ static _CharT*
+ _S_construct(_FwdIterator __beg, _FwdIterator __end, const _Alloc& __a,
std::forward_iterator_tag);
static _CharT*
__rc_string_base(size_type __n, _CharT __c, const _Alloc& __a);
template<typename _InputIterator>
- __rc_string_base(_InputIterator __beg, _InputIterator __end,
+ __rc_string_base(_InputIterator __beg, _InputIterator __end,
const _Alloc& __a);
~__rc_string_base()
- { _M_dispose(); }
+ { _M_dispose(); }
allocator_type&
_M_get_allocator()
void
_M_mutate(size_type __pos, size_type __len1, const _CharT* __s,
size_type __len2);
-
+
void
_M_erase(size_type __pos, size_type __n);
_M_set_sharable();
if (__rcs._M_is_leaked())
__rcs._M_set_sharable();
-
+
_CharT* __tmp = _M_data();
_M_data(__rcs._M_data());
__rcs._M_data(__tmp);
// 431. Swapping containers with unequal allocators.
std::__alloc_swap<allocator_type>::_S_do_it(_M_get_allocator(),
__rcs._M_get_allocator());
- }
+ }
template<typename _CharT, typename _Traits, typename _Alloc>
void
// Make sure we don't shrink below the current size.
if (__res < _M_length())
__res = _M_length();
-
+
if (__res != _M_capacity() || _M_is_shared())
{
_CharT* __tmp = _M_rep()->_M_clone(_M_get_allocator(),
size_type __len2)
{
const size_type __how_much = _M_length() - __pos - __len1;
-
+
_Rep* __r = _Rep::_S_create(_M_length() + __len2 - __len1,
_M_capacity(), _M_get_allocator());
-
+
if (__pos)
_S_copy(__r->_M_refdata(), _M_data(), __pos);
if (__s && __len2)
if (__how_much)
_S_copy(__r->_M_refdata() + __pos + __len2,
_M_data() + __pos + __len1, __how_much);
-
+
_M_dispose();
_M_data(__r->_M_refdata());
}
{
const size_type __new_size = _M_length() - __n;
const size_type __how_much = _M_length() - __pos - __n;
-
+
if (_M_is_shared())
{
// Must reallocate.
_M_data() + __pos + __n, __how_much);
}
- _M_rep()->_M_set_length(__new_size);
+ _M_rep()->_M_set_length(__new_size);
}
template<>