46 #pragma GCC system_header
55 #include <bits/gthr.h>
57 #include <tr1/functional>
60 # define __GC_CONST const
62 # define __GC_CONST // constant except for deallocation
67 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
69 _GLIBCXX_BEGIN_NAMESPACE_VERSION
73 enum { _S_max_rope_depth = 45 };
74 enum _Tag {_S_leaf, _S_concat, _S_substringfn, _S_function};
78 template<
typename _ForwardIterator,
typename _Allocator>
80 _Destroy_const(_ForwardIterator __first,
81 _ForwardIterator __last, _Allocator __alloc)
83 for (; __first != __last; ++__first)
84 __alloc.destroy(&*__first);
87 template<
typename _ForwardIterator,
typename _Tp>
89 _Destroy_const(_ForwardIterator __first,
98 template <
class _CharT>
105 template <
class _CharT>
107 _S_is_basic_char_type(_CharT*)
110 template <
class _CharT>
112 _S_is_one_byte_char_type(_CharT*)
116 _S_is_basic_char_type(
char*)
120 _S_is_one_byte_char_type(
char*)
124 _S_is_basic_char_type(
wchar_t*)
129 template <
class _CharT>
131 _S_cond_store_eos(_CharT&) { }
134 _S_cond_store_eos(
char& __c)
138 _S_cond_store_eos(
wchar_t& __c)
145 template <
class _CharT>
149 virtual ~char_producer() { }
152 operator()(std::size_t __start_pos, std::size_t __len,
153 _CharT* __buffer) = 0;
174 template<
class _Sequence, std::
size_t _Buf_sz = 100>
175 class sequence_buffer
176 :
public std::iterator<std::output_iterator_tag, void, void, void, void>
179 typedef typename _Sequence::value_type value_type;
181 _Sequence* _M_prefix;
182 value_type _M_buffer[_Buf_sz];
183 std::size_t _M_buf_count;
189 _M_prefix->append(_M_buffer, _M_buffer + _M_buf_count);
197 : _M_prefix(0), _M_buf_count(0) { }
199 sequence_buffer(
const sequence_buffer& __x)
201 _M_prefix = __x._M_prefix;
202 _M_buf_count = __x._M_buf_count;
203 std::copy(__x._M_buffer, __x._M_buffer + __x._M_buf_count, _M_buffer);
206 sequence_buffer(sequence_buffer& __x)
209 _M_prefix = __x._M_prefix;
213 sequence_buffer(_Sequence& __s)
214 : _M_prefix(&__s), _M_buf_count(0) { }
220 _M_prefix = __x._M_prefix;
228 _M_prefix = __x._M_prefix;
229 _M_buf_count = __x._M_buf_count;
230 std::copy(__x._M_buffer, __x._M_buffer + __x._M_buf_count, _M_buffer);
235 push_back(value_type __x)
237 if (_M_buf_count < _Buf_sz)
239 _M_buffer[_M_buf_count] = __x;
251 append(value_type* __s, std::size_t __len)
253 if (__len + _M_buf_count <= _Buf_sz)
255 std::size_t __i = _M_buf_count;
256 for (std::size_t __j = 0; __j < __len; __i++, __j++)
257 _M_buffer[__i] = __s[__j];
258 _M_buf_count += __len;
260 else if (0 == _M_buf_count)
261 _M_prefix->append(__s, __s + __len);
270 write(value_type* __s, std::size_t __len)
304 template<
class _CharT>
305 class _Rope_char_consumer
313 virtual ~_Rope_char_consumer() { }
316 operator()(
const _CharT* __buffer, std::size_t __len) = 0;
322 template<
class _CharT,
class _Alloc = std::allocator<_CharT> >
325 template<
class _CharT,
class _Alloc>
326 struct _Rope_RopeConcatenation;
328 template<
class _CharT,
class _Alloc>
329 struct _Rope_RopeLeaf;
331 template<
class _CharT,
class _Alloc>
332 struct _Rope_RopeFunction;
334 template<
class _CharT,
class _Alloc>
335 struct _Rope_RopeSubstring;
337 template<
class _CharT,
class _Alloc>
338 class _Rope_iterator;
340 template<
class _CharT,
class _Alloc>
341 class _Rope_const_iterator;
343 template<
class _CharT,
class _Alloc>
344 class _Rope_char_ref_proxy;
346 template<
class _CharT,
class _Alloc>
347 class _Rope_char_ptr_proxy;
349 template<
class _CharT,
class _Alloc>
351 operator==(
const _Rope_char_ptr_proxy<_CharT, _Alloc>& __x,
352 const _Rope_char_ptr_proxy<_CharT, _Alloc>& __y);
354 template<
class _CharT,
class _Alloc>
355 _Rope_const_iterator<_CharT, _Alloc>
356 operator-(
const _Rope_const_iterator<_CharT, _Alloc>& __x,
359 template<
class _CharT,
class _Alloc>
360 _Rope_const_iterator<_CharT, _Alloc>
361 operator+(
const _Rope_const_iterator<_CharT, _Alloc>& __x,
364 template<
class _CharT,
class _Alloc>
365 _Rope_const_iterator<_CharT, _Alloc>
367 const _Rope_const_iterator<_CharT, _Alloc>& __x);
369 template<
class _CharT,
class _Alloc>
371 operator==(
const _Rope_const_iterator<_CharT, _Alloc>& __x,
372 const _Rope_const_iterator<_CharT, _Alloc>& __y);
374 template<
class _CharT,
class _Alloc>
376 operator<(const _Rope_const_iterator<_CharT, _Alloc>& __x,
377 const _Rope_const_iterator<_CharT, _Alloc>& __y);
379 template<
class _CharT,
class _Alloc>
381 operator-(
const _Rope_const_iterator<_CharT, _Alloc>& __x,
382 const _Rope_const_iterator<_CharT, _Alloc>& __y);
384 template<
class _CharT,
class _Alloc>
385 _Rope_iterator<_CharT, _Alloc>
386 operator-(
const _Rope_iterator<_CharT, _Alloc>& __x, std::ptrdiff_t __n);
388 template<
class _CharT,
class _Alloc>
389 _Rope_iterator<_CharT, _Alloc>
390 operator+(
const _Rope_iterator<_CharT, _Alloc>& __x, std::ptrdiff_t __n);
392 template<
class _CharT,
class _Alloc>
393 _Rope_iterator<_CharT, _Alloc>
394 operator+(std::ptrdiff_t __n,
const _Rope_iterator<_CharT, _Alloc>& __x);
396 template<
class _CharT,
class _Alloc>
398 operator==(
const _Rope_iterator<_CharT, _Alloc>& __x,
399 const _Rope_iterator<_CharT, _Alloc>& __y);
401 template<
class _CharT,
class _Alloc>
403 operator<(const _Rope_iterator<_CharT, _Alloc>& __x,
404 const _Rope_iterator<_CharT, _Alloc>& __y);
406 template<
class _CharT,
class _Alloc>
408 operator-(
const _Rope_iterator<_CharT, _Alloc>& __x,
409 const _Rope_iterator<_CharT, _Alloc>& __y);
411 template<
class _CharT,
class _Alloc>
416 template<
class _CharT,
class _Alloc>
420 template<
class _CharT,
class _Alloc>
429 template<
class _CharT,
class _Alloc>
430 struct _Rope_Concat_fn
432 rope<_CharT, _Alloc> >
437 {
return __x + __y; }
440 template <
class _CharT,
class _Alloc>
441 inline rope<_CharT, _Alloc>
442 identity_element(_Rope_Concat_fn<_CharT, _Alloc>)
443 {
return rope<_CharT, _Alloc>(); }
449 struct _Refcount_Base
452 typedef std::size_t _RC_t;
458 #ifdef __GTHREAD_MUTEX_INIT
459 __gthread_mutex_t _M_ref_count_lock = __GTHREAD_MUTEX_INIT;
461 __gthread_mutex_t _M_ref_count_lock;
464 _Refcount_Base(_RC_t __n) : _M_ref_count(__n)
466 #ifndef __GTHREAD_MUTEX_INIT
467 #ifdef __GTHREAD_MUTEX_INIT_FUNCTION
468 __GTHREAD_MUTEX_INIT_FUNCTION (&_M_ref_count_lock);
470 #error __GTHREAD_MUTEX_INIT or __GTHREAD_MUTEX_INIT_FUNCTION should be defined by gthr.h abstraction layer, report problem to libstdc++@gcc.gnu.org.
475 #ifndef __GTHREAD_MUTEX_INIT
477 { __gthread_mutex_destroy(&_M_ref_count_lock); }
483 __gthread_mutex_lock(&_M_ref_count_lock);
485 __gthread_mutex_unlock(&_M_ref_count_lock);
491 __gthread_mutex_lock(&_M_ref_count_lock);
492 _RC_t __tmp = --_M_ref_count;
493 __gthread_mutex_unlock(&_M_ref_count_lock);
523 #define __ROPE_DEFINE_ALLOCS(__a) \
524 __ROPE_DEFINE_ALLOC(_CharT,_Data) \
525 typedef _Rope_RopeConcatenation<_CharT,__a> __C; \
526 __ROPE_DEFINE_ALLOC(__C,_C) \
527 typedef _Rope_RopeLeaf<_CharT,__a> __L; \
528 __ROPE_DEFINE_ALLOC(__L,_L) \
529 typedef _Rope_RopeFunction<_CharT,__a> __F; \
530 __ROPE_DEFINE_ALLOC(__F,_F) \
531 typedef _Rope_RopeSubstring<_CharT,__a> __S; \
532 __ROPE_DEFINE_ALLOC(__S,_S)
541 #define __STATIC_IF_SGI_ALLOC
543 template <
class _CharT,
class _Alloc>
544 struct _Rope_rep_base
547 typedef std::size_t size_type;
548 typedef _Alloc allocator_type;
551 get_allocator()
const
552 {
return *
static_cast<const _Alloc*
>(
this); }
556 {
return *
static_cast<_Alloc*
>(
this); }
558 const allocator_type&
559 _M_get_allocator()
const
560 {
return *
static_cast<const _Alloc*
>(
this); }
562 _Rope_rep_base(size_type __size,
const allocator_type&)
563 : _M_size(__size) { }
567 # define __ROPE_DEFINE_ALLOC(_Tp, __name) \
569 __alloc_traits<_Alloc>::template rebind<_Tp>::other __name##Alloc; \
570 static _Tp* __name##_allocate(size_type __n) \
571 { return __name##Alloc().allocate(__n); } \
572 static void __name##_deallocate(_Tp *__p, size_type __n) \
573 { __name##Alloc().deallocate(__p, __n); }
574 __ROPE_DEFINE_ALLOCS(_Alloc)
575 # undef __ROPE_DEFINE_ALLOC
578 template<
class _CharT,
class _Alloc>
580 :
public _Rope_rep_base<_CharT, _Alloc>
586 __detail::_Tag _M_tag:8;
587 bool _M_is_balanced:8;
588 unsigned char _M_depth;
589 __GC_CONST _CharT* _M_c_string;
590 #ifdef __GTHREAD_MUTEX_INIT
591 __gthread_mutex_t _M_c_string_lock = __GTHREAD_MUTEX_INIT;
593 __gthread_mutex_t _M_c_string_lock;
601 typedef typename _Rope_rep_base<_CharT, _Alloc>::allocator_type
603 typedef std::size_t size_type;
605 using _Rope_rep_base<_CharT, _Alloc>::get_allocator;
606 using _Rope_rep_base<_CharT, _Alloc>::_M_get_allocator;
608 _Rope_RopeRep(__detail::_Tag __t,
int __d,
bool __b, size_type __size,
609 const allocator_type& __a)
610 : _Rope_rep_base<_CharT, _Alloc>(__size, __a),
614 _M_tag(__t), _M_is_balanced(__b), _M_depth(__d), _M_c_string(0)
615 #ifdef __GTHREAD_MUTEX_INIT
618 { __GTHREAD_MUTEX_INIT_FUNCTION (&_M_c_string_lock); }
620 { __gthread_mutex_destroy (&_M_c_string_lock); }
627 _S_free_string(__GC_CONST _CharT*, size_type __len,
628 allocator_type& __a);
629 #define __STL_FREE_STRING(__s, __l, __a) _S_free_string(__s, __l, __a);
637 void _M_free_c_string();
652 _S_unref(_Rope_RopeRep* __t)
655 __t->_M_unref_nonnil();
659 _S_ref(_Rope_RopeRep* __t)
666 _S_free_if_unref(_Rope_RopeRep* __t)
668 if (0 != __t && 0 == __t->_M_ref_count)
672 void _M_unref_nonnil() { }
673 void _M_ref_nonnil() { }
674 static void _S_unref(_Rope_RopeRep*) { }
675 static void _S_ref(_Rope_RopeRep*) { }
676 static void _S_free_if_unref(_Rope_RopeRep*) { }
682 _Rope_RopeRep(
const _Rope_RopeRep&);
685 template<
class _CharT,
class _Alloc>
686 struct _Rope_RopeLeaf
687 :
public _Rope_RopeRep<_CharT, _Alloc>
689 typedef std::size_t size_type;
695 enum { _S_alloc_granularity = 8 };
698 _S_rounded_up_size(size_type __n)
700 size_type __size_with_eos;
702 if (_S_is_basic_char_type((_CharT*)0))
703 __size_with_eos = __n + 1;
705 __size_with_eos = __n;
707 return __size_with_eos;
710 return ((__size_with_eos + size_type(_S_alloc_granularity) - 1)
711 &~ (size_type(_S_alloc_granularity) - 1));
714 __GC_CONST _CharT* _M_data;
719 typedef typename _Rope_rep_base<_CharT,_Alloc>::allocator_type
722 _Rope_RopeLeaf(__GC_CONST _CharT* __d, size_type __size,
723 const allocator_type& __a)
724 : _Rope_RopeRep<_CharT, _Alloc>(__detail::_S_leaf, 0, true,
725 __size, __a), _M_data(__d)
727 if (_S_is_basic_char_type((_CharT *)0))
730 this->_M_c_string = __d;
737 ~_Rope_RopeLeaf() throw()
739 if (_M_data != this->_M_c_string)
740 this->_M_free_c_string();
742 this->__STL_FREE_STRING(_M_data, this->_M_size, this->_M_get_allocator());
749 _Rope_RopeLeaf(
const _Rope_RopeLeaf&);
752 template<
class _CharT,
class _Alloc>
753 struct _Rope_RopeConcatenation
754 :
public _Rope_RopeRep<_CharT, _Alloc>
757 _Rope_RopeRep<_CharT, _Alloc>* _M_left;
758 _Rope_RopeRep<_CharT, _Alloc>* _M_right;
760 typedef typename _Rope_rep_base<_CharT, _Alloc>::allocator_type
763 _Rope_RopeConcatenation(_Rope_RopeRep<_CharT, _Alloc>* __l,
764 _Rope_RopeRep<_CharT, _Alloc>* __r,
765 const allocator_type& __a)
766 : _Rope_RopeRep<_CharT, _Alloc>(__detail::_S_concat,
767 std::
max(__l->_M_depth,
770 __l->_M_size + __r->_M_size, __a),
771 _M_left(__l), _M_right(__r)
774 ~_Rope_RopeConcatenation() throw()
776 this->_M_free_c_string();
777 _M_left->_M_unref_nonnil();
778 _M_right->_M_unref_nonnil();
782 _Rope_RopeConcatenation&
783 operator=(
const _Rope_RopeConcatenation&);
785 _Rope_RopeConcatenation(
const _Rope_RopeConcatenation&);
788 template<
class _CharT,
class _Alloc>
789 struct _Rope_RopeFunction
790 :
public _Rope_RopeRep<_CharT, _Alloc>
793 char_producer<_CharT>* _M_fn;
795 bool _M_delete_when_done;
806 _S_fn_finalization_proc(
void * __tree,
void *)
807 {
delete ((_Rope_RopeFunction *)__tree) -> _M_fn; }
809 typedef typename _Rope_rep_base<_CharT, _Alloc>::allocator_type
812 _Rope_RopeFunction(char_producer<_CharT>* __f, std::size_t __size,
813 bool __d,
const allocator_type& __a)
814 : _Rope_RopeRep<_CharT, _Alloc>(__detail::_S_function, 0, true, __size, __a)
817 , _M_delete_when_done(__d)
823 GC_REGISTER_FINALIZER(
this, _Rope_RopeFunction::
824 _S_fn_finalization_proc, 0, 0, 0);
829 ~_Rope_RopeFunction() throw()
831 this->_M_free_c_string();
832 if (_M_delete_when_done)
840 _Rope_RopeFunction(
const _Rope_RopeFunction&);
849 template<
class _CharT,
class _Alloc>
850 struct _Rope_RopeSubstring
851 :
public _Rope_RopeFunction<_CharT, _Alloc>,
852 public char_producer<_CharT>
854 typedef std::size_t size_type;
857 _Rope_RopeRep<_CharT,_Alloc>* _M_base;
861 operator()(size_type __start_pos, size_type __req_len,
864 switch(_M_base->_M_tag)
866 case __detail::_S_function:
867 case __detail::_S_substringfn:
869 char_producer<_CharT>* __fn =
870 ((_Rope_RopeFunction<_CharT,_Alloc>*)_M_base)->_M_fn;
871 (*__fn)(__start_pos + _M_start, __req_len, __buffer);
874 case __detail::_S_leaf:
876 __GC_CONST _CharT* __s =
877 ((_Rope_RopeLeaf<_CharT,_Alloc>*)_M_base)->_M_data;
887 typedef typename _Rope_rep_base<_CharT, _Alloc>::allocator_type
890 _Rope_RopeSubstring(_Rope_RopeRep<_CharT, _Alloc>* __b, size_type __s,
891 size_type __l,
const allocator_type& __a)
892 : _Rope_RopeFunction<_CharT, _Alloc>(this, __l, false, __a),
893 char_producer<_CharT>(), _M_base(__b), _M_start(__s)
896 _M_base->_M_ref_nonnil();
898 this->_M_tag = __detail::_S_substringfn;
900 virtual ~_Rope_RopeSubstring() throw()
903 _M_base->_M_unref_nonnil();
919 template<
class _CharT,
class _Alloc>
920 struct _Rope_self_destruct_ptr
922 _Rope_RopeRep<_CharT, _Alloc>* _M_ptr;
924 ~_Rope_self_destruct_ptr()
925 { _Rope_RopeRep<_CharT, _Alloc>::_S_unref(_M_ptr); }
927 _Rope_self_destruct_ptr() : _M_ptr(0) { }
929 _Rope_self_destruct_ptr() { }
931 _Rope_self_destruct_ptr(_Rope_RopeRep<_CharT, _Alloc>* __p)
934 _Rope_RopeRep<_CharT, _Alloc>&
938 _Rope_RopeRep<_CharT, _Alloc>*
942 operator _Rope_RopeRep<_CharT, _Alloc>*()
945 _Rope_self_destruct_ptr&
946 operator=(_Rope_RopeRep<_CharT, _Alloc>* __x)
947 { _M_ptr = __x;
return *
this; }
956 template<
class _CharT,
class _Alloc>
957 class _Rope_char_ref_proxy
959 friend class rope<_CharT, _Alloc>;
960 friend class _Rope_iterator<_CharT, _Alloc>;
961 friend class _Rope_char_ptr_proxy<_CharT, _Alloc>;
963 typedef _Rope_RopeRep<_CharT, _Alloc>* _Self_destruct_ptr;
965 typedef _Rope_self_destruct_ptr<_CharT, _Alloc> _Self_destruct_ptr;
967 typedef _Rope_RopeRep<_CharT, _Alloc> _RopeRep;
968 typedef rope<_CharT, _Alloc> _My_rope;
971 bool _M_current_valid;
974 _Rope_char_ref_proxy(_My_rope* __r, std::size_t __p)
975 : _M_pos(__p), _M_current(), _M_current_valid(false), _M_root(__r) { }
977 _Rope_char_ref_proxy(
const _Rope_char_ref_proxy& __x)
978 : _M_pos(__x._M_pos), _M_current(__x._M_current),
979 _M_current_valid(false), _M_root(__x._M_root) { }
985 _Rope_char_ref_proxy(_My_rope* __r, std::size_t __p, _CharT __c)
986 : _M_pos(__p), _M_current(__c), _M_current_valid(true), _M_root(__r) { }
988 inline operator _CharT ()
const;
990 _Rope_char_ref_proxy&
993 _Rope_char_ptr_proxy<_CharT, _Alloc>
operator&()
const;
995 _Rope_char_ref_proxy&
996 operator=(
const _Rope_char_ref_proxy& __c)
1000 template<
class _CharT,
class __Alloc>
1002 swap(_Rope_char_ref_proxy <_CharT, __Alloc > __a,
1003 _Rope_char_ref_proxy <_CharT, __Alloc > __b)
1010 template<
class _CharT,
class _Alloc>
1011 class _Rope_char_ptr_proxy
1014 friend class _Rope_char_ref_proxy<_CharT, _Alloc>;
1016 rope<_CharT,_Alloc>* _M_root;
1018 _Rope_char_ptr_proxy(
const _Rope_char_ref_proxy<_CharT,_Alloc>& __x)
1019 : _M_pos(__x._M_pos), _M_root(__x._M_root) { }
1021 _Rope_char_ptr_proxy(
const _Rope_char_ptr_proxy& __x)
1022 : _M_pos(__x._M_pos), _M_root(__x._M_root) { }
1024 _Rope_char_ptr_proxy() { }
1026 _Rope_char_ptr_proxy(_CharT* __x)
1027 : _M_root(0), _M_pos(0) { }
1029 _Rope_char_ptr_proxy&
1030 operator=(
const _Rope_char_ptr_proxy& __x)
1032 _M_pos = __x._M_pos;
1033 _M_root = __x._M_root;
1037 template<
class _CharT2,
class _Alloc2>
1039 operator==(
const _Rope_char_ptr_proxy<_CharT2, _Alloc2>& __x,
1040 const _Rope_char_ptr_proxy<_CharT2, _Alloc2>& __y);
1042 _Rope_char_ref_proxy<_CharT, _Alloc>
operator*()
const
1043 {
return _Rope_char_ref_proxy<_CharT, _Alloc>(_M_root, _M_pos); }
1055 template<
class _CharT,
class _Alloc>
1056 class _Rope_iterator_base
1057 :
public std::iterator<std::random_access_iterator_tag, _CharT>
1059 friend class rope<_CharT, _Alloc>;
1061 typedef _Alloc _allocator_type;
1062 typedef _Rope_RopeRep<_CharT, _Alloc> _RopeRep;
1065 enum { _S_path_cache_len = 4 };
1066 enum { _S_iterator_buf_len = 15 };
1067 std::size_t _M_current_pos;
1069 std::size_t _M_leaf_pos;
1070 __GC_CONST _CharT* _M_buf_start;
1073 __GC_CONST _CharT* _M_buf_ptr;
1076 __GC_CONST _CharT* _M_buf_end;
1082 const _RopeRep* _M_path_end[_S_path_cache_len];
1086 unsigned char _M_path_directions;
1091 _CharT _M_tmp_buf[_S_iterator_buf_len];
1099 static void _S_setbuf(_Rope_iterator_base& __x);
1102 static void _S_setcache(_Rope_iterator_base& __x);
1105 static void _S_setcache_for_incr(_Rope_iterator_base& __x);
1108 _Rope_iterator_base() { }
1110 _Rope_iterator_base(_RopeRep* __root, std::size_t __pos)
1111 : _M_current_pos(__pos), _M_root(__root), _M_buf_ptr(0) { }
1113 void _M_incr(std::size_t __n);
1114 void _M_decr(std::size_t __n);
1118 {
return _M_current_pos; }
1120 _Rope_iterator_base(
const _Rope_iterator_base& __x)
1122 if (0 != __x._M_buf_ptr && __x._M_buf_start != __x._M_tmp_buf)
1126 _M_current_pos = __x._M_current_pos;
1127 _M_root = __x._M_root;
1133 template<
class _CharT,
class _Alloc>
1134 class _Rope_iterator;
1136 template<
class _CharT,
class _Alloc>
1137 class _Rope_const_iterator
1138 :
public _Rope_iterator_base<_CharT, _Alloc>
1140 friend class rope<_CharT, _Alloc>;
1142 typedef _Rope_RopeRep<_CharT, _Alloc> _RopeRep;
1144 _Rope_const_iterator(
const _RopeRep* __root, std::size_t __pos)
1145 : _Rope_iterator_base<_CharT, _Alloc>(const_cast<_RopeRep*>(__root),
1150 typedef _CharT reference;
1153 typedef const _CharT* pointer;
1156 _Rope_const_iterator() { }
1158 _Rope_const_iterator(
const _Rope_const_iterator& __x)
1159 : _Rope_iterator_base<_CharT,_Alloc>(__x) { }
1161 _Rope_const_iterator(
const _Rope_iterator<_CharT,_Alloc>& __x);
1163 _Rope_const_iterator(
const rope<_CharT, _Alloc>& __r, std::size_t __pos)
1164 : _Rope_iterator_base<_CharT,_Alloc>(__r._M_tree_ptr, __pos) { }
1166 _Rope_const_iterator&
1167 operator=(
const _Rope_const_iterator& __x)
1169 if (0 != __x._M_buf_ptr && __x._M_buf_start != __x._M_tmp_buf)
1170 *(
static_cast<_Rope_iterator_base<_CharT, _Alloc>*
>(
this)) = __x;
1173 this->_M_current_pos = __x._M_current_pos;
1174 this->_M_root = __x._M_root;
1175 this->_M_buf_ptr = 0;
1183 if (0 == this->_M_buf_ptr)
1184 this->_S_setcache(*
this);
1185 return *this->_M_buf_ptr;
1193 return *
const_cast<_Rope_const_iterator&
>(*this);
1196 _Rope_const_iterator&
1199 __GC_CONST _CharT* __next;
1200 if (0 != this->_M_buf_ptr
1201 && (__next = this->_M_buf_ptr + 1) < this->_M_buf_end)
1203 this->_M_buf_ptr = __next;
1204 ++this->_M_current_pos;
1211 _Rope_const_iterator&
1212 operator+=(std::ptrdiff_t __n)
1217 this->_M_decr(-__n);
1221 _Rope_const_iterator&
1228 _Rope_const_iterator&
1229 operator-=(std::ptrdiff_t __n)
1234 this->_M_incr(-__n);
1238 _Rope_const_iterator
1241 std::size_t __old_pos = this->_M_current_pos;
1243 return _Rope_const_iterator<_CharT,_Alloc>(this->_M_root, __old_pos);
1249 _Rope_const_iterator
1252 std::size_t __old_pos = this->_M_current_pos;
1254 return _Rope_const_iterator<_CharT,_Alloc>(this->_M_root, __old_pos);
1257 template<
class _CharT2,
class _Alloc2>
1258 friend _Rope_const_iterator<_CharT2, _Alloc2>
1259 operator-(
const _Rope_const_iterator<_CharT2, _Alloc2>& __x,
1260 std::ptrdiff_t __n);
1262 template<
class _CharT2,
class _Alloc2>
1263 friend _Rope_const_iterator<_CharT2, _Alloc2>
1264 operator+(
const _Rope_const_iterator<_CharT2, _Alloc2>& __x,
1265 std::ptrdiff_t __n);
1267 template<
class _CharT2,
class _Alloc2>
1268 friend _Rope_const_iterator<_CharT2, _Alloc2>
1270 const _Rope_const_iterator<_CharT2, _Alloc2>& __x);
1273 operator[](std::size_t __n)
1274 {
return rope<_CharT, _Alloc>::_S_fetch(this->_M_root,
1275 this->_M_current_pos + __n); }
1277 template<
class _CharT2,
class _Alloc2>
1279 operator==(
const _Rope_const_iterator<_CharT2, _Alloc2>& __x,
1280 const _Rope_const_iterator<_CharT2, _Alloc2>& __y);
1282 template<
class _CharT2,
class _Alloc2>
1284 operator<(const _Rope_const_iterator<_CharT2, _Alloc2>& __x,
1285 const _Rope_const_iterator<_CharT2, _Alloc2>& __y);
1287 template<
class _CharT2,
class _Alloc2>
1288 friend std::ptrdiff_t
1289 operator-(
const _Rope_const_iterator<_CharT2, _Alloc2>& __x,
1290 const _Rope_const_iterator<_CharT2, _Alloc2>& __y);
1293 template<
class _CharT,
class _Alloc>
1294 class _Rope_iterator
1295 :
public _Rope_iterator_base<_CharT, _Alloc>
1297 friend class rope<_CharT, _Alloc>;
1299 typedef typename _Rope_iterator_base<_CharT, _Alloc>::_RopeRep _RopeRep;
1300 rope<_CharT, _Alloc>* _M_root_rope;
1308 _Rope_iterator(rope<_CharT, _Alloc>* __r, std::size_t __pos)
1309 : _Rope_iterator_base<_CharT, _Alloc>(__r->_M_tree_ptr, __pos),
1311 { _RopeRep::_S_ref(this->_M_root);
1312 if (!(__r ->
empty()))
1313 this->_S_setcache(*
this);
1318 typedef _Rope_char_ref_proxy<_CharT, _Alloc> reference;
1319 typedef _Rope_char_ref_proxy<_CharT, _Alloc>* pointer;
1321 rope<_CharT, _Alloc>&
1323 {
return *_M_root_rope; }
1330 _Rope_iterator(
const _Rope_iterator& __x)
1331 : _Rope_iterator_base<_CharT, _Alloc>(__x)
1333 _M_root_rope = __x._M_root_rope;
1334 _RopeRep::_S_ref(this->_M_root);
1337 _Rope_iterator(rope<_CharT, _Alloc>& __r, std::size_t __pos);
1340 { _RopeRep::_S_unref(this->_M_root); }
1345 _RopeRep* __old = this->_M_root;
1347 _RopeRep::_S_ref(__x._M_root);
1348 if (0 != __x._M_buf_ptr && __x._M_buf_start != __x._M_tmp_buf)
1350 _M_root_rope = __x._M_root_rope;
1351 *(
static_cast<_Rope_iterator_base<_CharT, _Alloc>*
>(
this)) = __x;
1355 this->_M_current_pos = __x._M_current_pos;
1356 this->_M_root = __x._M_root;
1357 _M_root_rope = __x._M_root_rope;
1358 this->_M_buf_ptr = 0;
1360 _RopeRep::_S_unref(__old);
1368 if (0 == this->_M_buf_ptr)
1369 return _Rope_char_ref_proxy<_CharT, _Alloc>(_M_root_rope,
1370 this->_M_current_pos);
1372 return _Rope_char_ref_proxy<_CharT, _Alloc>(_M_root_rope,
1373 this->_M_current_pos,
1381 return *
const_cast<_Rope_iterator&
>(*this);
1392 operator+=(std::ptrdiff_t __n)
1397 this->_M_decr(-__n);
1409 operator-=(std::ptrdiff_t __n)
1414 this->_M_incr(-__n);
1421 std::size_t __old_pos = this->_M_current_pos;
1423 return _Rope_iterator<_CharT,_Alloc>(_M_root_rope, __old_pos);
1429 std::size_t __old_pos = this->_M_current_pos;
1431 return _Rope_iterator<_CharT,_Alloc>(_M_root_rope, __old_pos);
1435 operator[](std::ptrdiff_t __n)
1436 {
return _Rope_char_ref_proxy<_CharT, _Alloc>(_M_root_rope,
1437 this->_M_current_pos
1440 template<
class _CharT2,
class _Alloc2>
1442 operator==(
const _Rope_iterator<_CharT2, _Alloc2>& __x,
1443 const _Rope_iterator<_CharT2, _Alloc2>& __y);
1445 template<
class _CharT2,
class _Alloc2>
1447 operator<(const _Rope_iterator<_CharT2, _Alloc2>& __x,
1448 const _Rope_iterator<_CharT2, _Alloc2>& __y);
1450 template<
class _CharT2,
class _Alloc2>
1451 friend std::ptrdiff_t
1452 operator-(
const _Rope_iterator<_CharT2, _Alloc2>& __x,
1453 const _Rope_iterator<_CharT2, _Alloc2>& __y);
1455 template<
class _CharT2,
class _Alloc2>
1456 friend _Rope_iterator<_CharT2, _Alloc2>
1457 operator-(
const _Rope_iterator<_CharT2, _Alloc2>& __x,
1458 std::ptrdiff_t __n);
1460 template<
class _CharT2,
class _Alloc2>
1461 friend _Rope_iterator<_CharT2, _Alloc2>
1462 operator+(
const _Rope_iterator<_CharT2, _Alloc2>& __x,
1463 std::ptrdiff_t __n);
1465 template<
class _CharT2,
class _Alloc2>
1466 friend _Rope_iterator<_CharT2, _Alloc2>
1468 const _Rope_iterator<_CharT2, _Alloc2>& __x);
1472 template <
class _CharT,
class _Alloc>
1476 typedef _Alloc allocator_type;
1479 get_allocator()
const
1480 {
return *
static_cast<const _Alloc*
>(
this); }
1484 {
return *
static_cast<_Alloc*
>(
this); }
1486 const allocator_type&
1487 _M_get_allocator()
const
1488 {
return *
static_cast<const _Alloc*
>(
this); }
1490 typedef _Rope_RopeRep<_CharT, _Alloc> _RopeRep;
1493 _Rope_base(_RopeRep* __t,
const allocator_type&)
1494 : _M_tree_ptr(__t) { }
1496 _Rope_base(
const allocator_type&) { }
1499 _RopeRep *_M_tree_ptr;
1501 #define __ROPE_DEFINE_ALLOC(_Tp, __name) \
1503 __alloc_traits<_Alloc>::template rebind<_Tp>::other __name##Alloc; \
1504 static _Tp* __name##_allocate(std::size_t __n) \
1505 { return __name##Alloc().allocate(__n); } \
1506 static void __name##_deallocate(_Tp *__p, std::size_t __n) \
1507 { __name##Alloc().deallocate(__p, __n); }
1508 __ROPE_DEFINE_ALLOCS(_Alloc)
1509 #undef __ROPE_DEFINE_ALLOC
1515 _Rope_base(
const _Rope_base&);
1523 template <
class _CharT,
class _Alloc>
1524 class rope :
public _Rope_base<_CharT, _Alloc>
1527 typedef _CharT value_type;
1528 typedef std::ptrdiff_t difference_type;
1529 typedef std::size_t size_type;
1530 typedef _CharT const_reference;
1531 typedef const _CharT* const_pointer;
1532 typedef _Rope_iterator<_CharT, _Alloc> iterator;
1533 typedef _Rope_const_iterator<_CharT, _Alloc> const_iterator;
1534 typedef _Rope_char_ref_proxy<_CharT, _Alloc> reference;
1535 typedef _Rope_char_ptr_proxy<_CharT, _Alloc> pointer;
1537 friend class _Rope_iterator<_CharT, _Alloc>;
1538 friend class _Rope_const_iterator<_CharT, _Alloc>;
1539 friend struct _Rope_RopeRep<_CharT, _Alloc>;
1540 friend class _Rope_iterator_base<_CharT, _Alloc>;
1541 friend class _Rope_char_ptr_proxy<_CharT, _Alloc>;
1542 friend class _Rope_char_ref_proxy<_CharT, _Alloc>;
1543 friend struct _Rope_RopeSubstring<_CharT, _Alloc>;
1546 typedef _Rope_base<_CharT, _Alloc> _Base;
1547 typedef typename _Base::allocator_type allocator_type;
1548 using _Base::_M_tree_ptr;
1549 using _Base::get_allocator;
1550 using _Base::_M_get_allocator;
1551 typedef __GC_CONST _CharT* _Cstrptr;
1553 static _CharT _S_empty_c_str[1];
1557 {
return __c == _S_eos((_CharT*)0); }
1559 enum { _S_copy_max = 23 };
1563 typedef _Rope_RopeRep<_CharT, _Alloc> _RopeRep;
1564 typedef _Rope_RopeConcatenation<_CharT, _Alloc> _RopeConcatenation;
1565 typedef _Rope_RopeLeaf<_CharT, _Alloc> _RopeLeaf;
1566 typedef _Rope_RopeFunction<_CharT, _Alloc> _RopeFunction;
1567 typedef _Rope_RopeSubstring<_CharT, _Alloc> _RopeSubstring;
1570 static _CharT _S_fetch(_RopeRep* __r, size_type __pos);
1579 static _CharT* _S_fetch_ptr(_RopeRep* __r, size_type __pos);
1584 _Rope_char_consumer<_CharT>& __c,
1585 const _RopeRep* __r,
1586 size_type __begin, size_type __end);
1591 _S_unref(_RopeRep* __t)
1592 { _RopeRep::_S_unref(__t); }
1595 _S_ref(_RopeRep* __t)
1596 { _RopeRep::_S_ref(__t); }
1599 static void _S_unref(_RopeRep*) { }
1600 static void _S_ref(_RopeRep*) { }
1604 typedef _Rope_RopeRep<_CharT, _Alloc>* _Self_destruct_ptr;
1606 typedef _Rope_self_destruct_ptr<_CharT, _Alloc> _Self_destruct_ptr;
1610 static _RopeRep* _S_substring(_RopeRep*
__base,
1611 size_type __start, size_type __endp1);
1613 static _RopeRep* _S_concat_char_iter(_RopeRep* __r,
1614 const _CharT* __iter,
1616 allocator_type& __a);
1620 static _RopeRep* _S_destr_concat_char_iter(_RopeRep* __r,
1621 const _CharT* __iter,
1623 allocator_type& __a)
1629 {
return _S_concat_char_iter(__r, __iter, __slen, __a); }
1634 static _RopeRep* _S_concat(_RopeRep* __left, _RopeRep* __right);
1640 apply_to_pieces(size_type __begin, size_type __end,
1641 _Rope_char_consumer<_CharT>& __c)
const
1642 { _S_apply_to_pieces(__c, this->_M_tree_ptr, __begin, __end); }
1647 _S_rounded_up_size(size_type __n)
1648 {
return _RopeLeaf::_S_rounded_up_size(__n); }
1651 _S_allocated_capacity(size_type __n)
1653 if (_S_is_basic_char_type((_CharT*)0))
1654 return _S_rounded_up_size(__n) - 1;
1656 return _S_rounded_up_size(__n);
1663 _S_new_RopeLeaf(__GC_CONST _CharT *__s,
1664 size_type __size, allocator_type& __a)
1666 _RopeLeaf* __space =
typename _Base::_LAlloc(__a).allocate(1);
1667 return new(__space) _RopeLeaf(__s, __size, __a);
1670 static _RopeConcatenation*
1671 _S_new_RopeConcatenation(_RopeRep* __left, _RopeRep* __right,
1672 allocator_type& __a)
1674 _RopeConcatenation* __space =
typename _Base::_CAlloc(__a).allocate(1);
1675 return new(__space) _RopeConcatenation(__left, __right, __a);
1678 static _RopeFunction*
1679 _S_new_RopeFunction(char_producer<_CharT>* __f,
1680 size_type __size,
bool __d, allocator_type& __a)
1682 _RopeFunction* __space =
typename _Base::_FAlloc(__a).allocate(1);
1683 return new(__space) _RopeFunction(__f, __size, __d, __a);
1686 static _RopeSubstring*
1687 _S_new_RopeSubstring(_Rope_RopeRep<_CharT,_Alloc>* __b, size_type __s,
1688 size_type __l, allocator_type& __a)
1690 _RopeSubstring* __space =
typename _Base::_SAlloc(__a).allocate(1);
1691 return new(__space) _RopeSubstring(__b, __s, __l, __a);
1695 _S_RopeLeaf_from_unowned_char_ptr(
const _CharT *__s,
1696 size_type __size, allocator_type& __a)
1697 #define __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __size, __a) \
1698 _S_RopeLeaf_from_unowned_char_ptr(__s, __size, __a)
1702 _CharT* __buf = __a.allocate(_S_rounded_up_size(__size));
1704 __uninitialized_copy_n_a(__s, __size, __buf, __a);
1705 _S_cond_store_eos(__buf[__size]);
1707 {
return _S_new_RopeLeaf(__buf, __size, __a); }
1710 _RopeRep::__STL_FREE_STRING(__buf, __size, __a);
1711 __throw_exception_again;
1722 _S_tree_concat(_RopeRep* __left, _RopeRep* __right);
1726 _S_leaf_concat_char_iter(_RopeLeaf* __r,
1727 const _CharT* __iter, size_type __slen);
1733 _S_destr_leaf_concat_char_iter(_RopeLeaf* __r,
1734 const _CharT* __iter, size_type __slen);
1740 static size_type _S_char_ptr_len(
const _CharT* __s);
1743 rope(_RopeRep* __t,
const allocator_type& __a = allocator_type())
1744 : _Base(__t, __a) { }
1750 static _CharT* _S_flatten(_RopeRep* __r, _CharT* __buffer);
1754 static _CharT* _S_flatten(_RopeRep* __r,
1755 size_type __start, size_type __len,
1758 static const unsigned long
1759 _S_min_len[__detail::_S_max_rope_depth + 1];
1762 _S_is_balanced(_RopeRep* __r)
1763 {
return (__r->_M_size >= _S_min_len[__r->_M_depth]); }
1766 _S_is_almost_balanced(_RopeRep* __r)
1767 {
return (__r->_M_depth == 0
1768 || __r->_M_size >= _S_min_len[__r->_M_depth - 1]); }
1771 _S_is_roughly_balanced(_RopeRep* __r)
1772 {
return (__r->_M_depth <= 1
1773 || __r->_M_size >= _S_min_len[__r->_M_depth - 2]); }
1777 _S_concat_and_set_balanced(_RopeRep* __left, _RopeRep* __right)
1779 _RopeRep* __result = _S_concat(__left, __right);
1780 if (_S_is_balanced(__result))
1781 __result->_M_is_balanced =
true;
1790 static _RopeRep* _S_balance(_RopeRep* __r);
1794 static void _S_add_to_forest(_RopeRep*__r, _RopeRep** __forest);
1797 static void _S_add_leaf_to_forest(_RopeRep* __r, _RopeRep** __forest);
1800 static void _S_dump(_RopeRep* __r,
int __indent = 0);
1803 static int _S_compare(
const _RopeRep* __x,
const _RopeRep* __y);
1806 _GLIBCXX_NODISCARD
bool
1808 {
return 0 == this->_M_tree_ptr; }
1814 compare(
const rope& __y)
const
1815 {
return _S_compare(this->_M_tree_ptr, __y._M_tree_ptr); }
1817 rope(
const _CharT* __s,
const allocator_type& __a = allocator_type())
1821 __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, _S_char_ptr_len(__s),
1822 _M_get_allocator());
1825 rope(
const _CharT* __s, size_type __len,
1826 const allocator_type& __a = allocator_type())
1830 __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __len, _M_get_allocator());
1836 rope(
const _CharT* __s,
const _CharT* __e,
1837 const allocator_type& __a = allocator_type())
1841 __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __e - __s, _M_get_allocator());
1844 rope(
const const_iterator& __s,
const const_iterator& __e,
1845 const allocator_type& __a = allocator_type())
1846 : _Base(_S_substring(__s._M_root, __s._M_current_pos,
1847 __e._M_current_pos), __a)
1850 rope(
const iterator& __s,
const iterator& __e,
1851 const allocator_type& __a = allocator_type())
1852 : _Base(_S_substring(__s._M_root, __s._M_current_pos,
1853 __e._M_current_pos), __a)
1856 rope(_CharT __c,
const allocator_type& __a = allocator_type())
1859 _CharT* __buf = this->_Data_allocate(_S_rounded_up_size(1));
1861 __alloc_traits<allocator_type>::construct(_M_get_allocator(),
1865 this->_M_tree_ptr = _S_new_RopeLeaf(__buf, 1,
1866 _M_get_allocator());
1870 _RopeRep::__STL_FREE_STRING(__buf, 1, _M_get_allocator());
1871 __throw_exception_again;
1875 rope(size_type __n, _CharT __c,
1876 const allocator_type& __a = allocator_type());
1878 rope(
const allocator_type& __a = allocator_type())
1882 rope(char_producer<_CharT> *__fn, size_type __len,
bool __delete_fn,
1883 const allocator_type& __a = allocator_type())
1886 this->_M_tree_ptr = (0 == __len)
1888 : _S_new_RopeFunction(__fn, __len, __delete_fn, _M_get_allocator());
1891 rope(
const rope& __x,
const allocator_type& __a = allocator_type())
1892 : _Base(__x._M_tree_ptr, __a)
1893 { _S_ref(this->_M_tree_ptr); }
1896 { _S_unref(this->_M_tree_ptr); }
1901 _RopeRep* __old = this->_M_tree_ptr;
1902 this->_M_tree_ptr = __x._M_tree_ptr;
1903 _S_ref(this->_M_tree_ptr);
1911 _S_unref(this->_M_tree_ptr);
1912 this->_M_tree_ptr = 0;
1916 push_back(_CharT __x)
1918 allocator_type __a = _M_get_allocator();
1919 _RopeRep* __old = this->_M_tree_ptr;
1921 = _S_destr_concat_char_iter(this->_M_tree_ptr, &__x, 1, __a);
1928 _RopeRep* __old = this->_M_tree_ptr;
1929 this->_M_tree_ptr = _S_substring(this->_M_tree_ptr,
1930 0, this->_M_tree_ptr->_M_size - 1);
1936 {
return _S_fetch(this->_M_tree_ptr, this->_M_tree_ptr->_M_size - 1); }
1939 push_front(_CharT __x)
1941 _RopeRep* __old = this->_M_tree_ptr;
1943 __STL_ROPE_FROM_UNOWNED_CHAR_PTR(&__x, 1, _M_get_allocator());
1946 this->_M_tree_ptr = _S_concat(__left, this->_M_tree_ptr);
1953 __throw_exception_again;
1960 _RopeRep* __old = this->_M_tree_ptr;
1962 = _S_substring(this->_M_tree_ptr, 1, this->_M_tree_ptr->_M_size);
1968 {
return _S_fetch(this->_M_tree_ptr, 0); }
1973 _RopeRep* __old = this->_M_tree_ptr;
1974 this->_M_tree_ptr = _S_balance(this->_M_tree_ptr);
1979 copy(_CharT* __buffer)
const
1981 _Destroy_const(__buffer, __buffer +
size(), _M_get_allocator());
1982 _S_flatten(this->_M_tree_ptr, __buffer);
1991 copy(size_type __pos, size_type __n, _CharT* __buffer)
const
1993 size_type __size =
size();
1994 size_type __len = (__pos + __n > __size? __size - __pos : __n);
1996 _Destroy_const(__buffer, __buffer + __len, _M_get_allocator());
1997 _S_flatten(this->_M_tree_ptr, __pos, __len, __buffer);
2005 { _S_dump(this->_M_tree_ptr); }
2009 const _CharT* c_str()
const;
2013 const _CharT* replace_with_c_str();
2021 if (0 == this->_M_tree_ptr)
2023 if (__detail::_S_leaf == this->_M_tree_ptr->_M_tag &&
2024 ((_RopeLeaf*)this->_M_tree_ptr)->_M_data ==
2025 this->_M_tree_ptr->_M_c_string)
2031 this->_M_tree_ptr->_M_free_c_string();
2033 this->_M_tree_ptr->_M_c_string = 0;
2037 operator[] (size_type __pos)
const
2038 {
return _S_fetch(this->_M_tree_ptr, __pos); }
2041 at(size_type __pos)
const
2044 return (*
this)[__pos];
2049 {
return(const_iterator(this->_M_tree_ptr, 0)); }
2054 {
return(const_iterator(this->_M_tree_ptr, 0)); }
2058 {
return(const_iterator(this->_M_tree_ptr,
size())); }
2062 {
return(const_iterator(this->_M_tree_ptr,
size())); }
2066 {
return(0 == this->_M_tree_ptr? 0 : this->_M_tree_ptr->_M_size); }
2075 return _S_min_len[int(__detail::_S_max_rope_depth) - 1] - 1;
2083 const_reverse_iterator
2085 {
return const_reverse_iterator(
end()); }
2087 const_reverse_iterator
2088 const_rbegin()
const
2089 {
return const_reverse_iterator(
end()); }
2091 const_reverse_iterator
2093 {
return const_reverse_iterator(
begin()); }
2095 const_reverse_iterator
2097 {
return const_reverse_iterator(
begin()); }
2099 template<
class _CharT2,
class _Alloc2>
2100 friend rope<_CharT2, _Alloc2>
2101 operator+(
const rope<_CharT2, _Alloc2>& __left,
2102 const rope<_CharT2, _Alloc2>& __right);
2104 template<
class _CharT2,
class _Alloc2>
2105 friend rope<_CharT2, _Alloc2>
2106 operator+(
const rope<_CharT2, _Alloc2>& __left,
const _CharT2* __right);
2108 template<
class _CharT2,
class _Alloc2>
2109 friend rope<_CharT2, _Alloc2>
2110 operator+(
const rope<_CharT2, _Alloc2>& __left, _CharT2 __right);
2119 append(
const _CharT* __iter, size_type __n)
2121 allocator_type __a = _M_get_allocator();
2122 _RopeRep* __result =
2123 _S_destr_concat_char_iter(this->_M_tree_ptr, __iter, __n, __a);
2124 _S_unref(this->_M_tree_ptr);
2125 this->_M_tree_ptr = __result;
2130 append(
const _CharT* __c_string)
2132 size_type __len = _S_char_ptr_len(__c_string);
2133 append(__c_string, __len);
2138 append(
const _CharT* __s,
const _CharT* __e)
2140 allocator_type __a = _M_get_allocator();
2141 _RopeRep* __result =
2142 _S_destr_concat_char_iter(this->_M_tree_ptr, __s, __e - __s, __a);
2143 _S_unref(this->_M_tree_ptr);
2144 this->_M_tree_ptr = __result;
2149 append(const_iterator __s, const_iterator __e)
2151 _Self_destruct_ptr __appendee(_S_substring(__s._M_root,
2153 __e._M_current_pos));
2154 _RopeRep* __result = _S_concat(this->_M_tree_ptr,
2155 (_RopeRep*)__appendee);
2156 _S_unref(this->_M_tree_ptr);
2157 this->_M_tree_ptr = __result;
2164 allocator_type __a = _M_get_allocator();
2165 _RopeRep* __result =
2166 _S_destr_concat_char_iter(this->_M_tree_ptr, &__c, 1, __a);
2167 _S_unref(this->_M_tree_ptr);
2168 this->_M_tree_ptr = __result;
2174 {
return append(_CharT()); }
2177 append(
const rope& __y)
2179 _RopeRep* __result = _S_concat(this->_M_tree_ptr, __y._M_tree_ptr);
2180 _S_unref(this->_M_tree_ptr);
2181 this->_M_tree_ptr = __result;
2186 append(size_type __n, _CharT __c)
2188 rope<_CharT,_Alloc> __last(__n, __c);
2189 return append(__last);
2195 _RopeRep* __tmp = this->_M_tree_ptr;
2196 this->_M_tree_ptr = __b._M_tree_ptr;
2197 __b._M_tree_ptr = __tmp;
2203 replace(_RopeRep* __old, size_type __pos1,
2204 size_type __pos2, _RopeRep* __r)
2211 _Self_destruct_ptr __left(_S_substring(__old, 0, __pos1));
2212 _Self_destruct_ptr __right(_S_substring(__old, __pos2, __old->_M_size));
2216 __result = _S_concat(__left, __right);
2219 _Self_destruct_ptr __left_result(_S_concat(__left, __r));
2220 __result = _S_concat(__left_result, __right);
2227 insert(size_type __p,
const rope& __r)
2229 _RopeRep* __result =
2230 replace(this->_M_tree_ptr, __p, __p, __r._M_tree_ptr);
2231 _S_unref(this->_M_tree_ptr);
2232 this->_M_tree_ptr = __result;
2236 insert(size_type __p, size_type __n, _CharT __c)
2238 rope<_CharT,_Alloc> __r(__n,__c);
2243 insert(size_type __p,
const _CharT* __i, size_type __n)
2245 _Self_destruct_ptr __left(_S_substring(this->_M_tree_ptr, 0, __p));
2246 _Self_destruct_ptr __right(_S_substring(this->_M_tree_ptr,
2248 _Self_destruct_ptr __left_result(_S_concat_char_iter(__left, __i, __n,
2249 _M_get_allocator()));
2253 _RopeRep* __result = _S_concat(__left_result, __right);
2254 _S_unref(this->_M_tree_ptr);
2255 this->_M_tree_ptr = __result;
2259 insert(size_type __p,
const _CharT* __c_string)
2260 { insert(__p, __c_string, _S_char_ptr_len(__c_string)); }
2263 insert(size_type __p, _CharT __c)
2264 { insert(__p, &__c, 1); }
2267 insert(size_type __p)
2269 _CharT __c = _CharT();
2270 insert(__p, &__c, 1);
2274 insert(size_type __p,
const _CharT* __i,
const _CharT* __j)
2281 insert(size_type __p,
const const_iterator& __i,
2282 const const_iterator& __j)
2289 insert(size_type __p,
const iterator& __i,
2290 const iterator& __j)
2299 replace(size_type __p, size_type __n,
const rope& __r)
2301 _RopeRep* __result =
2302 replace(this->_M_tree_ptr, __p, __p + __n, __r._M_tree_ptr);
2303 _S_unref(this->_M_tree_ptr);
2304 this->_M_tree_ptr = __result;
2308 replace(size_type __p, size_type __n,
2309 const _CharT* __i, size_type __i_len)
2311 rope __r(__i, __i_len);
2312 replace(__p, __n, __r);
2316 replace(size_type __p, size_type __n, _CharT __c)
2319 replace(__p, __n, __r);
2323 replace(size_type __p, size_type __n,
const _CharT* __c_string)
2325 rope __r(__c_string);
2326 replace(__p, __n, __r);
2330 replace(size_type __p, size_type __n,
2331 const _CharT* __i,
const _CharT* __j)
2334 replace(__p, __n, __r);
2338 replace(size_type __p, size_type __n,
2339 const const_iterator& __i,
const const_iterator& __j)
2342 replace(__p, __n, __r);
2346 replace(size_type __p, size_type __n,
2347 const iterator& __i,
const iterator& __j)
2350 replace(__p, __n, __r);
2355 replace(size_type __p, _CharT __c)
2357 iterator __i(
this, __p);
2362 replace(size_type __p,
const rope& __r)
2363 { replace(__p, 1, __r); }
2366 replace(size_type __p,
const _CharT* __i, size_type __i_len)
2367 { replace(__p, 1, __i, __i_len); }
2370 replace(size_type __p,
const _CharT* __c_string)
2371 { replace(__p, 1, __c_string); }
2374 replace(size_type __p,
const _CharT* __i,
const _CharT* __j)
2375 { replace(__p, 1, __i, __j); }
2378 replace(size_type __p,
const const_iterator& __i,
2379 const const_iterator& __j)
2380 { replace(__p, 1, __i, __j); }
2383 replace(size_type __p,
const iterator& __i,
2384 const iterator& __j)
2385 { replace(__p, 1, __i, __j); }
2389 erase(size_type __p, size_type __n)
2391 _RopeRep* __result = replace(this->_M_tree_ptr, __p,
2393 _S_unref(this->_M_tree_ptr);
2394 this->_M_tree_ptr = __result;
2399 erase(size_type __p)
2400 { erase(__p, __p + 1); }
2404 insert(
const iterator& __p,
const rope& __r)
2406 insert(__p.index(), __r);
2411 insert(
const iterator& __p, size_type __n, _CharT __c)
2413 insert(__p.index(), __n, __c);
2417 iterator insert(
const iterator& __p, _CharT __c)
2419 insert(__p.index(), __c);
2424 insert(
const iterator& __p )
2426 insert(__p.index());
2431 insert(
const iterator& __p,
const _CharT* c_string)
2433 insert(__p.index(), c_string);
2438 insert(
const iterator& __p,
const _CharT* __i, size_type __n)
2440 insert(__p.index(), __i, __n);
2445 insert(
const iterator& __p,
const _CharT* __i,
2448 insert(__p.index(), __i, __j);
2453 insert(
const iterator& __p,
2454 const const_iterator& __i,
const const_iterator& __j)
2456 insert(__p.index(), __i, __j);
2461 insert(
const iterator& __p,
2462 const iterator& __i,
const iterator& __j)
2464 insert(__p.index(), __i, __j);
2470 replace(
const iterator& __p,
const iterator& __q,
const rope& __r)
2471 { replace(__p.index(), __q.index() - __p.index(), __r); }
2474 replace(
const iterator& __p,
const iterator& __q, _CharT __c)
2475 { replace(__p.index(), __q.index() - __p.index(), __c); }
2478 replace(
const iterator& __p,
const iterator& __q,
2479 const _CharT* __c_string)
2480 { replace(__p.index(), __q.index() - __p.index(), __c_string); }
2483 replace(
const iterator& __p,
const iterator& __q,
2484 const _CharT* __i, size_type __n)
2485 { replace(__p.index(), __q.index() - __p.index(), __i, __n); }
2488 replace(
const iterator& __p,
const iterator& __q,
2489 const _CharT* __i,
const _CharT* __j)
2490 { replace(__p.index(), __q.index() - __p.index(), __i, __j); }
2493 replace(
const iterator& __p,
const iterator& __q,
2494 const const_iterator& __i,
const const_iterator& __j)
2495 { replace(__p.index(), __q.index() - __p.index(), __i, __j); }
2498 replace(
const iterator& __p,
const iterator& __q,
2499 const iterator& __i,
const iterator& __j)
2500 { replace(__p.index(), __q.index() - __p.index(), __i, __j); }
2504 replace(
const iterator& __p,
const rope& __r)
2505 { replace(__p.index(), __r); }
2508 replace(
const iterator& __p, _CharT __c)
2509 { replace(__p.index(), __c); }
2512 replace(
const iterator& __p,
const _CharT* __c_string)
2513 { replace(__p.index(), __c_string); }
2516 replace(
const iterator& __p,
const _CharT* __i, size_type __n)
2517 { replace(__p.index(), __i, __n); }
2520 replace(
const iterator& __p,
const _CharT* __i,
const _CharT* __j)
2521 { replace(__p.index(), __i, __j); }
2524 replace(
const iterator& __p, const_iterator __i, const_iterator __j)
2525 { replace(__p.index(), __i, __j); }
2528 replace(
const iterator& __p, iterator __i, iterator __j)
2529 { replace(__p.index(), __i, __j); }
2533 erase(
const iterator& __p,
const iterator& __q)
2535 size_type __p_index = __p.index();
2536 erase(__p_index, __q.index() - __p_index);
2537 return iterator(
this, __p_index);
2541 erase(
const iterator& __p)
2543 size_type __p_index = __p.index();
2544 erase(__p_index, 1);
2545 return iterator(
this, __p_index);
2549 substr(size_type __start, size_type __len = 1)
const
2551 return rope<_CharT, _Alloc>(_S_substring(this->_M_tree_ptr,
2557 substr(iterator __start, iterator __end)
const
2559 return rope<_CharT, _Alloc>(_S_substring(this->_M_tree_ptr,
2565 substr(iterator __start)
const
2567 size_type __pos = __start.index();
2568 return rope<_CharT, _Alloc>(_S_substring(this->_M_tree_ptr,
2573 substr(const_iterator __start, const_iterator __end)
const
2577 return rope<_CharT, _Alloc>(_S_substring(this->_M_tree_ptr,
2582 rope<_CharT, _Alloc>
2583 substr(const_iterator __start)
2585 size_type __pos = __start.index();
2586 return rope<_CharT, _Alloc>(_S_substring(this->_M_tree_ptr,
2590 static const size_type npos;
2592 size_type find(_CharT __c, size_type __pos = 0)
const;
2595 find(
const _CharT* __s, size_type __pos = 0)
const
2597 size_type __result_pos;
2598 const_iterator __result =
2600 __s, __s + _S_char_ptr_len(__s));
2601 __result_pos = __result.index();
2602 #ifndef __STL_OLD_ROPE_SEMANTICS
2603 if (__result_pos ==
size())
2604 __result_pos = npos;
2606 return __result_pos;
2611 {
return(iterator(
this, 0)); }
2615 {
return(iterator(
this,
size())); }
2621 {
return reverse_iterator(mutable_end()); }
2625 {
return reverse_iterator(mutable_begin()); }
2628 mutable_reference_at(size_type __pos)
2629 {
return reference(
this, __pos); }
2633 operator[] (size_type __pos)
2634 {
return _char_ref_proxy(
this, __pos); }
2640 return (*
this)[__pos];
2643 void resize(size_type __n, _CharT __c) { }
2644 void resize(size_type __n) { }
2645 void reserve(size_type __res_arg = 0) { }
2649 {
return max_size(); }
2655 copy(_CharT* __buffer, size_type __n,
2656 size_type __pos = 0)
const
2657 {
return copy(__pos, __n, __buffer); }
2661 {
return mutable_end(); }
2665 {
return mutable_begin(); }
2669 {
return mutable_rend(); }
2673 {
return mutable_rbegin(); }
2678 {
return const_end(); }
2682 {
return const_begin(); }
2684 const_reverse_iterator
2686 {
return const_rend(); }
2688 const_reverse_iterator
2690 {
return const_rbegin(); }
2695 template <
class _CharT,
class _Alloc>
2696 const typename rope<_CharT, _Alloc>::size_type
2697 rope<_CharT, _Alloc>::npos = (size_type)(-1);
2699 template <
class _CharT,
class _Alloc>
2700 inline bool operator==(
const _Rope_const_iterator<_CharT, _Alloc>& __x,
2701 const _Rope_const_iterator<_CharT, _Alloc>& __y)
2702 {
return (__x._M_current_pos == __y._M_current_pos
2703 && __x._M_root == __y._M_root); }
2705 template <
class _CharT,
class _Alloc>
2706 inline bool operator<(const _Rope_const_iterator<_CharT, _Alloc>& __x,
2707 const _Rope_const_iterator<_CharT, _Alloc>& __y)
2708 {
return (__x._M_current_pos < __y._M_current_pos); }
2710 template <
class _CharT,
class _Alloc>
2711 inline bool operator!=(
const _Rope_const_iterator<_CharT, _Alloc>& __x,
2712 const _Rope_const_iterator<_CharT, _Alloc>& __y)
2713 {
return !(__x == __y); }
2715 template <
class _CharT,
class _Alloc>
2716 inline bool operator>(
const _Rope_const_iterator<_CharT, _Alloc>& __x,
2717 const _Rope_const_iterator<_CharT, _Alloc>& __y)
2718 {
return __y < __x; }
2720 template <
class _CharT,
class _Alloc>
2722 operator<=(const _Rope_const_iterator<_CharT, _Alloc>& __x,
2723 const _Rope_const_iterator<_CharT, _Alloc>& __y)
2724 {
return !(__y < __x); }
2726 template <
class _CharT,
class _Alloc>
2728 operator>=(
const _Rope_const_iterator<_CharT, _Alloc>& __x,
2729 const _Rope_const_iterator<_CharT, _Alloc>& __y)
2730 {
return !(__x < __y); }
2732 template <
class _CharT,
class _Alloc>
2733 inline std::ptrdiff_t
2734 operator-(
const _Rope_const_iterator<_CharT, _Alloc>& __x,
2735 const _Rope_const_iterator<_CharT, _Alloc>& __y)
2737 return (std::ptrdiff_t)__x._M_current_pos
2738 - (std::ptrdiff_t)__y._M_current_pos;
2741 template <
class _CharT,
class _Alloc>
2742 inline _Rope_const_iterator<_CharT, _Alloc>
2743 operator-(
const _Rope_const_iterator<_CharT, _Alloc>& __x,
2745 {
return _Rope_const_iterator<_CharT, _Alloc>(__x._M_root,
2746 __x._M_current_pos - __n); }
2748 template <
class _CharT,
class _Alloc>
2749 inline _Rope_const_iterator<_CharT, _Alloc>
2750 operator+(
const _Rope_const_iterator<_CharT, _Alloc>& __x,
2752 {
return _Rope_const_iterator<_CharT, _Alloc>(__x._M_root,
2753 __x._M_current_pos + __n); }
2755 template <
class _CharT,
class _Alloc>
2756 inline _Rope_const_iterator<_CharT, _Alloc>
2758 const _Rope_const_iterator<_CharT, _Alloc>& __x)
2759 {
return _Rope_const_iterator<_CharT, _Alloc>(__x._M_root,
2760 __x._M_current_pos + __n); }
2762 template <
class _CharT,
class _Alloc>
2764 operator==(
const _Rope_iterator<_CharT, _Alloc>& __x,
2765 const _Rope_iterator<_CharT, _Alloc>& __y)
2766 {
return (__x._M_current_pos == __y._M_current_pos
2767 && __x._M_root_rope == __y._M_root_rope); }
2769 template <
class _CharT,
class _Alloc>
2771 operator<(const _Rope_iterator<_CharT, _Alloc>& __x,
2772 const _Rope_iterator<_CharT, _Alloc>& __y)
2773 {
return (__x._M_current_pos < __y._M_current_pos); }
2775 template <
class _CharT,
class _Alloc>
2777 operator!=(
const _Rope_iterator<_CharT, _Alloc>& __x,
2778 const _Rope_iterator<_CharT, _Alloc>& __y)
2779 {
return !(__x == __y); }
2781 template <
class _CharT,
class _Alloc>
2783 operator>(
const _Rope_iterator<_CharT, _Alloc>& __x,
2784 const _Rope_iterator<_CharT, _Alloc>& __y)
2785 {
return __y < __x; }
2787 template <
class _CharT,
class _Alloc>
2789 operator<=(const _Rope_iterator<_CharT, _Alloc>& __x,
2790 const _Rope_iterator<_CharT, _Alloc>& __y)
2791 {
return !(__y < __x); }
2793 template <
class _CharT,
class _Alloc>
2795 operator>=(
const _Rope_iterator<_CharT, _Alloc>& __x,
2796 const _Rope_iterator<_CharT, _Alloc>& __y)
2797 {
return !(__x < __y); }
2799 template <
class _CharT,
class _Alloc>
2800 inline std::ptrdiff_t
2801 operator-(
const _Rope_iterator<_CharT, _Alloc>& __x,
2802 const _Rope_iterator<_CharT, _Alloc>& __y)
2803 {
return ((std::ptrdiff_t)__x._M_current_pos
2804 - (std::ptrdiff_t)__y._M_current_pos); }
2806 template <
class _CharT,
class _Alloc>
2807 inline _Rope_iterator<_CharT, _Alloc>
2808 operator-(
const _Rope_iterator<_CharT, _Alloc>& __x,
2810 {
return _Rope_iterator<_CharT, _Alloc>(__x._M_root_rope,
2811 __x._M_current_pos - __n); }
2813 template <
class _CharT,
class _Alloc>
2814 inline _Rope_iterator<_CharT, _Alloc>
2815 operator+(
const _Rope_iterator<_CharT, _Alloc>& __x, std::ptrdiff_t __n)
2816 {
return _Rope_iterator<_CharT, _Alloc>(__x._M_root_rope,
2817 __x._M_current_pos + __n); }
2819 template <
class _CharT,
class _Alloc>
2820 inline _Rope_iterator<_CharT, _Alloc>
2821 operator+(std::ptrdiff_t __n,
const _Rope_iterator<_CharT, _Alloc>& __x)
2822 {
return _Rope_iterator<_CharT, _Alloc>(__x._M_root_rope,
2823 __x._M_current_pos + __n); }
2825 template <
class _CharT,
class _Alloc>
2826 inline rope<_CharT, _Alloc>
2827 operator+(
const rope<_CharT, _Alloc>& __left,
2828 const rope<_CharT, _Alloc>& __right)
2832 typedef rope<_CharT, _Alloc> rope_type;
2833 return rope_type(rope_type::_S_concat(__left._M_tree_ptr,
2834 __right._M_tree_ptr));
2837 template <
class _CharT,
class _Alloc>
2838 inline rope<_CharT, _Alloc>&
2839 operator+=(rope<_CharT, _Alloc>& __left,
2840 const rope<_CharT, _Alloc>& __right)
2842 __left.append(__right);
2846 template <
class _CharT,
class _Alloc>
2847 inline rope<_CharT, _Alloc>
2848 operator+(
const rope<_CharT, _Alloc>& __left,
2849 const _CharT* __right)
2851 typedef rope<_CharT, _Alloc> rope_type;
2852 std::size_t __rlen = rope_type::_S_char_ptr_len(__right);
2853 _Alloc __a = __left.get_allocator();
2854 return rope_type(rope_type::_S_concat_char_iter(__left._M_tree_ptr,
2855 __right, __rlen, __a));
2858 template <
class _CharT,
class _Alloc>
2859 inline rope<_CharT, _Alloc>&
2860 operator+=(rope<_CharT, _Alloc>& __left,
2861 const _CharT* __right)
2863 __left.append(__right);
2867 template <
class _CharT,
class _Alloc>
2868 inline rope<_CharT, _Alloc>
2869 operator+(
const rope<_CharT, _Alloc>& __left, _CharT __right)
2871 typedef rope<_CharT, _Alloc> rope_type;
2872 _Alloc __a = __left.get_allocator();
2873 return rope_type(rope_type::_S_concat_char_iter(__left._M_tree_ptr,
2877 template <
class _CharT,
class _Alloc>
2878 inline rope<_CharT, _Alloc>&
2879 operator+=(rope<_CharT, _Alloc>& __left, _CharT __right)
2881 __left.append(__right);
2885 template <
class _CharT,
class _Alloc>
2887 operator<(const rope<_CharT, _Alloc>& __left,
2888 const rope<_CharT, _Alloc>& __right)
2889 {
return __left.compare(__right) < 0; }
2891 template <
class _CharT,
class _Alloc>
2893 operator==(
const rope<_CharT, _Alloc>& __left,
2894 const rope<_CharT, _Alloc>& __right)
2895 {
return __left.compare(__right) == 0; }
2897 template <
class _CharT,
class _Alloc>
2899 operator==(
const _Rope_char_ptr_proxy<_CharT, _Alloc>& __x,
2900 const _Rope_char_ptr_proxy<_CharT, _Alloc>& __y)
2901 {
return (__x._M_pos == __y._M_pos && __x._M_root == __y._M_root); }
2903 template <
class _CharT,
class _Alloc>
2905 operator!=(
const rope<_CharT, _Alloc>& __x,
2906 const rope<_CharT, _Alloc>& __y)
2907 {
return !(__x == __y); }
2909 template <
class _CharT,
class _Alloc>
2911 operator>(
const rope<_CharT, _Alloc>& __x,
2912 const rope<_CharT, _Alloc>& __y)
2913 {
return __y < __x; }
2915 template <
class _CharT,
class _Alloc>
2917 operator<=(const rope<_CharT, _Alloc>& __x,
2918 const rope<_CharT, _Alloc>& __y)
2919 {
return !(__y < __x); }
2921 template <
class _CharT,
class _Alloc>
2923 operator>=(
const rope<_CharT, _Alloc>& __x,
2924 const rope<_CharT, _Alloc>& __y)
2925 {
return !(__x < __y); }
2927 template <
class _CharT,
class _Alloc>
2929 operator!=(
const _Rope_char_ptr_proxy<_CharT, _Alloc>& __x,
2930 const _Rope_char_ptr_proxy<_CharT, _Alloc>& __y)
2931 {
return !(__x == __y); }
2933 template<
class _CharT,
class _Traits,
class _Alloc>
2935 operator<<(std::basic_ostream<_CharT, _Traits>& __o,
2936 const rope<_CharT, _Alloc>& __r);
2938 typedef rope<char> crope;
2939 typedef rope<wchar_t> wrope;
2941 inline crope::reference
2942 __mutable_reference_at(crope& __c, std::size_t __i)
2943 {
return __c.mutable_reference_at(__i); }
2945 inline wrope::reference
2946 __mutable_reference_at(wrope& __c, std::size_t __i)
2947 {
return __c.mutable_reference_at(__i); }
2949 template <
class _CharT,
class _Alloc>
2951 swap(rope<_CharT, _Alloc>& __x, rope<_CharT, _Alloc>& __y)
2954 _GLIBCXX_END_NAMESPACE_VERSION
2958 namespace std _GLIBCXX_VISIBILITY(default)
2960 _GLIBCXX_BEGIN_NAMESPACE_VERSION
2965 struct hash<__gnu_cxx::crope>
2970 size_t __size = __str.size();
2973 return 13 * __str[0] + 5 * __str[__size - 1] + __size;
2979 struct hash<__gnu_cxx::wrope>
2984 size_t __size = __str.size();
2987 return 13 * __str[0] + 5 * __str[__size - 1] + __size;
2992 _GLIBCXX_END_NAMESPACE_VERSION
void _Destroy(_ForwardIterator __first, _ForwardIterator __last, _Allocator &__alloc)
bitset< _Nb > operator&(const bitset< _Nb > &__x, const bitset< _Nb > &__y) noexcept
Global bitwise operations on bitsets.
constexpr auto rend(_Container &__cont) -> decltype(__cont.rend())
Return a reverse iterator pointing one past the first element of the container.
std::pair< _InputIter, _ForwardIter > uninitialized_copy_n(_InputIter __first, _Size __count, _ForwardIter __result)
Copies the range [first,last) into result.
constexpr complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.
_Tp * begin(valarray< _Tp > &__va)
Return an iterator pointing to the first element of the valarray.
constexpr auto rbegin(_Container &__cont) -> decltype(__cont.rbegin())
Return a reverse iterator pointing to the last element of the container.
_Tp * end(valarray< _Tp > &__va)
Return an iterator pointing to one past the last element of the valarray.
constexpr _ForwardIterator search(_ForwardIterator __first, _ForwardIterator __last, const _Searcher &__searcher)
Search a sequence using a Searcher object.
basic_ostream< _CharT, _Traits > & flush(basic_ostream< _CharT, _Traits > &__os)
Flushes the output stream.
The standard allocator, as per C++03 [20.4.1].
constexpr complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
element_type & operator*() const
Smart pointer dereferencing.
constexpr _Iterator __base(_Iterator __it)
constexpr complex< _Tp > operator-(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x minus y.
constexpr auto empty(const _Container &__cont) noexcept(noexcept(__cont.empty())) -> decltype(__cont.empty())
Return whether a container is empty.
constexpr const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
Template class basic_ostream.
element_type * operator->() const
Smart pointer dereferencing.
constexpr auto size(const _Container &__cont) noexcept(noexcept(__cont.size())) -> decltype(__cont.size())
Return the size of a container.
auto_ptr & operator=(auto_ptr &__a)
auto_ptr assignment operator.