head	1.13;
access;
symbols
	netbsd-11-0-RC4:1.12
	netbsd-11-0-RC3:1.12
	netbsd-11-0-RC2:1.12
	netbsd-11-0-RC1:1.12
	gcc-14-3-0:1.1.1.14
	perseant-exfatfs-base-20250801:1.12
	netbsd-11:1.12.0.4
	netbsd-11-base:1.12
	gcc-12-5-0:1.1.1.13
	netbsd-10-1-RELEASE:1.11
	perseant-exfatfs-base-20240630:1.12
	gcc-12-4-0:1.1.1.13
	perseant-exfatfs:1.12.0.2
	perseant-exfatfs-base:1.12
	netbsd-8-3-RELEASE:1.5
	netbsd-9-4-RELEASE:1.7
	netbsd-10-0-RELEASE:1.11
	netbsd-10-0-RC6:1.11
	netbsd-10-0-RC5:1.11
	netbsd-10-0-RC4:1.11
	netbsd-10-0-RC3:1.11
	netbsd-10-0-RC2:1.11
	netbsd-10-0-RC1:1.11
	gcc-12-3-0:1.1.1.13
	gcc-10-5-0:1.1.1.12
	netbsd-10:1.11.0.2
	netbsd-10-base:1.11
	netbsd-9-3-RELEASE:1.7
	gcc-10-4-0:1.1.1.12
	cjep_sun2x-base1:1.10
	cjep_sun2x:1.10.0.4
	cjep_sun2x-base:1.10
	cjep_staticlib_x-base1:1.10
	netbsd-9-2-RELEASE:1.7
	cjep_staticlib_x:1.10.0.2
	cjep_staticlib_x-base:1.10
	gcc-10-3-0:1.1.1.11
	netbsd-9-1-RELEASE:1.7
	gcc-9-3-0:1.1.1.10
	gcc-7-5-0:1.1.1.8
	phil-wifi-20200421:1.8
	phil-wifi-20200411:1.8
	is-mlppp:1.8.0.2
	is-mlppp-base:1.8
	phil-wifi-20200406:1.8
	netbsd-8-2-RELEASE:1.5
	gcc-8-4-0:1.1.1.9
	netbsd-9-0-RELEASE:1.7
	netbsd-9-0-RC2:1.7
	netbsd-9-0-RC1:1.7
	phil-wifi-20191119:1.8
	gcc-8-3-0:1.1.1.7
	netbsd-9:1.7.0.2
	netbsd-9-base:1.7
	phil-wifi-20190609:1.7
	netbsd-8-1-RELEASE:1.5
	netbsd-8-1-RC1:1.5
	pgoyette-compat-merge-20190127:1.6.2.1
	pgoyette-compat-20190127:1.7
	gcc-7-4-0:1.1.1.6
	pgoyette-compat-20190118:1.6
	pgoyette-compat-1226:1.6
	pgoyette-compat-1126:1.6
	gcc-6-5-0:1.1.1.5
	pgoyette-compat-1020:1.6
	pgoyette-compat-0930:1.6
	pgoyette-compat-0906:1.6
	netbsd-7-2-RELEASE:1.3.4.1
	pgoyette-compat-0728:1.6
	netbsd-8-0-RELEASE:1.5
	phil-wifi:1.6.0.4
	phil-wifi-base:1.6
	pgoyette-compat-0625:1.6
	netbsd-8-0-RC2:1.5
	pgoyette-compat-0521:1.6
	pgoyette-compat-0502:1.6
	pgoyette-compat-0422:1.6
	netbsd-8-0-RC1:1.5
	pgoyette-compat-0415:1.6
	pgoyette-compat-0407:1.6
	pgoyette-compat-0330:1.6
	pgoyette-compat-0322:1.6
	pgoyette-compat-0315:1.6
	netbsd-7-1-2-RELEASE:1.3.4.1
	pgoyette-compat:1.6.0.2
	pgoyette-compat-base:1.6
	gcc-6-4-0:1.1.1.5
	netbsd-7-1-1-RELEASE:1.3.4.1
	gcc-5-5-0:1.1.1.4
	matt-nb8-mediatek:1.5.0.12
	matt-nb8-mediatek-base:1.5
	perseant-stdc-iso10646:1.5.0.10
	perseant-stdc-iso10646-base:1.5
	netbsd-8:1.5.0.8
	netbsd-8-base:1.5
	prg-localcount2-base3:1.5
	prg-localcount2-base2:1.5
	prg-localcount2-base1:1.5
	prg-localcount2:1.5.0.6
	prg-localcount2-base:1.5
	pgoyette-localcount-20170426:1.5
	bouyer-socketcan-base1:1.5
	pgoyette-localcount-20170320:1.5
	netbsd-7-1:1.3.4.1.0.6
	netbsd-7-1-RELEASE:1.3.4.1
	netbsd-7-1-RC2:1.3.4.1
	netbsd-7-nhusb-base-20170116:1.3.4.1
	bouyer-socketcan:1.5.0.4
	bouyer-socketcan-base:1.5
	pgoyette-localcount-20170107:1.5
	netbsd-7-1-RC1:1.3.4.1
	pgoyette-localcount-20161104:1.5
	netbsd-7-0-2-RELEASE:1.3.4.1
	localcount-20160914:1.5
	netbsd-7-nhusb:1.3.4.1.0.4
	netbsd-7-nhusb-base:1.3.4.1
	pgoyette-localcount-20160806:1.5
	pgoyette-localcount-20160726:1.5
	pgoyette-localcount:1.5.0.2
	pgoyette-localcount-base:1.5
	gcc-5-4-0:1.1.1.4
	netbsd-7-0-1-RELEASE:1.3.4.1
	gcc-5-3-0:1.1.1.4
	netbsd-7-0:1.3.4.1.0.2
	netbsd-7-0-RELEASE:1.3.4.1
	gcc-4-8-5-pre-gcc-old-import:1.4
	netbsd-7-0-RC3:1.3.4.1
	netbsd-7-0-RC2:1.3.4.1
	post-gcc-4-8-5-merge:1.4
	gcc-4-8-5:1.1.1.3
	netbsd-7-0-RC1:1.3.4.1
	gcc-4-8-4:1.1.1.3
	gcc-4-8-20141009:1.1.1.3
	netbsd-6-0-6-RELEASE:1.1.1.1
	netbsd-6-1-5-RELEASE:1.1.1.1
	netbsd-7:1.3.0.4
	netbsd-7-base:1.3
	gcc-4-8-3:1.1.1.2
	yamt-pagecache-base9:1.3
	yamt-pagecache-tag8:1.1.1.1
	netbsd-6-1-4-RELEASE:1.1.1.1
	netbsd-6-0-5-RELEASE:1.1.1.1
	tls-earlyentropy:1.3.0.2
	tls-earlyentropy-base:1.3
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.3
	riastradh-drm2-base3:1.3
	gcc-4-8-3-pre-r208254:1.1.1.2
	gcc-4-8-3-pre-r206687:1.1.1.2
	imported-to-gcc-old-20140227-0107:1.2
	netbsd-6-1-3-RELEASE:1.1.1.1
	netbsd-6-0-4-RELEASE:1.1.1.1
	netbsd-6-1-2-RELEASE:1.1.1.1
	netbsd-6-0-3-RELEASE:1.1.1.1
	netbsd-6-1-1-RELEASE:1.1.1.1
	riastradh-drm2-base2:1.2
	riastradh-drm2-base1:1.2
	riastradh-drm2:1.2.0.4
	riastradh-drm2-base:1.2
	netbsd-6-1:1.1.1.1.0.14
	netbsd-6-0-2-RELEASE:1.1.1.1
	netbsd-6-1-RELEASE:1.1.1.1
	netbsd-6-1-RC4:1.1.1.1
	netbsd-6-1-RC3:1.1.1.1
	agc-symver:1.2.0.2
	agc-symver-base:1.2
	netbsd-6-1-RC2:1.1.1.1
	netbsd-6-1-RC1:1.1.1.1
	yamt-pagecache-base8:1.1.1.1
	netbsd-6-0-1-RELEASE:1.1.1.1
	yamt-pagecache-base7:1.1.1.1
	matt-nb6-plus-nbase:1.1.1.1
	yamt-pagecache-base6:1.1.1.1
	netbsd-6-0:1.1.1.1.0.10
	netbsd-6-0-RELEASE:1.1.1.1
	gcc-4-5-4:1.1.1.1
	netbsd-6-0-RC2:1.1.1.1
	tls-maxphys:1.1.1.1.0.8
	tls-maxphys-base:1.3
	matt-nb6-plus:1.1.1.1.0.6
	matt-nb6-plus-base:1.1.1.1
	netbsd-6-0-RC1:1.1.1.1
	yamt-pagecache-base5:1.1.1.1
	yamt-pagecache-base4:1.1.1.1
	netbsd-6:1.1.1.1.0.4
	netbsd-6-base:1.1.1.1
	yamt-pagecache-base3:1.1.1.1
	yamt-pagecache-base2:1.1.1.1
	yamt-pagecache:1.1.1.1.0.2
	yamt-pagecache-base:1.1.1.1
	gcc-4-5-3:1.1.1.1
	FSF:1.1.1;
locks; strict;
comment	@# @;


1.13
date	2025.09.14.00.09.01;	author mrg;	state Exp;
branches;
next	1.12;
commitid	x9D5QEnvbeMI4CaG;

1.12
date	2023.07.30.05.51.44;	author mrg;	state Exp;
branches;
next	1.11;
commitid	Iugici1GtQ2mWMyE;

1.11
date	2022.07.22.20.22.38;	author mrg;	state Exp;
branches;
next	1.10;
commitid	26I33JZwnjoCLVMD;

1.10
date	2021.04.11.00.02.25;	author mrg;	state Exp;
branches;
next	1.9;
commitid	rXajJcXg3xWG0OOC;

1.9
date	2020.09.05.09.12.33;	author mrg;	state Exp;
branches;
next	1.8;
commitid	dS3LXwk3lAvP4QmC;

1.8
date	2019.10.01.10.38.24;	author mrg;	state Exp;
branches;
next	1.7;
commitid	r1DeKUVOMBnJt9FB;

1.7
date	2019.01.19.12.10.14;	author mrg;	state Exp;
branches;
next	1.6;
commitid	k8UsQyKpGt5Abo8B;

1.6
date	2018.02.02.03.41.12;	author mrg;	state Exp;
branches
	1.6.2.1
	1.6.4.1;
next	1.5;
commitid	YbHkrPGCnw2dEepA;

1.5
date	2016.01.24.09.43.39;	author mrg;	state Exp;
branches;
next	1.4;
commitid	dxhNntGC3MSSqaSy;

1.4
date	2014.10.12.07.11.59;	author mrg;	state Exp;
branches;
next	1.3;
commitid	gDt0NK6Vt43eGSTx;

1.3
date	2014.03.01.09.04.13;	author mrg;	state Exp;
branches
	1.3.4.1;
next	1.2;
commitid	xDwNUNuRUv05xYqx;

1.2
date	2013.03.02.23.23.55;	author joerg;	state Exp;
branches;
next	1.1;

1.1
date	2011.06.21.01.24.44;	author mrg;	state Exp;
branches
	1.1.1.1;
next	;

1.6.2.1
date	2019.01.26.21.59.35;	author pgoyette;	state Exp;
branches;
next	;
commitid	JKpcmvSjdT25dl9B;

1.6.4.1
date	2019.06.10.21.54.52;	author christos;	state Exp;
branches;
next	1.6.4.2;
commitid	jtc8rnCzWiEEHGqB;

1.6.4.2
date	2020.04.13.07.58.38;	author martin;	state Exp;
branches;
next	;
commitid	X01YhRUPVUDaec4C;

1.3.4.1
date	2014.10.14.20.26.01;	author snj;	state Exp;
branches;
next	;
commitid	FzZB4tcCfwDt0dUx;

1.1.1.1
date	2011.06.21.01.24.44;	author mrg;	state Exp;
branches
	1.1.1.1.2.1
	1.1.1.1.8.1;
next	1.1.1.2;

1.1.1.2
date	2014.03.01.08.41.32;	author mrg;	state Exp;
branches;
next	1.1.1.3;
commitid	TtaB91QNTknAoYqx;

1.1.1.3
date	2014.10.12.07.02.31;	author mrg;	state Exp;
branches;
next	1.1.1.4;
commitid	AUoKtJJh7G1ZySTx;

1.1.1.4
date	2016.01.24.06.05.52;	author mrg;	state Exp;
branches;
next	1.1.1.5;
commitid	uWWfbLp08zOK79Sy;

1.1.1.5
date	2018.02.02.01.59.03;	author mrg;	state Exp;
branches;
next	1.1.1.6;
commitid	XNKaycqpfhzd5epA;

1.1.1.6
date	2019.01.19.10.14.12;	author mrg;	state Exp;
branches;
next	1.1.1.7;
commitid	VQ8OwWIg5RS9kn8B;

1.1.1.7
date	2019.10.01.09.36.07;	author mrg;	state Exp;
branches;
next	1.1.1.8;
commitid	smvgr2IPAQDr89FB;

1.1.1.8
date	2020.08.11.05.10.39;	author mrg;	state Exp;
branches;
next	1.1.1.9;
commitid	5dBRDT7i6e65xBjC;

1.1.1.9
date	2020.08.11.05.30.09;	author mrg;	state Exp;
branches;
next	1.1.1.10;
commitid	7AI4OfpLi4eqEBjC;

1.1.1.10
date	2020.09.05.07.52.09;	author mrg;	state Exp;
branches;
next	1.1.1.11;
commitid	ZRYA7IOuwfMjAPmC;

1.1.1.11
date	2021.04.10.22.10.04;	author mrg;	state Exp;
branches;
next	1.1.1.12;
commitid	eC4g0MRpqTvEkNOC;

1.1.1.12
date	2022.07.22.19.52.36;	author mrg;	state Exp;
branches;
next	1.1.1.13;
commitid	fUYPgdKzIHqhwVMD;

1.1.1.13
date	2023.07.30.05.21.20;	author mrg;	state Exp;
branches;
next	1.1.1.14;
commitid	tk6nV4mbc9nVEMyE;

1.1.1.14
date	2025.09.13.23.45.48;	author mrg;	state Exp;
branches;
next	;
commitid	KwhwN4krNWa6XBaG;

1.1.1.1.2.1
date	2014.05.22.16.37.49;	author yamt;	state Exp;
branches;
next	;
commitid	DX8bafDLmqEbpyBx;

1.1.1.1.8.1
date	2013.06.23.06.28.34;	author tls;	state Exp;
branches;
next	1.1.1.1.8.2;
commitid	OnlO1cBgtQRcIHUw;

1.1.1.1.8.2
date	2014.08.19.23.54.50;	author tls;	state Exp;
branches;
next	;
commitid	jTnpym9Qu0o4R1Nx;


desc
@@


1.13
log
@merge GCC 14.3.0.
@
text
@// SGI's rope class -*- C++ -*-

// Copyright (C) 2001-2024 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/*
 * Copyright (c) 1997
 * Silicon Graphics Computer Systems, Inc.
 *
 * Permission to use, copy, modify, distribute and sell this software
 * and its documentation for any purpose is hereby granted without fee,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation.  Silicon Graphics makes no
 * representations about the suitability of this software for any
 * purpose.  It is provided "as is" without express or implied warranty.
 */

/** @@file ext/rope
 *  This file is a GNU extension to the Standard C++ Library (possibly
 *  containing extensions from the HP/SGI STL subset). 
 */

#ifndef _ROPE
#define _ROPE 1

#pragma GCC system_header

#include <bits/requires_hosted.h> // GNU extensions are currently omitted

#include <algorithm>
#include <iosfwd>
#include <bits/stl_construct.h>
#include <bits/stl_uninitialized.h>
#include <bits/stl_function.h>
#include <bits/stl_numeric.h>
#include <bits/allocator.h>
#include <bits/gthr.h>
#include <ext/alloc_traits.h>
#include <tr1/functional>

# ifdef __GC
#   define __GC_CONST const
# else
#   define __GC_CONST   // constant except for deallocation
# endif

#include <ext/memory> // For uninitialized_copy_n

namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION

  namespace __detail
  {
    enum { _S_max_rope_depth = 45 };
    enum _Tag {_S_leaf, _S_concat, _S_substringfn, _S_function};
  } // namespace __detail

  // See libstdc++/36832.
  template<typename _ForwardIterator, typename _Allocator>
    void
    _Destroy_const(_ForwardIterator __first,
		   _ForwardIterator __last, _Allocator __alloc)
    {
      for (; __first != __last; ++__first)
	__alloc.destroy(&*__first);
    }

  template<typename _ForwardIterator, typename _Tp>
    inline void
    _Destroy_const(_ForwardIterator __first,
		   _ForwardIterator __last, std::allocator<_Tp>)
    { std::_Destroy(__first, __last); }

  // The _S_eos function is used for those functions that
  // convert to/from C-like strings to detect the end of the string.
  
  // The end-of-C-string character.
  // This is what the draft standard says it should be.
  template <class _CharT>
    inline _CharT
    _S_eos(_CharT*)
    { return _CharT(); }

  // Test for basic character types.
  // For basic character types leaves having a trailing eos.
  template <class _CharT>
    inline bool
    _S_is_basic_char_type(_CharT*)
    { return false; }
  
  template <class _CharT>
    inline bool
    _S_is_one_byte_char_type(_CharT*)
    { return false; }

  inline bool
  _S_is_basic_char_type(char*)
  { return true; }
  
  inline bool
  _S_is_one_byte_char_type(char*)
  { return true; }
  
  inline bool
  _S_is_basic_char_type(wchar_t*)
  { return true; }

  // Store an eos iff _CharT is a basic character type.
  // Do not reference _S_eos if it isn't.
  template <class _CharT>
    inline void
    _S_cond_store_eos(_CharT&) { }

  inline void
  _S_cond_store_eos(char& __c)
  { __c = 0; }

  inline void
  _S_cond_store_eos(wchar_t& __c)
  { __c = 0; }

  // char_producers are logically functions that generate a section of
  // a string.  These can be converted to ropes.  The resulting rope
  // invokes the char_producer on demand.  This allows, for example,
  // files to be viewed as ropes without reading the entire file.
  template <class _CharT>
    class char_producer
    {
    public:
      virtual ~char_producer() { }

      virtual void
      operator()(std::size_t __start_pos, std::size_t __len,
		 _CharT* __buffer) = 0;
      // Buffer should really be an arbitrary output iterator.
      // That way we could flatten directly into an ostream, etc.
      // This is thoroughly impossible, since iterator types don't
      // have runtime descriptions.
    };

  // Sequence buffers:
  //
  // Sequence must provide an append operation that appends an
  // array to the sequence.  Sequence buffers are useful only if
  // appending an entire array is cheaper than appending element by element.
  // This is true for many string representations.
  // This should  perhaps inherit from ostream<sequence::value_type>
  // and be implemented correspondingly, so that they can be used
  // for formatted.  For the sake of portability, we don't do this yet.
  //
  // For now, sequence buffers behave as output iterators.  But they also
  // behave a little like basic_ostringstream<sequence::value_type> and a
  // little like containers.

// Ignore warnings about std::iterator.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"

  template<class _Sequence, std::size_t _Buf_sz = 100>
    class sequence_buffer
    : public std::iterator<std::output_iterator_tag, void, void, void, void>
    {
    public:
      typedef typename _Sequence::value_type value_type;
    protected:
      _Sequence* _M_prefix;
      value_type _M_buffer[_Buf_sz];
      std::size_t _M_buf_count;
    public:

      void
      flush()
      {
	_M_prefix->append(_M_buffer, _M_buffer + _M_buf_count);
	_M_buf_count = 0;
      }
      
      ~sequence_buffer()
      { flush(); }
      
      sequence_buffer()
      : _M_prefix(0), _M_buf_count(0) { }

      sequence_buffer(const sequence_buffer& __x)
      {
	_M_prefix = __x._M_prefix;
	_M_buf_count = __x._M_buf_count;
	std::copy(__x._M_buffer, __x._M_buffer + __x._M_buf_count, _M_buffer);
      }
      
      // Non-const "copy" modifies the parameter - yuck
      sequence_buffer(sequence_buffer& __x)
      {
	__x.flush();
	_M_prefix = __x._M_prefix;
	_M_buf_count = 0;
      }
      
      sequence_buffer(_Sequence& __s)
      : _M_prefix(&__s), _M_buf_count(0) { }
      
      // Non-const "copy" modifies the parameter - yuck
      sequence_buffer&
      operator=(sequence_buffer& __x)
      {
	__x.flush();
	_M_prefix = __x._M_prefix;
	_M_buf_count = 0;
	return *this;
      }

      sequence_buffer&
      operator=(const sequence_buffer& __x)
      {
	_M_prefix = __x._M_prefix;
	_M_buf_count = __x._M_buf_count;
	std::copy(__x._M_buffer, __x._M_buffer + __x._M_buf_count, _M_buffer);
	return *this;
      }

#if __cplusplus >= 201103L
      sequence_buffer(sequence_buffer&& __x) : sequence_buffer(__x) { }
      sequence_buffer& operator=(sequence_buffer&& __x) { return *this = __x; }
#endif

      void
      push_back(value_type __x)
      {
	if (_M_buf_count < _Buf_sz)
	  {
	    _M_buffer[_M_buf_count] = __x;
	    ++_M_buf_count;
	  }
	else
	  {
	    flush();
	    _M_buffer[0] = __x;
	    _M_buf_count = 1;
	  }
      }
      
      void
      append(value_type* __s, std::size_t __len)
      {
	if (__len + _M_buf_count <= _Buf_sz)
	  {
	    std::size_t __i = _M_buf_count;
	    for (std::size_t __j = 0; __j < __len; __i++, __j++)
	      _M_buffer[__i] = __s[__j];
	    _M_buf_count += __len;
	  }
	else if (0 == _M_buf_count)
	  _M_prefix->append(__s, __s + __len);
	else
	  {
	    flush();
	    append(__s, __len);
	  }
      }

      sequence_buffer&
      write(value_type* __s, std::size_t __len)
      {
	append(__s, __len);
	return *this;
      }
      
      sequence_buffer&
      put(value_type __x)
      {
	push_back(__x);
	return *this;
      }
      
      sequence_buffer&
      operator=(const value_type& __rhs)
      {
	push_back(__rhs);
	return *this;
      }
      
      sequence_buffer&
      operator*()
      { return *this; }
      
      sequence_buffer&
      operator++()
      { return *this; }
      
      sequence_buffer
      operator++(int)
      { return *this; }
    };
#pragma GCC diagnostic pop
  
  // The following should be treated as private, at least for now.
  template<class _CharT>
    class _Rope_char_consumer
    {
    public:
      // If we had member templates, these should not be virtual.
      // For now we need to use run-time parametrization where
      // compile-time would do.  Hence this should all be private
      // for now.
      // The symmetry with char_producer is accidental and temporary.
      virtual ~_Rope_char_consumer() { }
  
      virtual bool
      operator()(const _CharT* __buffer, std::size_t __len) = 0;
    };
  
  // First a lot of forward declarations.  The standard seems to require
  // much stricter "declaration before use" than many of the implementations
  // that preceded it.
  template<class _CharT, class _Alloc = std::allocator<_CharT> >
    class rope;
  
  template<class _CharT, class _Alloc>
    struct _Rope_RopeConcatenation;

  template<class _CharT, class _Alloc>
    struct _Rope_RopeLeaf;
  
  template<class _CharT, class _Alloc>
    struct _Rope_RopeFunction;
  
  template<class _CharT, class _Alloc>
    struct _Rope_RopeSubstring;
  
  template<class _CharT, class _Alloc>
    class _Rope_iterator;
  
  template<class _CharT, class _Alloc>
    class _Rope_const_iterator;
  
  template<class _CharT, class _Alloc>
    class _Rope_char_ref_proxy;
  
  template<class _CharT, class _Alloc>
    class _Rope_char_ptr_proxy;

  template<class _CharT, class _Alloc>
    bool
    operator==(const _Rope_char_ptr_proxy<_CharT, _Alloc>& __x,
	       const _Rope_char_ptr_proxy<_CharT, _Alloc>& __y);

  template<class _CharT, class _Alloc>
    _Rope_const_iterator<_CharT, _Alloc>
    operator-(const _Rope_const_iterator<_CharT, _Alloc>& __x,
	      std::ptrdiff_t __n);

  template<class _CharT, class _Alloc>
    _Rope_const_iterator<_CharT, _Alloc>
    operator+(const _Rope_const_iterator<_CharT, _Alloc>& __x,
	      std::ptrdiff_t __n);

  template<class _CharT, class _Alloc>
    _Rope_const_iterator<_CharT, _Alloc>
    operator+(std::ptrdiff_t __n,
	      const _Rope_const_iterator<_CharT, _Alloc>& __x);

  template<class _CharT, class _Alloc>
    bool
    operator==(const _Rope_const_iterator<_CharT, _Alloc>& __x,
	       const _Rope_const_iterator<_CharT, _Alloc>& __y);

  template<class _CharT, class _Alloc>
    bool
    operator<(const _Rope_const_iterator<_CharT, _Alloc>& __x,
	      const _Rope_const_iterator<_CharT, _Alloc>& __y);
  
  template<class _CharT, class _Alloc>
    std::ptrdiff_t
    operator-(const _Rope_const_iterator<_CharT, _Alloc>& __x,
	      const _Rope_const_iterator<_CharT, _Alloc>& __y);

  template<class _CharT, class _Alloc>
    _Rope_iterator<_CharT, _Alloc>
    operator-(const _Rope_iterator<_CharT, _Alloc>& __x, std::ptrdiff_t __n);

  template<class _CharT, class _Alloc>
    _Rope_iterator<_CharT, _Alloc>
    operator+(const _Rope_iterator<_CharT, _Alloc>& __x, std::ptrdiff_t __n);

  template<class _CharT, class _Alloc>
    _Rope_iterator<_CharT, _Alloc>
    operator+(std::ptrdiff_t __n, const _Rope_iterator<_CharT, _Alloc>& __x);

  template<class _CharT, class _Alloc>
    bool
    operator==(const _Rope_iterator<_CharT, _Alloc>& __x,
	       const _Rope_iterator<_CharT, _Alloc>& __y);

  template<class _CharT, class _Alloc>
    bool
    operator<(const _Rope_iterator<_CharT, _Alloc>& __x,
	      const _Rope_iterator<_CharT, _Alloc>& __y);

  template<class _CharT, class _Alloc>
    std::ptrdiff_t
    operator-(const _Rope_iterator<_CharT, _Alloc>& __x,
	      const _Rope_iterator<_CharT, _Alloc>& __y);

  template<class _CharT, class _Alloc>
    rope<_CharT, _Alloc>
    operator+(const rope<_CharT, _Alloc>& __left,
	      const rope<_CharT, _Alloc>& __right);

  template<class _CharT, class _Alloc>
    rope<_CharT, _Alloc>
    operator+(const rope<_CharT, _Alloc>& __left, const _CharT* __right);

  template<class _CharT, class _Alloc>
    rope<_CharT, _Alloc>
    operator+(const rope<_CharT, _Alloc>& __left, _CharT __right);

  // Some helpers, so we can use power on ropes.
  // See below for why this isn't local to the implementation.

// Ignore warnings about std::binary_function.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
  // This uses a nonstandard refcount convention.
  // The result has refcount 0.
  template<class _CharT, class _Alloc>
    struct _Rope_Concat_fn
    : public std::binary_function<rope<_CharT, _Alloc>, rope<_CharT, _Alloc>,
				  rope<_CharT, _Alloc> >
    {
      rope<_CharT, _Alloc>
      operator()(const rope<_CharT, _Alloc>& __x,
		 const rope<_CharT, _Alloc>& __y)
      { return __x + __y; }
    };
#pragma GCC diagnostic pop

  template <class _CharT, class _Alloc>
    inline rope<_CharT, _Alloc>
    identity_element(_Rope_Concat_fn<_CharT, _Alloc>)
    { return rope<_CharT, _Alloc>(); }

  // Class _Refcount_Base provides a type, _RC_t, a data member,
  // _M_ref_count, and member functions _M_incr and _M_decr, which perform
  // atomic preincrement/predecrement.  The constructor initializes
  // _M_ref_count.
  struct _Refcount_Base
  {
    // The type _RC_t
    typedef std::size_t _RC_t;
    
    // The data member _M_ref_count
    _RC_t _M_ref_count;

    // Constructor
#ifdef __GTHREAD_MUTEX_INIT
    __gthread_mutex_t _M_ref_count_lock = __GTHREAD_MUTEX_INIT;
#else
    __gthread_mutex_t _M_ref_count_lock;
#endif

    _Refcount_Base(_RC_t __n) : _M_ref_count(__n)
    {
#ifndef __GTHREAD_MUTEX_INIT
#ifdef __GTHREAD_MUTEX_INIT_FUNCTION
      __GTHREAD_MUTEX_INIT_FUNCTION (&_M_ref_count_lock);
#else
#error __GTHREAD_MUTEX_INIT or __GTHREAD_MUTEX_INIT_FUNCTION should be defined by gthr.h abstraction layer, report problem to libstdc++@@gcc.gnu.org.
#endif
#endif
    }

#ifndef __GTHREAD_MUTEX_INIT
    ~_Refcount_Base()
    { __gthread_mutex_destroy(&_M_ref_count_lock); }
#endif

    void
    _M_incr()
    {
      __gthread_mutex_lock(&_M_ref_count_lock);
      ++_M_ref_count;
      __gthread_mutex_unlock(&_M_ref_count_lock);
    }

    _RC_t
    _M_decr()
    {
      __gthread_mutex_lock(&_M_ref_count_lock);
      _RC_t __tmp = --_M_ref_count;
      __gthread_mutex_unlock(&_M_ref_count_lock);
      return __tmp;
    }
  };

  //
  // What follows should really be local to rope.  Unfortunately,
  // that doesn't work, since it makes it impossible to define generic
  // equality on rope iterators.  According to the draft standard, the
  // template parameters for such an equality operator cannot be inferred
  // from the occurrence of a member class as a parameter.
  // (SGI compilers in fact allow this, but the __result wouldn't be
  // portable.)
  // Similarly, some of the static member functions are member functions
  // only to avoid polluting the global namespace, and to circumvent
  // restrictions on type inference for template functions.
  //

  //
  // The internal data structure for representing a rope.  This is
  // private to the implementation.  A rope is really just a pointer
  // to one of these.
  //
  // A few basic functions for manipulating this data structure
  // are members of _RopeRep.  Most of the more complex algorithms
  // are implemented as rope members.
  //
  // Some of the static member functions of _RopeRep have identically
  // named functions in rope that simply invoke the _RopeRep versions.

#define __ROPE_DEFINE_ALLOCS(__a) \
        __ROPE_DEFINE_ALLOC(_CharT,_Data) /* character data */ \
        typedef _Rope_RopeConcatenation<_CharT,__a> __C; \
        __ROPE_DEFINE_ALLOC(__C,_C) \
        typedef _Rope_RopeLeaf<_CharT,__a> __L; \
        __ROPE_DEFINE_ALLOC(__L,_L) \
        typedef _Rope_RopeFunction<_CharT,__a> __F; \
        __ROPE_DEFINE_ALLOC(__F,_F) \
        typedef _Rope_RopeSubstring<_CharT,__a> __S; \
        __ROPE_DEFINE_ALLOC(__S,_S)

  //  Internal rope nodes potentially store a copy of the allocator
  //  instance used to allocate them.  This is mostly redundant.
  //  But the alternative would be to pass allocator instances around
  //  in some form to nearly all internal functions, since any pointer
  //  assignment may result in a zero reference count and thus require
  //  deallocation.

#define __STATIC_IF_SGI_ALLOC  /* not static */

  template <class _CharT, class _Alloc>
    struct _Rope_rep_base
    : public _Alloc
    {
      typedef std::size_t size_type;
      typedef _Alloc allocator_type;

      allocator_type
      get_allocator() const
      { return *static_cast<const _Alloc*>(this); }

      allocator_type&
      _M_get_allocator()
      { return *static_cast<_Alloc*>(this); }

      const allocator_type&
      _M_get_allocator() const
      { return *static_cast<const _Alloc*>(this); }

      _Rope_rep_base(size_type __size, const allocator_type&)
      : _M_size(__size) { }

      size_type _M_size;

# define __ROPE_DEFINE_ALLOC(_Tp, __name) \
        typedef typename \
          __alloc_traits<_Alloc>::template rebind<_Tp>::other __name##Alloc; \
        static _Tp* __name##_allocate(size_type __n) \
          { return __name##Alloc().allocate(__n); } \
        static void __name##_deallocate(_Tp *__p, size_type __n) \
          { __name##Alloc().deallocate(__p, __n); }
      __ROPE_DEFINE_ALLOCS(_Alloc)
# undef __ROPE_DEFINE_ALLOC
    };

  template<class _CharT, class _Alloc>
    struct _Rope_RopeRep
    : public _Rope_rep_base<_CharT, _Alloc>
# ifndef __GC
	     , _Refcount_Base
# endif
    {
    public:
      __detail::_Tag _M_tag:8;
      bool _M_is_balanced:8;
      unsigned char _M_depth;
      __GC_CONST _CharT* _M_c_string;
#ifdef __GTHREAD_MUTEX_INIT
      __gthread_mutex_t _M_c_string_lock = __GTHREAD_MUTEX_INIT;
#else
      __gthread_mutex_t _M_c_string_lock;
#endif
                        /* Flattened version of string, if needed.  */
                        /* typically 0.                             */
                        /* If it's not 0, then the memory is owned  */
                        /* by this node.                            */
                        /* In the case of a leaf, this may point to */
                        /* the same memory as the data field.       */
      typedef typename _Rope_rep_base<_CharT, _Alloc>::allocator_type
        allocator_type;
      typedef std::size_t size_type;

      using _Rope_rep_base<_CharT, _Alloc>::get_allocator;
      using _Rope_rep_base<_CharT, _Alloc>::_M_get_allocator;

      _Rope_RopeRep(__detail::_Tag __t, int __d, bool __b, size_type __size,
		    const allocator_type& __a)
      : _Rope_rep_base<_CharT, _Alloc>(__size, __a),
#ifndef __GC
	_Refcount_Base(1),
#endif
	_M_tag(__t), _M_is_balanced(__b), _M_depth(__d), _M_c_string(0)
#ifdef __GTHREAD_MUTEX_INIT
      { }
#else
      { __GTHREAD_MUTEX_INIT_FUNCTION (&_M_c_string_lock); }
      ~_Rope_RopeRep()
      { __gthread_mutex_destroy (&_M_c_string_lock); }
#endif
#ifdef __GC
      void
      _M_incr () { }
#endif
      static void
      _S_free_string(__GC_CONST _CharT*, size_type __len,
		     allocator_type& __a);
#define __STL_FREE_STRING(__s, __l, __a) _S_free_string(__s, __l, __a);
                        // Deallocate data section of a leaf.
                        // This shouldn't be a member function.
                        // But its hard to do anything else at the
                        // moment, because it's templatized w.r.t.
                        // an allocator.
                        // Does nothing if __GC is defined.
#ifndef __GC
      void _M_free_c_string();
      void _M_free_tree();
      // Deallocate t. Assumes t is not 0.
      void
      _M_unref_nonnil()
      {
	if (0 == _M_decr())
	  _M_free_tree();
      }

      void
      _M_ref_nonnil()
      { _M_incr(); }

      static void
      _S_unref(_Rope_RopeRep* __t)
      {
	if (0 != __t)
	  __t->_M_unref_nonnil();
      }

      static void
      _S_ref(_Rope_RopeRep* __t)
      {
	if (0 != __t)
	  __t->_M_incr();
      }
      
      static void
      _S_free_if_unref(_Rope_RopeRep* __t)
      {
	if (0 != __t && 0 == __t->_M_ref_count)
	  __t->_M_free_tree();
      }
#   else /* __GC */
      void _M_unref_nonnil() { }
      void _M_ref_nonnil() { }
      static void _S_unref(_Rope_RopeRep*) { }
      static void _S_ref(_Rope_RopeRep*) { }
      static void _S_free_if_unref(_Rope_RopeRep*) { }
#   endif
    protected:
      _Rope_RopeRep&
      operator=(const _Rope_RopeRep&);

      _Rope_RopeRep(const _Rope_RopeRep&);
    };

  template<class _CharT, class _Alloc>
    struct _Rope_RopeLeaf
    : public _Rope_RopeRep<_CharT, _Alloc>
    {
      typedef std::size_t size_type;
    public:
      // Apparently needed by VC++
      // The data fields of leaves are allocated with some
      // extra space, to accommodate future growth and for basic
      // character types, to hold a trailing eos character.
      enum { _S_alloc_granularity = 8 };
      
      static size_type
      _S_rounded_up_size(size_type __n)
      {
        size_type __size_with_eos;
	
        if (_S_is_basic_char_type((_CharT*)0))
	  __size_with_eos = __n + 1;
	else
	  __size_with_eos = __n;
#ifdef __GC
	return __size_with_eos;
#else
	// Allow slop for in-place expansion.
	return ((__size_with_eos + size_type(_S_alloc_granularity) - 1)
		&~ (size_type(_S_alloc_granularity) - 1));
#endif
      }
      __GC_CONST _CharT* _M_data; /* Not necessarily 0 terminated. */
                                  /* The allocated size is         */
                                  /* _S_rounded_up_size(size), except */
                                  /* in the GC case, in which it   */
                                  /* doesn't matter.               */
      typedef typename _Rope_rep_base<_CharT,_Alloc>::allocator_type
        allocator_type;

      _Rope_RopeLeaf(__GC_CONST _CharT* __d, size_type __size,
		     const allocator_type& __a)
      : _Rope_RopeRep<_CharT, _Alloc>(__detail::_S_leaf, 0, true,
				      __size, __a), _M_data(__d)
      {
        if (_S_is_basic_char_type((_CharT *)0))
	  {
            // already eos terminated.
            this->_M_c_string = __d;
	  }
      }
      // The constructor assumes that d has been allocated with
      // the proper allocator and the properly padded size.
      // In contrast, the destructor deallocates the data:
#ifndef __GC
      ~_Rope_RopeLeaf() throw()
      {
        if (_M_data != this->_M_c_string)
	  this->_M_free_c_string();
	
	this->__STL_FREE_STRING(_M_data, this->_M_size, this->_M_get_allocator());
      }
#endif
    protected:
      _Rope_RopeLeaf&
      operator=(const _Rope_RopeLeaf&);

      _Rope_RopeLeaf(const _Rope_RopeLeaf&);
    };

  template<class _CharT, class _Alloc>
    struct _Rope_RopeConcatenation
    : public _Rope_RopeRep<_CharT, _Alloc>
    {
    public:
      _Rope_RopeRep<_CharT, _Alloc>* _M_left;
      _Rope_RopeRep<_CharT, _Alloc>* _M_right;

      typedef typename _Rope_rep_base<_CharT, _Alloc>::allocator_type
        allocator_type;

      _Rope_RopeConcatenation(_Rope_RopeRep<_CharT, _Alloc>* __l,
			      _Rope_RopeRep<_CharT, _Alloc>* __r,
			      const allocator_type& __a)
	: _Rope_RopeRep<_CharT, _Alloc>(__detail::_S_concat,
				      std::max(__l->_M_depth,
					       __r->_M_depth) + 1,
				      false,
				      __l->_M_size + __r->_M_size, __a),
        _M_left(__l), _M_right(__r)
      { }
#ifndef __GC
      ~_Rope_RopeConcatenation() throw()
      {
	this->_M_free_c_string();
	_M_left->_M_unref_nonnil();
	_M_right->_M_unref_nonnil();
      }
#endif
    protected:
      _Rope_RopeConcatenation&
      operator=(const _Rope_RopeConcatenation&);
      
      _Rope_RopeConcatenation(const _Rope_RopeConcatenation&);
    };

  template<class _CharT, class _Alloc>
    struct _Rope_RopeFunction
    : public _Rope_RopeRep<_CharT, _Alloc>
    {
    public:
      char_producer<_CharT>* _M_fn;
#ifndef __GC
      bool _M_delete_when_done; // Char_producer is owned by the
                                // rope and should be explicitly
                                // deleted when the rope becomes
                                // inaccessible.
#else
      // In the GC case, we either register the rope for
      // finalization, or not.  Thus the field is unnecessary;
      // the information is stored in the collector data structures.
      // We do need a finalization procedure to be invoked by the
      // collector.
      static void
      _S_fn_finalization_proc(void * __tree, void *)
      { delete ((_Rope_RopeFunction *)__tree) -> _M_fn; }
#endif
    typedef typename _Rope_rep_base<_CharT, _Alloc>::allocator_type
      allocator_type;

      _Rope_RopeFunction(char_producer<_CharT>* __f, std::size_t __size,
                        bool __d, const allocator_type& __a)
      : _Rope_RopeRep<_CharT, _Alloc>(__detail::_S_function, 0, true, __size, __a)
	, _M_fn(__f)
#ifndef __GC
	, _M_delete_when_done(__d)
#endif
      {
#ifdef __GC
	if (__d)
	  {
	    GC_REGISTER_FINALIZER(this, _Rope_RopeFunction::
				  _S_fn_finalization_proc, 0, 0, 0);
	  }
#endif
      }
#ifndef __GC
      ~_Rope_RopeFunction() throw()
      {
	this->_M_free_c_string();
	if (_M_delete_when_done)
	  delete _M_fn;
      }
# endif
    protected:
      _Rope_RopeFunction&
      operator=(const _Rope_RopeFunction&);

      _Rope_RopeFunction(const _Rope_RopeFunction&);
    };
  // Substring results are usually represented using just
  // concatenation nodes.  But in the case of very long flat ropes
  // or ropes with a functional representation that isn't practical.
  // In that case, we represent the __result as a special case of
  // RopeFunction, whose char_producer points back to the rope itself.
  // In all cases except repeated substring operations and
  // deallocation, we treat the __result as a RopeFunction.
  template<class _CharT, class _Alloc>
    struct _Rope_RopeSubstring
    : public _Rope_RopeFunction<_CharT, _Alloc>,
      public char_producer<_CharT>
    {
      typedef std::size_t size_type;
    public:
      // XXX this whole class should be rewritten.
      _Rope_RopeRep<_CharT,_Alloc>* _M_base;      // not 0
      size_type _M_start;

      virtual void
      operator()(size_type __start_pos, size_type __req_len,
		 _CharT* __buffer)
      {
        switch(_M_base->_M_tag)
	  {
	  case __detail::_S_function:
	  case __detail::_S_substringfn:
	    {
	      char_producer<_CharT>* __fn =
		((_Rope_RopeFunction<_CharT,_Alloc>*)_M_base)->_M_fn;
	      (*__fn)(__start_pos + _M_start, __req_len, __buffer);
	    }
	    break;
	  case __detail::_S_leaf:
	    {
	      __GC_CONST _CharT* __s =
		((_Rope_RopeLeaf<_CharT,_Alloc>*)_M_base)->_M_data;
	      uninitialized_copy_n(__s + __start_pos + _M_start, __req_len,
				   __buffer);
	    }
	    break;
	  default:
	    break;
	  }
      }
      
      typedef typename _Rope_rep_base<_CharT, _Alloc>::allocator_type
        allocator_type;

      _Rope_RopeSubstring(_Rope_RopeRep<_CharT, _Alloc>* __b, size_type __s,
                          size_type __l, const allocator_type& __a)
      : _Rope_RopeFunction<_CharT, _Alloc>(this, __l, false, __a),
        char_producer<_CharT>(), _M_base(__b), _M_start(__s)
      {
#ifndef __GC
	_M_base->_M_ref_nonnil();
#endif
        this->_M_tag = __detail::_S_substringfn;
      }
    virtual ~_Rope_RopeSubstring() throw()
      {
#ifndef __GC
	_M_base->_M_unref_nonnil();
	// _M_free_c_string();  -- done by parent class
#endif
      }
    };

  // Self-destructing pointers to Rope_rep.
  // These are not conventional smart pointers.  Their
  // only purpose in life is to ensure that unref is called
  // on the pointer either at normal exit or if an exception
  // is raised.  It is the caller's responsibility to
  // adjust reference counts when these pointers are initialized
  // or assigned to.  (This convention significantly reduces
  // the number of potentially expensive reference count
  // updates.)
#ifndef __GC
  template<class _CharT, class _Alloc>
    struct _Rope_self_destruct_ptr
    {
      _Rope_RopeRep<_CharT, _Alloc>* _M_ptr;

      ~_Rope_self_destruct_ptr()
      { _Rope_RopeRep<_CharT, _Alloc>::_S_unref(_M_ptr); }
#if __cpp_exceptions
      _Rope_self_destruct_ptr() : _M_ptr(0) { }
#else
      _Rope_self_destruct_ptr() { }
#endif
      _Rope_self_destruct_ptr(_Rope_RopeRep<_CharT, _Alloc>* __p)
      : _M_ptr(__p) { }
    
      _Rope_RopeRep<_CharT, _Alloc>&
      operator*()
      { return *_M_ptr; }
    
      _Rope_RopeRep<_CharT, _Alloc>*
      operator->()
      { return _M_ptr; }
    
      operator _Rope_RopeRep<_CharT, _Alloc>*()
      { return _M_ptr; }
    
      _Rope_self_destruct_ptr&
      operator=(_Rope_RopeRep<_CharT, _Alloc>* __x)
      { _M_ptr = __x; return *this; }
    };
#endif

  // Dereferencing a nonconst iterator has to return something
  // that behaves almost like a reference.  It's not possible to
  // return an actual reference since assignment requires extra
  // work.  And we would get into the same problems as with the
  // CD2 version of basic_string.
  template<class _CharT, class _Alloc>
    class _Rope_char_ref_proxy
    {
      friend class rope<_CharT, _Alloc>;
      friend class _Rope_iterator<_CharT, _Alloc>;
      friend class _Rope_char_ptr_proxy<_CharT, _Alloc>;
#ifdef __GC
      typedef _Rope_RopeRep<_CharT, _Alloc>* _Self_destruct_ptr;
#else
      typedef _Rope_self_destruct_ptr<_CharT, _Alloc> _Self_destruct_ptr;
#endif
      typedef _Rope_RopeRep<_CharT, _Alloc> _RopeRep;
      typedef rope<_CharT, _Alloc> _My_rope;
      std::size_t _M_pos;
      _CharT _M_current;
      bool _M_current_valid;
      _My_rope* _M_root;     // The whole rope.
    public:
      _Rope_char_ref_proxy(_My_rope* __r, std::size_t __p)
      :  _M_pos(__p), _M_current(), _M_current_valid(false), _M_root(__r) { }

      _Rope_char_ref_proxy(const _Rope_char_ref_proxy& __x)
      : _M_pos(__x._M_pos), _M_current(__x._M_current), 
	_M_current_valid(false), _M_root(__x._M_root) { }

      // Don't preserve cache if the reference can outlive the
      // expression.  We claim that's not possible without calling
      // a copy constructor or generating reference to a proxy
      // reference.  We declare the latter to have undefined semantics.
      _Rope_char_ref_proxy(_My_rope* __r, std::size_t __p, _CharT __c)
      : _M_pos(__p), _M_current(__c), _M_current_valid(true), _M_root(__r) { }

      inline operator _CharT () const;

      _Rope_char_ref_proxy&
      operator=(_CharT __c);
    
      _Rope_char_ptr_proxy<_CharT, _Alloc> operator&() const;
      
      _Rope_char_ref_proxy&
      operator=(const _Rope_char_ref_proxy& __c)
      { return operator=((_CharT)__c); }
    };

  template<class _CharT, class __Alloc>
    inline void
    swap(_Rope_char_ref_proxy <_CharT, __Alloc > __a,
	 _Rope_char_ref_proxy <_CharT, __Alloc > __b)
    {
      _CharT __tmp = __a;
      __a = __b;
      __b = __tmp;
    }

  template<class _CharT, class _Alloc>
    class _Rope_char_ptr_proxy
    {
      // XXX this class should be rewritten.
      friend class _Rope_char_ref_proxy<_CharT, _Alloc>;
      std::size_t _M_pos;
      rope<_CharT,_Alloc>* _M_root;     // The whole rope.
    public:
      _Rope_char_ptr_proxy(const _Rope_char_ref_proxy<_CharT,_Alloc>& __x)
      : _M_pos(__x._M_pos), _M_root(__x._M_root) { }

      _Rope_char_ptr_proxy(const _Rope_char_ptr_proxy& __x)
      : _M_pos(__x._M_pos), _M_root(__x._M_root) { }

      _Rope_char_ptr_proxy() { }
      
      _Rope_char_ptr_proxy(_CharT* __x)
      : _M_root(0), _M_pos(0) { }

      _Rope_char_ptr_proxy&
      operator=(const _Rope_char_ptr_proxy& __x)
      {
        _M_pos = __x._M_pos;
        _M_root = __x._M_root;
        return *this;
      }

      template<class _CharT2, class _Alloc2>
        friend bool
        operator==(const _Rope_char_ptr_proxy<_CharT2, _Alloc2>& __x,
		   const _Rope_char_ptr_proxy<_CharT2, _Alloc2>& __y);

      _Rope_char_ref_proxy<_CharT, _Alloc> operator*() const
      { return _Rope_char_ref_proxy<_CharT, _Alloc>(_M_root, _M_pos); }
    };

  // Rope iterators:
  // Unlike in the C version, we cache only part of the stack
  // for rope iterators, since they must be efficiently copyable.
  // When we run out of cache, we have to reconstruct the iterator
  // value.
  // Pointers from iterators are not included in reference counts.
  // Iterators are assumed to be thread private.  Ropes can
  // be shared.
  
// Ignore warnings about std::iterator
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
  template<class _CharT, class _Alloc>
    class _Rope_iterator_base
    : public std::iterator<std::random_access_iterator_tag, _CharT>
    {
      friend class rope<_CharT, _Alloc>;
    public:
      typedef _Alloc _allocator_type; // used in _Rope_rotate, VC++ workaround
      typedef _Rope_RopeRep<_CharT, _Alloc> _RopeRep;
      // Borland doesn't want this to be protected.
    protected:
      enum { _S_path_cache_len = 4 }; // Must be <= 9.
      enum { _S_iterator_buf_len = 15 };
      std::size_t _M_current_pos;
      _RopeRep* _M_root;     // The whole rope.
      std::size_t _M_leaf_pos; // Starting position for current leaf
      __GC_CONST _CharT* _M_buf_start;
                             // Buffer possibly
                             // containing current char.
      __GC_CONST _CharT* _M_buf_ptr;
                             // Pointer to current char in buffer.
                             // != 0 ==> buffer valid.
      __GC_CONST _CharT* _M_buf_end;
                             // One past __last valid char in buffer.
      // What follows is the path cache.  We go out of our
      // way to make this compact.
      // Path_end contains the bottom section of the path from
      // the root to the current leaf.
      const _RopeRep* _M_path_end[_S_path_cache_len];
      int _M_leaf_index;     // Last valid __pos in path_end;
                             // _M_path_end[0] ... _M_path_end[leaf_index-1]
                             // point to concatenation nodes.
      unsigned char _M_path_directions;
                          // (path_directions >> __i) & 1 is 1
                          // iff we got from _M_path_end[leaf_index - __i - 1]
                          // to _M_path_end[leaf_index - __i] by going to the
                          // __right. Assumes path_cache_len <= 9.
      _CharT _M_tmp_buf[_S_iterator_buf_len];
                        // Short buffer for surrounding chars.
                        // This is useful primarily for
                        // RopeFunctions.  We put the buffer
                        // here to avoid locking in the
                        // multithreaded case.
      // The cached path is generally assumed to be valid
      // only if the buffer is valid.
      static void _S_setbuf(_Rope_iterator_base& __x);
                                        // Set buffer contents given
                                        // path cache.
      static void _S_setcache(_Rope_iterator_base& __x);
                                        // Set buffer contents and
                                        // path cache.
      static void _S_setcache_for_incr(_Rope_iterator_base& __x);
                                        // As above, but assumes path
                                        // cache is valid for previous posn.
      _Rope_iterator_base() { }

      _Rope_iterator_base(_RopeRep* __root, std::size_t __pos)
      : _M_current_pos(__pos), _M_root(__root), _M_buf_ptr(0) { }

      void _M_incr(std::size_t __n);
      void _M_decr(std::size_t __n);
    public:
      std::size_t
      index() const
      { return _M_current_pos; }
    
      _Rope_iterator_base(const _Rope_iterator_base& __x)
      {
        if (0 != __x._M_buf_ptr && __x._M_buf_start != __x._M_tmp_buf)
	  *this = __x;
	else
	  {
            _M_current_pos = __x._M_current_pos;
            _M_root = __x._M_root;
            _M_buf_ptr = 0;
	  }
      }
    };
#pragma GCC diagnostic pop

  template<class _CharT, class _Alloc>
    class _Rope_iterator;

  template<class _CharT, class _Alloc>
    class _Rope_const_iterator
    : public _Rope_iterator_base<_CharT, _Alloc>
    {
      friend class rope<_CharT, _Alloc>;
    protected:
      typedef _Rope_RopeRep<_CharT, _Alloc> _RopeRep;
      // The one from the base class may not be directly visible.
      _Rope_const_iterator(const _RopeRep* __root, std::size_t __pos)
      : _Rope_iterator_base<_CharT, _Alloc>(const_cast<_RopeRep*>(__root),
					    __pos)
                   // Only nonconst iterators modify root ref count
      { }
  public:
      typedef _CharT reference;   // Really a value.  Returning a reference
                                  // Would be a mess, since it would have
                                  // to be included in refcount.
      typedef const _CharT* pointer;

    public:
      _Rope_const_iterator() { }

      _Rope_const_iterator(const _Rope_const_iterator& __x)
      : _Rope_iterator_base<_CharT,_Alloc>(__x) { }

      _Rope_const_iterator(const _Rope_iterator<_CharT,_Alloc>& __x);
    
      _Rope_const_iterator(const rope<_CharT, _Alloc>& __r, std::size_t __pos)
      : _Rope_iterator_base<_CharT,_Alloc>(__r._M_tree_ptr, __pos) { }

      _Rope_const_iterator&
      operator=(const _Rope_const_iterator& __x)
      {
        if (0 != __x._M_buf_ptr && __x._M_buf_start != __x._M_tmp_buf)
	  *(static_cast<_Rope_iterator_base<_CharT, _Alloc>*>(this)) = __x;
	else
	  {
            this->_M_current_pos = __x._M_current_pos;
            this->_M_root = __x._M_root;
            this->_M_buf_ptr = 0;
	  }
        return(*this);
      }

      reference
      operator*()
      {
        if (0 == this->_M_buf_ptr)
	  this->_S_setcache(*this);
        return *this->_M_buf_ptr;
      }

      // Without this const version, Rope iterators do not meet the
      // requirements of an Input Iterator.
      reference
      operator*() const
      {
	return *const_cast<_Rope_const_iterator&>(*this);
      }

      _Rope_const_iterator&
      operator++()
      {
        __GC_CONST _CharT* __next;
        if (0 != this->_M_buf_ptr
	    && (__next = this->_M_buf_ptr + 1) < this->_M_buf_end)
	  {
            this->_M_buf_ptr = __next;
            ++this->_M_current_pos;
	  }
	else
	  this->_M_incr(1);
	return *this;
      }

      _Rope_const_iterator&
      operator+=(std::ptrdiff_t __n)
      {
        if (__n >= 0)
	  this->_M_incr(__n);
	else
	  this->_M_decr(-__n);
	return *this;
      }

      _Rope_const_iterator&
      operator--()
      {
        this->_M_decr(1);
        return *this;
      }

      _Rope_const_iterator&
      operator-=(std::ptrdiff_t __n)
      {
        if (__n >= 0)
	  this->_M_decr(__n);
	else
	  this->_M_incr(-__n);
	return *this;
      }

      _Rope_const_iterator
      operator++(int)
      {
	std::size_t __old_pos = this->_M_current_pos;
        this->_M_incr(1);
        return _Rope_const_iterator<_CharT,_Alloc>(this->_M_root, __old_pos);
        // This makes a subsequent dereference expensive.
        // Perhaps we should instead copy the iterator
        // if it has a valid cache?
      }

      _Rope_const_iterator
      operator--(int)
      {
	std::size_t __old_pos = this->_M_current_pos;
        this->_M_decr(1);
        return _Rope_const_iterator<_CharT,_Alloc>(this->_M_root, __old_pos);
      }

      template<class _CharT2, class _Alloc2>
        friend _Rope_const_iterator<_CharT2, _Alloc2>
        operator-(const _Rope_const_iterator<_CharT2, _Alloc2>& __x,
		  std::ptrdiff_t __n);

      template<class _CharT2, class _Alloc2>
        friend _Rope_const_iterator<_CharT2, _Alloc2>
        operator+(const _Rope_const_iterator<_CharT2, _Alloc2>& __x,
		  std::ptrdiff_t __n);

      template<class _CharT2, class _Alloc2>
        friend _Rope_const_iterator<_CharT2, _Alloc2>
        operator+(std::ptrdiff_t __n,
		  const _Rope_const_iterator<_CharT2, _Alloc2>& __x);

      reference
      operator[](std::size_t __n)
      { return rope<_CharT, _Alloc>::_S_fetch(this->_M_root,
					      this->_M_current_pos + __n); }

      template<class _CharT2, class _Alloc2>
        friend bool
        operator==(const _Rope_const_iterator<_CharT2, _Alloc2>& __x,
		   const _Rope_const_iterator<_CharT2, _Alloc2>& __y);

      template<class _CharT2, class _Alloc2>
        friend bool
        operator<(const _Rope_const_iterator<_CharT2, _Alloc2>& __x,
		  const _Rope_const_iterator<_CharT2, _Alloc2>& __y);

      template<class _CharT2, class _Alloc2>
        friend std::ptrdiff_t
        operator-(const _Rope_const_iterator<_CharT2, _Alloc2>& __x,
		  const _Rope_const_iterator<_CharT2, _Alloc2>& __y);
    };

  template<class _CharT, class _Alloc>
    class _Rope_iterator
    : public _Rope_iterator_base<_CharT, _Alloc>
    {
      friend class rope<_CharT, _Alloc>;
    protected:
      typedef typename _Rope_iterator_base<_CharT, _Alloc>::_RopeRep _RopeRep;
      rope<_CharT, _Alloc>* _M_root_rope;

      // root is treated as a cached version of this, and is used to
      // detect changes to the underlying rope.

      // Root is included in the reference count.  This is necessary
      // so that we can detect changes reliably.  Unfortunately, it
      // requires careful bookkeeping for the nonGC case.
      _Rope_iterator(rope<_CharT, _Alloc>* __r, std::size_t __pos)
      : _Rope_iterator_base<_CharT, _Alloc>(__r->_M_tree_ptr, __pos),
        _M_root_rope(__r)
      { _RopeRep::_S_ref(this->_M_root);
        if (!(__r -> empty()))
	  this->_S_setcache(*this);
      }

      void _M_check();
    public:
      typedef _Rope_char_ref_proxy<_CharT, _Alloc>  reference;
      typedef _Rope_char_ref_proxy<_CharT, _Alloc>* pointer;

      rope<_CharT, _Alloc>&
      container()
      { return *_M_root_rope; }

      _Rope_iterator()
      {
        this->_M_root = 0;  // Needed for reference counting.
      }

      _Rope_iterator(const _Rope_iterator& __x)
      : _Rope_iterator_base<_CharT, _Alloc>(__x)
      {
        _M_root_rope = __x._M_root_rope;
        _RopeRep::_S_ref(this->_M_root);
      }

      _Rope_iterator(rope<_CharT, _Alloc>& __r, std::size_t __pos);

      ~_Rope_iterator()
      { _RopeRep::_S_unref(this->_M_root); }

      _Rope_iterator&
      operator=(const _Rope_iterator& __x)
      {
        _RopeRep* __old = this->_M_root;
	
        _RopeRep::_S_ref(__x._M_root);
        if (0 != __x._M_buf_ptr && __x._M_buf_start != __x._M_tmp_buf)
	  {
            _M_root_rope = __x._M_root_rope;
            *(static_cast<_Rope_iterator_base<_CharT, _Alloc>*>(this)) = __x;
	  }
	else
	  {
	    this->_M_current_pos = __x._M_current_pos;
            this->_M_root = __x._M_root;
            _M_root_rope = __x._M_root_rope;
            this->_M_buf_ptr = 0;
	  }
        _RopeRep::_S_unref(__old);
        return(*this);
      }

      reference
      operator*()
      {
        _M_check();
        if (0 == this->_M_buf_ptr)
	  return _Rope_char_ref_proxy<_CharT, _Alloc>(_M_root_rope,
						      this->_M_current_pos);
	else
	  return _Rope_char_ref_proxy<_CharT, _Alloc>(_M_root_rope,
						      this->_M_current_pos,
						      *this->_M_buf_ptr);
      }

      // See above comment.
      reference
      operator*() const
      {
	return *const_cast<_Rope_iterator&>(*this);
      }

      _Rope_iterator&
      operator++()
      {
        this->_M_incr(1);
        return *this;
      }

      _Rope_iterator&
      operator+=(std::ptrdiff_t __n)
      {
        if (__n >= 0)
	  this->_M_incr(__n);
	else
	  this->_M_decr(-__n);
	return *this;
      }

      _Rope_iterator&
      operator--()
      {
        this->_M_decr(1);
        return *this;
      }

      _Rope_iterator&
      operator-=(std::ptrdiff_t __n)
      {
        if (__n >= 0)
	  this->_M_decr(__n);
	else
	  this->_M_incr(-__n);
	return *this;
      }

      _Rope_iterator
      operator++(int)
      {
	std::size_t __old_pos = this->_M_current_pos;
        this->_M_incr(1);
        return _Rope_iterator<_CharT,_Alloc>(_M_root_rope, __old_pos);
      }

      _Rope_iterator
      operator--(int)
      {
	std::size_t __old_pos = this->_M_current_pos;
        this->_M_decr(1);
        return _Rope_iterator<_CharT,_Alloc>(_M_root_rope, __old_pos);
      }

      reference
      operator[](std::ptrdiff_t __n)
      { return _Rope_char_ref_proxy<_CharT, _Alloc>(_M_root_rope,
						    this->_M_current_pos
						    + __n); }

      template<class _CharT2, class _Alloc2>
        friend bool
        operator==(const _Rope_iterator<_CharT2, _Alloc2>& __x,
		   const _Rope_iterator<_CharT2, _Alloc2>& __y);

      template<class _CharT2, class _Alloc2>
        friend bool
        operator<(const _Rope_iterator<_CharT2, _Alloc2>& __x,
		  const _Rope_iterator<_CharT2, _Alloc2>& __y);

      template<class _CharT2, class _Alloc2>
        friend std::ptrdiff_t
        operator-(const _Rope_iterator<_CharT2, _Alloc2>& __x,
		  const _Rope_iterator<_CharT2, _Alloc2>& __y);

      template<class _CharT2, class _Alloc2>
        friend _Rope_iterator<_CharT2, _Alloc2>
        operator-(const _Rope_iterator<_CharT2, _Alloc2>& __x,
		  std::ptrdiff_t __n);

      template<class _CharT2, class _Alloc2>
        friend _Rope_iterator<_CharT2, _Alloc2>
        operator+(const _Rope_iterator<_CharT2, _Alloc2>& __x,
		  std::ptrdiff_t __n);

      template<class _CharT2, class _Alloc2>
        friend _Rope_iterator<_CharT2, _Alloc2>
        operator+(std::ptrdiff_t __n,
		  const _Rope_iterator<_CharT2, _Alloc2>& __x);
    };


  template <class _CharT, class _Alloc>
    struct _Rope_base
    : public _Alloc
    {
      typedef _Alloc allocator_type;

      allocator_type
      get_allocator() const
      { return *static_cast<const _Alloc*>(this); }

      allocator_type&
      _M_get_allocator()
      { return *static_cast<_Alloc*>(this); }

      const allocator_type&
      _M_get_allocator() const
      { return *static_cast<const _Alloc*>(this); }

      typedef _Rope_RopeRep<_CharT, _Alloc> _RopeRep;
      // The one in _Base may not be visible due to template rules.

      _Rope_base(_RopeRep* __t, const allocator_type&)
      : _M_tree_ptr(__t) { }

      _Rope_base(const allocator_type&) { }

      // The only data member of a rope:
      _RopeRep *_M_tree_ptr;

#define __ROPE_DEFINE_ALLOC(_Tp, __name) \
        typedef typename \
          __alloc_traits<_Alloc>::template rebind<_Tp>::other __name##Alloc; \
        static _Tp* __name##_allocate(std::size_t __n) \
          { return __name##Alloc().allocate(__n); } \
        static void __name##_deallocate(_Tp *__p, std::size_t __n) \
          { __name##Alloc().deallocate(__p, __n); }
      __ROPE_DEFINE_ALLOCS(_Alloc)
#undef __ROPE_DEFINE_ALLOC

    protected:
      _Rope_base&
      operator=(const _Rope_base&);
      
      _Rope_base(const _Rope_base&);
    };

  /**
   *  This is an SGI extension.
   *  @@ingroup SGIextensions
   *  @@doctodo
   */
  template <class _CharT, class _Alloc>
    class rope : public _Rope_base<_CharT, _Alloc>
    {
    public:
      typedef _CharT value_type;
      typedef std::ptrdiff_t difference_type;
      typedef std::size_t size_type;
      typedef _CharT const_reference;
      typedef const _CharT* const_pointer;
      typedef _Rope_iterator<_CharT, _Alloc> iterator;
      typedef _Rope_const_iterator<_CharT, _Alloc> const_iterator;
      typedef _Rope_char_ref_proxy<_CharT, _Alloc> reference;
      typedef _Rope_char_ptr_proxy<_CharT, _Alloc> pointer;

      friend class _Rope_iterator<_CharT, _Alloc>;
      friend class _Rope_const_iterator<_CharT, _Alloc>;
      friend struct _Rope_RopeRep<_CharT, _Alloc>;
      friend class _Rope_iterator_base<_CharT, _Alloc>;
      friend class _Rope_char_ptr_proxy<_CharT, _Alloc>;
      friend class _Rope_char_ref_proxy<_CharT, _Alloc>;
      friend struct _Rope_RopeSubstring<_CharT, _Alloc>;

    protected:
      typedef _Rope_base<_CharT, _Alloc> _Base;
      typedef typename _Base::allocator_type allocator_type;
      using _Base::_M_tree_ptr;
      using _Base::get_allocator;
      using _Base::_M_get_allocator;
      typedef __GC_CONST _CharT* _Cstrptr;
      
      static _CharT _S_empty_c_str[1];
      
      static bool
      _S_is0(_CharT __c)
      { return __c == _S_eos((_CharT*)0); }
      
      enum { _S_copy_max = 23 };
                // For strings shorter than _S_copy_max, we copy to
                // concatenate.

      typedef _Rope_RopeRep<_CharT, _Alloc> _RopeRep;
      typedef _Rope_RopeConcatenation<_CharT, _Alloc> _RopeConcatenation;
      typedef _Rope_RopeLeaf<_CharT, _Alloc> _RopeLeaf;
      typedef _Rope_RopeFunction<_CharT, _Alloc> _RopeFunction;
      typedef _Rope_RopeSubstring<_CharT, _Alloc> _RopeSubstring;

      // Retrieve a character at the indicated position.
      static _CharT _S_fetch(_RopeRep* __r, size_type __pos);

#ifndef __GC
      // Obtain a pointer to the character at the indicated position.
      // The pointer can be used to change the character.
      // If such a pointer cannot be produced, as is frequently the
      // case, 0 is returned instead.
      // (Returns nonzero only if all nodes in the path have a refcount
      // of 1.)
      static _CharT* _S_fetch_ptr(_RopeRep* __r, size_type __pos);
#endif

      static bool
      _S_apply_to_pieces(// should be template parameter
			 _Rope_char_consumer<_CharT>& __c,
			 const _RopeRep* __r,
			 size_type __begin, size_type __end);
                         // begin and end are assumed to be in range.

#ifndef __GC
      static void
      _S_unref(_RopeRep* __t)
      { _RopeRep::_S_unref(__t); }

      static void
      _S_ref(_RopeRep* __t)
      { _RopeRep::_S_ref(__t); }

#else /* __GC */
      static void _S_unref(_RopeRep*) { }
      static void _S_ref(_RopeRep*) { }
#endif

#ifdef __GC
      typedef _Rope_RopeRep<_CharT, _Alloc>* _Self_destruct_ptr;
#else
      typedef _Rope_self_destruct_ptr<_CharT, _Alloc> _Self_destruct_ptr;
#endif

      // _Result is counted in refcount.
      static _RopeRep* _S_substring(_RopeRep* __base,
                                    size_type __start, size_type __endp1);

      static _RopeRep* _S_concat_char_iter(_RopeRep* __r,
					   const _CharT* __iter,
					   size_type __slen,
					   allocator_type& __a);
      // Concatenate rope and char ptr, copying __iter.
      // Should really take an arbitrary iterator.
      // Result is counted in refcount.
      static _RopeRep* _S_destr_concat_char_iter(_RopeRep* __r,
						 const _CharT* __iter,
						 size_type __slen,
						 allocator_type& __a)
	// As above, but one reference to __r is about to be
	// destroyed.  Thus the pieces may be recycled if all
	// relevant reference counts are 1.
#ifdef __GC
	// We can't really do anything since refcounts are unavailable.
      { return _S_concat_char_iter(__r, __iter, __slen, __a); }
#else
      ;
#endif

      static _RopeRep* _S_concat(_RopeRep* __left, _RopeRep* __right);
      // General concatenation on _RopeRep.  _Result
      // has refcount of 1.  Adjusts argument refcounts.

   public:
      void
      apply_to_pieces(size_type __begin, size_type __end,
		      _Rope_char_consumer<_CharT>& __c) const
      { _S_apply_to_pieces(__c, this->_M_tree_ptr, __begin, __end); }

   protected:

      static size_type
      _S_rounded_up_size(size_type __n)
      { return _RopeLeaf::_S_rounded_up_size(__n); }

      static size_type
      _S_allocated_capacity(size_type __n)
      {
	if (_S_is_basic_char_type((_CharT*)0))
	  return _S_rounded_up_size(__n) - 1;
	else
	  return _S_rounded_up_size(__n);
	
      }

      // Allocate and construct a RopeLeaf using the supplied allocator
      // Takes ownership of s instead of copying.
      static _RopeLeaf*
      _S_new_RopeLeaf(__GC_CONST _CharT *__s,
		      size_type __size, allocator_type& __a)
      {
	_RopeLeaf* __space = typename _Base::_LAlloc(__a).allocate(1);
	return new(__space) _RopeLeaf(__s, __size, __a);
      }

      static _RopeConcatenation*
      _S_new_RopeConcatenation(_RopeRep* __left, _RopeRep* __right,
			       allocator_type& __a)
      {
	_RopeConcatenation* __space = typename _Base::_CAlloc(__a).allocate(1);
	return new(__space) _RopeConcatenation(__left, __right, __a);
      }

      static _RopeFunction*
      _S_new_RopeFunction(char_producer<_CharT>* __f,
			  size_type __size, bool __d, allocator_type& __a)
      {
	_RopeFunction* __space = typename _Base::_FAlloc(__a).allocate(1);
	return new(__space) _RopeFunction(__f, __size, __d, __a);
      }

      static _RopeSubstring*
      _S_new_RopeSubstring(_Rope_RopeRep<_CharT,_Alloc>* __b, size_type __s,
			   size_type __l, allocator_type& __a)
      {
	_RopeSubstring* __space = typename _Base::_SAlloc(__a).allocate(1);
	return new(__space) _RopeSubstring(__b, __s, __l, __a);
      }
      
      static _RopeLeaf*
      _S_RopeLeaf_from_unowned_char_ptr(const _CharT *__s,
					size_type __size, allocator_type& __a)
#define __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __size, __a) \
                _S_RopeLeaf_from_unowned_char_ptr(__s, __size, __a)
      {
	if (0 == __size)
	  return 0;
	_CharT* __buf = __a.allocate(_S_rounded_up_size(__size));
	
	__uninitialized_copy_n_a(__s, __size, __buf, __a);
	_S_cond_store_eos(__buf[__size]);
	__try
	  { return _S_new_RopeLeaf(__buf, __size, __a); }
	__catch(...)
	  {
	    _RopeRep::__STL_FREE_STRING(__buf, __size, __a);
	    __throw_exception_again;
	  }
      }

      // Concatenation of nonempty strings.
      // Always builds a concatenation node.
      // Rebalances if the result is too deep.
      // Result has refcount 1.
      // Does not increment left and right ref counts even though
      // they are referenced.
      static _RopeRep*
      _S_tree_concat(_RopeRep* __left, _RopeRep* __right);

      // Concatenation helper functions
      static _RopeLeaf*
      _S_leaf_concat_char_iter(_RopeLeaf* __r,
			       const _CharT* __iter, size_type __slen);
      // Concatenate by copying leaf.
      // should take an arbitrary iterator
      // result has refcount 1.
#ifndef __GC
      static _RopeLeaf*
      _S_destr_leaf_concat_char_iter(_RopeLeaf* __r,
				     const _CharT* __iter, size_type __slen);
      // A version that potentially clobbers __r if __r->_M_ref_count == 1.
#endif

    private:
      
      static size_type _S_char_ptr_len(const _CharT* __s);
      // slightly generalized strlen

      rope(_RopeRep* __t, const allocator_type& __a = allocator_type())
      : _Base(__t, __a) { }


      // Copy __r to the _CharT buffer.
      // Returns __buffer + __r->_M_size.
      // Assumes that buffer is uninitialized.
      static _CharT* _S_flatten(_RopeRep* __r, _CharT* __buffer);

      // Again, with explicit starting position and length.
      // Assumes that buffer is uninitialized.
      static _CharT* _S_flatten(_RopeRep* __r,
				size_type __start, size_type __len,
				_CharT* __buffer);

      static const unsigned long
      _S_min_len[__detail::_S_max_rope_depth + 1];
      
      static bool
      _S_is_balanced(_RopeRep* __r)
      { return (__r->_M_size >= _S_min_len[__r->_M_depth]); }

      static bool
      _S_is_almost_balanced(_RopeRep* __r)
      { return (__r->_M_depth == 0
		|| __r->_M_size >= _S_min_len[__r->_M_depth - 1]); }

      static bool
      _S_is_roughly_balanced(_RopeRep* __r)
      { return (__r->_M_depth <= 1
		|| __r->_M_size >= _S_min_len[__r->_M_depth - 2]); }

      // Assumes the result is not empty.
      static _RopeRep*
      _S_concat_and_set_balanced(_RopeRep* __left, _RopeRep* __right)
      {
	_RopeRep* __result = _S_concat(__left, __right);
	if (_S_is_balanced(__result))
	  __result->_M_is_balanced = true;
	return __result;
      }

      // The basic rebalancing operation.  Logically copies the
      // rope.  The result has refcount of 1.  The client will
      // usually decrement the reference count of __r.
      // The result is within height 2 of balanced by the above
      // definition.
      static _RopeRep* _S_balance(_RopeRep* __r);

      // Add all unbalanced subtrees to the forest of balanced trees.
      // Used only by balance.
      static void _S_add_to_forest(_RopeRep*__r, _RopeRep** __forest);

      // Add __r to forest, assuming __r is already balanced.
      static void _S_add_leaf_to_forest(_RopeRep* __r, _RopeRep** __forest);
      
      // Print to stdout, exposing structure
      static void _S_dump(_RopeRep* __r, int __indent = 0);
      
      // Return -1, 0, or 1 if __x < __y, __x == __y, or __x > __y resp.
      static int _S_compare(const _RopeRep* __x, const _RopeRep* __y);
      
    public:
      _GLIBCXX_NODISCARD bool
      empty() const
      { return 0 == this->_M_tree_ptr; }
      
      // Comparison member function.  This is public only for those
      // clients that need a ternary comparison.  Others
      // should use the comparison operators below.
      int
      compare(const rope& __y) const
      { return _S_compare(this->_M_tree_ptr, __y._M_tree_ptr); }

      rope(const _CharT* __s, const allocator_type& __a = allocator_type())
      : _Base(__a)
      {
	this->_M_tree_ptr =
	  __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, _S_char_ptr_len(__s),
					   _M_get_allocator());
      }

      rope(const _CharT* __s, size_type __len,
	   const allocator_type& __a = allocator_type())
      : _Base(__a)
      {
	this->_M_tree_ptr =
	  __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __len, _M_get_allocator());
      }

      // Should perhaps be templatized with respect to the iterator type
      // and use Sequence_buffer.  (It should perhaps use sequence_buffer
      // even now.)
      rope(const _CharT* __s, const _CharT* __e,
	   const allocator_type& __a = allocator_type())
      : _Base(__a)
      {
	this->_M_tree_ptr =
	  __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __e - __s, _M_get_allocator());
      }

      rope(const const_iterator& __s, const const_iterator& __e,
	   const allocator_type& __a = allocator_type())
      : _Base(_S_substring(__s._M_root, __s._M_current_pos,
			   __e._M_current_pos), __a)
      { }

      rope(const iterator& __s, const iterator& __e,
	   const allocator_type& __a = allocator_type())
      : _Base(_S_substring(__s._M_root, __s._M_current_pos,
			   __e._M_current_pos), __a)
      { }

      rope(_CharT __c, const allocator_type& __a = allocator_type())
      : _Base(__a)
      {
	_CharT* __buf = this->_Data_allocate(_S_rounded_up_size(1));
	
	__alloc_traits<allocator_type>::construct(_M_get_allocator(),
						  __buf, __c);
	__try
	  {
	    this->_M_tree_ptr = _S_new_RopeLeaf(__buf, 1,
						_M_get_allocator());
	  }
	__catch(...)
	  {
	    _RopeRep::__STL_FREE_STRING(__buf, 1, _M_get_allocator());
	    __throw_exception_again;
	  }
      }

      rope(size_type __n, _CharT __c,
	   const allocator_type& __a = allocator_type());

      rope(const allocator_type& __a = allocator_type())
      : _Base(0, __a) { }

      // Construct a rope from a function that can compute its members
      rope(char_producer<_CharT> *__fn, size_type __len, bool __delete_fn,
	   const allocator_type& __a = allocator_type())
      : _Base(__a)
      {
	this->_M_tree_ptr = (0 == __len)
	  ? 0
	  : _S_new_RopeFunction(__fn, __len, __delete_fn, _M_get_allocator());
      }

      rope(const rope& __x, const allocator_type& __a = allocator_type())
      : _Base(__x._M_tree_ptr, __a)
      { _S_ref(this->_M_tree_ptr); }

      ~rope() throw()
      { _S_unref(this->_M_tree_ptr); }

      rope&
      operator=(const rope& __x)
      {
	_RopeRep* __old = this->_M_tree_ptr;
	this->_M_tree_ptr = __x._M_tree_ptr;
	_S_ref(this->_M_tree_ptr);
	_S_unref(__old);
	return *this;
      }

      void
      clear()
      {
	_S_unref(this->_M_tree_ptr);
	this->_M_tree_ptr = 0;
      }
      
      void
      push_back(_CharT __x)
      {
	allocator_type __a = _M_get_allocator();
	_RopeRep* __old = this->_M_tree_ptr;
	this->_M_tree_ptr
	  = _S_destr_concat_char_iter(this->_M_tree_ptr, &__x, 1, __a);
	_S_unref(__old);
      }

      void
      pop_back()
      {
	_RopeRep* __old = this->_M_tree_ptr;
	this->_M_tree_ptr = _S_substring(this->_M_tree_ptr,
					 0, this->_M_tree_ptr->_M_size - 1);
	_S_unref(__old);
      }

      _CharT
      back() const
      { return _S_fetch(this->_M_tree_ptr, this->_M_tree_ptr->_M_size - 1); }

      void
      push_front(_CharT __x)
      {
	_RopeRep* __old = this->_M_tree_ptr;
	_RopeRep* __left =
	  __STL_ROPE_FROM_UNOWNED_CHAR_PTR(&__x, 1, _M_get_allocator());
	__try
	  {
	    this->_M_tree_ptr = _S_concat(__left, this->_M_tree_ptr);
	    _S_unref(__old);
	    _S_unref(__left);
	  }
	__catch(...)
	  {
	    _S_unref(__left);
	    __throw_exception_again;
	  }
      }

      void
      pop_front()
      {
	_RopeRep* __old = this->_M_tree_ptr;
	this->_M_tree_ptr
	  = _S_substring(this->_M_tree_ptr, 1, this->_M_tree_ptr->_M_size);
	_S_unref(__old);
      }

      _CharT
      front() const
      { return _S_fetch(this->_M_tree_ptr, 0); }

      void
      balance()
      {
	_RopeRep* __old = this->_M_tree_ptr;
	this->_M_tree_ptr = _S_balance(this->_M_tree_ptr);
	_S_unref(__old);
      }

      void
      copy(_CharT* __buffer) const
      {
	_Destroy_const(__buffer, __buffer + size(), _M_get_allocator());
	_S_flatten(this->_M_tree_ptr, __buffer);
      }

      // This is the copy function from the standard, but
      // with the arguments reordered to make it consistent with the
      // rest of the interface.
      // Note that this guaranteed not to compile if the draft standard
      // order is assumed.
      size_type
      copy(size_type __pos, size_type __n, _CharT* __buffer) const
      {
	size_type __size = size();
	size_type __len = (__pos + __n > __size? __size - __pos : __n);

	_Destroy_const(__buffer, __buffer + __len, _M_get_allocator());
	_S_flatten(this->_M_tree_ptr, __pos, __len, __buffer);
	return __len;
      }

      // Print to stdout, exposing structure.  May be useful for
      // performance debugging.
      void
      dump()
      { _S_dump(this->_M_tree_ptr); }
      
      // Convert to 0 terminated string in new allocated memory.
      // Embedded 0s in the input do not terminate the copy.
      const _CharT* c_str() const;

      // As above, but also use the flattened representation as
      // the new rope representation.
      const _CharT* replace_with_c_str();
      
      // Reclaim memory for the c_str generated flattened string.
      // Intentionally undocumented, since it's hard to say when this
      // is safe for multiple threads.
      void
      delete_c_str ()
      {
	if (0 == this->_M_tree_ptr)
	  return;
	if (__detail::_S_leaf == this->_M_tree_ptr->_M_tag &&
	    ((_RopeLeaf*)this->_M_tree_ptr)->_M_data ==
	    this->_M_tree_ptr->_M_c_string)
	  {
	    // Representation shared
	    return;
	  }
#ifndef __GC
	this->_M_tree_ptr->_M_free_c_string();
#endif
	this->_M_tree_ptr->_M_c_string = 0;
      }

      _CharT
      operator[] (size_type __pos) const
      { return _S_fetch(this->_M_tree_ptr, __pos); }

      _CharT
      at(size_type __pos) const
      {
	// if (__pos >= size()) throw out_of_range;  // XXX
	return (*this)[__pos];
      }

      const_iterator
      begin() const
      { return(const_iterator(this->_M_tree_ptr, 0)); }

      // An easy way to get a const iterator from a non-const container.
      const_iterator
      const_begin() const
      { return(const_iterator(this->_M_tree_ptr, 0)); }

      const_iterator
      end() const
      { return(const_iterator(this->_M_tree_ptr, size())); }

      const_iterator
      const_end() const
      { return(const_iterator(this->_M_tree_ptr, size())); }

      size_type
      size() const
      {	return(0 == this->_M_tree_ptr? 0 : this->_M_tree_ptr->_M_size); }
      
      size_type
      length() const
      {	return size(); }

      size_type
      max_size() const
      {
	return _S_min_len[int(__detail::_S_max_rope_depth) - 1] - 1;
	//  Guarantees that the result can be sufficiently
	//  balanced.  Longer ropes will probably still work,
	//  but it's harder to make guarantees.
      }

      typedef std::reverse_iterator<const_iterator> const_reverse_iterator;

      const_reverse_iterator
      rbegin() const
      { return const_reverse_iterator(end()); }

      const_reverse_iterator
      const_rbegin() const
      {	return const_reverse_iterator(end()); }

      const_reverse_iterator
      rend() const
      { return const_reverse_iterator(begin()); }
      
      const_reverse_iterator
      const_rend() const
      {	return const_reverse_iterator(begin()); }

      template<class _CharT2, class _Alloc2>
        friend rope<_CharT2, _Alloc2>
        operator+(const rope<_CharT2, _Alloc2>& __left,
		  const rope<_CharT2, _Alloc2>& __right);

      template<class _CharT2, class _Alloc2>
        friend rope<_CharT2, _Alloc2>
        operator+(const rope<_CharT2, _Alloc2>& __left, const _CharT2* __right);

      template<class _CharT2, class _Alloc2>
        friend rope<_CharT2, _Alloc2>
        operator+(const rope<_CharT2, _Alloc2>& __left, _CharT2 __right);

      // The symmetric cases are intentionally omitted, since they're
      // presumed to be less common, and we don't handle them as well.

      // The following should really be templatized.  The first
      // argument should be an input iterator or forward iterator with
      // value_type _CharT.
      rope&
      append(const _CharT* __iter, size_type __n)
      {
	allocator_type __a = _M_get_allocator();
	_RopeRep* __result =
	  _S_destr_concat_char_iter(this->_M_tree_ptr, __iter, __n, __a);
	_S_unref(this->_M_tree_ptr);
	this->_M_tree_ptr = __result;
	return *this;
      }

      rope&
      append(const _CharT* __c_string)
      {
	size_type __len = _S_char_ptr_len(__c_string);
	append(__c_string, __len);
	return(*this);
      }

      rope&
      append(const _CharT* __s, const _CharT* __e)
      {
	allocator_type __a = _M_get_allocator();
	_RopeRep* __result =
	  _S_destr_concat_char_iter(this->_M_tree_ptr, __s, __e - __s, __a);
	_S_unref(this->_M_tree_ptr);
	this->_M_tree_ptr = __result;
	return *this;
      }

      rope&
      append(const_iterator __s, const_iterator __e)
      {
	_Self_destruct_ptr __appendee(_S_substring(__s._M_root,
						   __s._M_current_pos,
						   __e._M_current_pos));
	_RopeRep* __result = _S_concat(this->_M_tree_ptr, 
				       (_RopeRep*)__appendee);
	_S_unref(this->_M_tree_ptr);
	this->_M_tree_ptr = __result;
	return *this;
      }

      rope&
      append(_CharT __c)
      {
	allocator_type __a = _M_get_allocator();
	_RopeRep* __result =
	  _S_destr_concat_char_iter(this->_M_tree_ptr, &__c, 1, __a);
	_S_unref(this->_M_tree_ptr);
	this->_M_tree_ptr = __result;
	return *this;
      }

      rope&
      append()
      { return append(_CharT()); }  // XXX why?

      rope&
      append(const rope& __y)
      {
	_RopeRep* __result = _S_concat(this->_M_tree_ptr, __y._M_tree_ptr);
	_S_unref(this->_M_tree_ptr);
	this->_M_tree_ptr = __result;
	return *this;
      }

      rope&
      append(size_type __n, _CharT __c)
      {
	rope<_CharT,_Alloc> __last(__n, __c);
	return append(__last);
      }

      void
      swap(rope& __b)
      {
	_RopeRep* __tmp = this->_M_tree_ptr;
	this->_M_tree_ptr = __b._M_tree_ptr;
	__b._M_tree_ptr = __tmp;
      }

    protected:
      // Result is included in refcount.
      static _RopeRep*
      replace(_RopeRep* __old, size_type __pos1,
	      size_type __pos2, _RopeRep* __r)
      {
	if (0 == __old)
	  {
	    _S_ref(__r);
	    return __r;
	  }
	_Self_destruct_ptr __left(_S_substring(__old, 0, __pos1));
	_Self_destruct_ptr __right(_S_substring(__old, __pos2, __old->_M_size));
	_RopeRep* __result;

	if (0 == __r)
	  __result = _S_concat(__left, __right);
	else
	  {
	    _Self_destruct_ptr __left_result(_S_concat(__left, __r));
	    __result = _S_concat(__left_result, __right);
	  }
	return __result;
      }

    public:
      void
      insert(size_type __p, const rope& __r)
      {
	_RopeRep* __result =
	  replace(this->_M_tree_ptr, __p, __p, __r._M_tree_ptr);
	_S_unref(this->_M_tree_ptr);
	this->_M_tree_ptr = __result;
      }

      void
      insert(size_type __p, size_type __n, _CharT __c)
      {
	rope<_CharT,_Alloc> __r(__n,__c);
	insert(__p, __r);
      }
      
      void
      insert(size_type __p, const _CharT* __i, size_type __n)
      {
	_Self_destruct_ptr __left(_S_substring(this->_M_tree_ptr, 0, __p));
	_Self_destruct_ptr __right(_S_substring(this->_M_tree_ptr,
						__p, size()));
	_Self_destruct_ptr __left_result(_S_concat_char_iter(__left, __i, __n,
							     _M_get_allocator()));
	// _S_ destr_concat_char_iter should be safe here.
	// But as it stands it's probably not a win, since __left
	// is likely to have additional references.
	_RopeRep* __result = _S_concat(__left_result, __right);
	_S_unref(this->_M_tree_ptr);
	this->_M_tree_ptr = __result;
      }

      void
      insert(size_type __p, const _CharT* __c_string)
      {	insert(__p, __c_string, _S_char_ptr_len(__c_string)); }

      void
      insert(size_type __p, _CharT __c)
      { insert(__p, &__c, 1); }

      void
      insert(size_type __p)
      {
	_CharT __c = _CharT();
	insert(__p, &__c, 1);
      }

      void
      insert(size_type __p, const _CharT* __i, const _CharT* __j)
      {
	rope __r(__i, __j);
	insert(__p, __r);
      }

      void
      insert(size_type __p, const const_iterator& __i,
	     const const_iterator& __j)
      {
	rope __r(__i, __j);
	insert(__p, __r);
      }

      void
      insert(size_type __p, const iterator& __i,
	     const iterator& __j)
      {
	rope __r(__i, __j);
	insert(__p, __r);
      }

      // (position, length) versions of replace operations:
      
      void
      replace(size_type __p, size_type __n, const rope& __r)
      {
	_RopeRep* __result =
	  replace(this->_M_tree_ptr, __p, __p + __n, __r._M_tree_ptr);
	_S_unref(this->_M_tree_ptr);
	this->_M_tree_ptr = __result;
      }

      void
      replace(size_type __p, size_type __n,
	      const _CharT* __i, size_type __i_len)
      {
	rope __r(__i, __i_len);
	replace(__p, __n, __r);
      }

      void
      replace(size_type __p, size_type __n, _CharT __c)
      {
	rope __r(__c);
	replace(__p, __n, __r);
      }

      void
      replace(size_type __p, size_type __n, const _CharT* __c_string)
      {
	rope __r(__c_string);
	replace(__p, __n, __r);
      }
      
      void
      replace(size_type __p, size_type __n,
	      const _CharT* __i, const _CharT* __j)
      {
	rope __r(__i, __j);
	replace(__p, __n, __r);
      }
      
      void
      replace(size_type __p, size_type __n,
	      const const_iterator& __i, const const_iterator& __j)
      {
	rope __r(__i, __j);
	replace(__p, __n, __r);
      }

      void
      replace(size_type __p, size_type __n,
	      const iterator& __i, const iterator& __j)
      {
	rope __r(__i, __j);
	replace(__p, __n, __r);
      }

      // Single character variants:
      void
      replace(size_type __p, _CharT __c)
      {
	iterator __i(this, __p);
	*__i = __c;
      }

      void
      replace(size_type __p, const rope& __r)
      { replace(__p, 1, __r); }

      void
      replace(size_type __p, const _CharT* __i, size_type __i_len)
      { replace(__p, 1, __i, __i_len); }

      void
      replace(size_type __p, const _CharT* __c_string)
      {	replace(__p, 1, __c_string); }

      void
      replace(size_type __p, const _CharT* __i, const _CharT* __j)
      {	replace(__p, 1, __i, __j); }

      void
      replace(size_type __p, const const_iterator& __i,
	      const const_iterator& __j)
      { replace(__p, 1, __i, __j); }

      void
      replace(size_type __p, const iterator& __i,
	      const iterator& __j)
      { replace(__p, 1, __i, __j); }

      // Erase, (position, size) variant.
      void
      erase(size_type __p, size_type __n)
      {
	_RopeRep* __result = replace(this->_M_tree_ptr, __p,
				     __p + __n, 0);
	_S_unref(this->_M_tree_ptr);
	this->_M_tree_ptr = __result;
      }

      // Insert, iterator variants.
      iterator
      insert(const iterator& __p, const rope& __r)
      {
	insert(__p.index(), __r);
	return __p;
      }

      iterator
      insert(const iterator& __p, size_type __n, _CharT __c)
      {
	insert(__p.index(), __n, __c);
	return __p;
      }

      iterator insert(const iterator& __p, _CharT __c)
      {
	insert(__p.index(), __c);
	return __p;
      }
      
      iterator
      insert(const iterator& __p )
      {
	insert(__p.index());
	return __p;
      }
      
      iterator
      insert(const iterator& __p, const _CharT* c_string)
      {
	insert(__p.index(), c_string);
	return __p;
      }
      
      iterator
      insert(const iterator& __p, const _CharT* __i, size_type __n)
      {
	insert(__p.index(), __i, __n);
	return __p;
      }
      
      iterator
      insert(const iterator& __p, const _CharT* __i,
	     const _CharT* __j)
      {
	insert(__p.index(), __i, __j); 
	return __p;
      }
      
      iterator
      insert(const iterator& __p,
	     const const_iterator& __i, const const_iterator& __j)
      {
	insert(__p.index(), __i, __j);
	return __p;
      }
      
      iterator
      insert(const iterator& __p,
	     const iterator& __i, const iterator& __j)
      {
	insert(__p.index(), __i, __j);
	return __p;
      }

      // Replace, range variants.
      void
      replace(const iterator& __p, const iterator& __q, const rope& __r)
      {	replace(__p.index(), __q.index() - __p.index(), __r); }

      void
      replace(const iterator& __p, const iterator& __q, _CharT __c)
      { replace(__p.index(), __q.index() - __p.index(), __c); }
      
      void
      replace(const iterator& __p, const iterator& __q,
	      const _CharT* __c_string)
      { replace(__p.index(), __q.index() - __p.index(), __c_string); }
      
      void
      replace(const iterator& __p, const iterator& __q,
	      const _CharT* __i, size_type __n)
      { replace(__p.index(), __q.index() - __p.index(), __i, __n); }
      
      void
      replace(const iterator& __p, const iterator& __q,
	      const _CharT* __i, const _CharT* __j)
      { replace(__p.index(), __q.index() - __p.index(), __i, __j); }
      
      void
      replace(const iterator& __p, const iterator& __q,
	      const const_iterator& __i, const const_iterator& __j)
      { replace(__p.index(), __q.index() - __p.index(), __i, __j); }
      
      void
      replace(const iterator& __p, const iterator& __q,
	      const iterator& __i, const iterator& __j)
      { replace(__p.index(), __q.index() - __p.index(), __i, __j); }

      // Replace, iterator variants.
      void
      replace(const iterator& __p, const rope& __r)
      { replace(__p.index(), __r); }
      
      void
      replace(const iterator& __p, _CharT __c)
      { replace(__p.index(), __c); }
      
      void
      replace(const iterator& __p, const _CharT* __c_string)
      { replace(__p.index(), __c_string); }
      
      void
      replace(const iterator& __p, const _CharT* __i, size_type __n)
      { replace(__p.index(), __i, __n); }
      
      void
      replace(const iterator& __p, const _CharT* __i, const _CharT* __j)
      { replace(__p.index(), __i, __j); }
      
      void
      replace(const iterator& __p, const_iterator __i, const_iterator __j)
      { replace(__p.index(), __i, __j); }
      
      void
      replace(const iterator& __p, iterator __i, iterator __j)
      { replace(__p.index(), __i, __j); }

      // Iterator and range variants of erase
      iterator
      erase(const iterator& __p, const iterator& __q)
      {
	size_type __p_index = __p.index();
	erase(__p_index, __q.index() - __p_index);
	return iterator(this, __p_index);
      }

      iterator
      erase(const iterator& __p)
      {
	size_type __p_index = __p.index();
	erase(__p_index, 1);
	return iterator(this, __p_index);
      }

      rope
      substr(size_type __start, size_type __len = 1) const
      {
	return rope<_CharT, _Alloc>(_S_substring(this->_M_tree_ptr,
						 __start,
						 __start + __len));
      }

      rope
      substr(iterator __start, iterator __end) const
      {
	return rope<_CharT, _Alloc>(_S_substring(this->_M_tree_ptr,
						 __start.index(),
						 __end.index()));
      }

      rope
      substr(iterator __start) const
      {
	size_type __pos = __start.index();
	return rope<_CharT, _Alloc>(_S_substring(this->_M_tree_ptr,
						 __pos, __pos + 1));
      }

      rope
      substr(const_iterator __start, const_iterator __end) const
      {
	// This might eventually take advantage of the cache in the
	// iterator.
	return rope<_CharT, _Alloc>(_S_substring(this->_M_tree_ptr,
						 __start.index(),
						 __end.index()));
      }

      rope<_CharT, _Alloc>
      substr(const_iterator __start)
      {
	size_type __pos = __start.index();
	return rope<_CharT, _Alloc>(_S_substring(this->_M_tree_ptr,
						 __pos, __pos + 1));
      }

      static const size_type npos;

      size_type find(_CharT __c, size_type __pos = 0) const;

      size_type
      find(const _CharT* __s, size_type __pos = 0) const
      {
	size_type __result_pos;
	const_iterator __result =
	  std::search(const_begin() + __pos, const_end(),
		      __s, __s + _S_char_ptr_len(__s));
	__result_pos = __result.index();
#ifndef __STL_OLD_ROPE_SEMANTICS
	if (__result_pos == size())
	  __result_pos = npos;
#endif
	return __result_pos;
      }

      iterator
      mutable_begin()
      { return(iterator(this, 0)); }
      
      iterator
      mutable_end()
      { return(iterator(this, size())); }

      typedef std::reverse_iterator<iterator> reverse_iterator;
      
      reverse_iterator
      mutable_rbegin()
      { return reverse_iterator(mutable_end()); }

      reverse_iterator
      mutable_rend()
      { return reverse_iterator(mutable_begin()); }

      reference
      mutable_reference_at(size_type __pos)
      { return reference(this, __pos); }

#ifdef __STD_STUFF
      reference
      operator[] (size_type __pos)
      { return _char_ref_proxy(this, __pos); }

      reference
      at(size_type __pos)
      {
	// if (__pos >= size()) throw out_of_range;  // XXX
	return (*this)[__pos];
      }
      
      void resize(size_type __n, _CharT __c) { }
      void resize(size_type __n) { }
      void reserve(size_type __res_arg = 0) { }
      
      size_type
      capacity() const
      { return max_size(); }

      // Stuff below this line is dangerous because it's error prone.
      // I would really like to get rid of it.
      // copy function with funny arg ordering.
      size_type
      copy(_CharT* __buffer, size_type __n,
	   size_type __pos = 0) const
      { return copy(__pos, __n, __buffer); }

      iterator
      end()
      { return mutable_end(); }

      iterator
      begin()
      { return mutable_begin(); }

      reverse_iterator
      rend()
      { return mutable_rend(); }
      
      reverse_iterator
      rbegin()
      { return mutable_rbegin(); }

#else
      const_iterator
      end()
      { return const_end(); }

      const_iterator
      begin()
      { return const_begin(); }

      const_reverse_iterator
      rend()
      { return const_rend(); }

      const_reverse_iterator
      rbegin()
      { return const_rbegin(); }

#endif
    };

  template <class _CharT, class _Alloc>
    const typename rope<_CharT, _Alloc>::size_type
    rope<_CharT, _Alloc>::npos = (size_type)(-1);
  
  template <class _CharT, class _Alloc>
    inline bool operator==(const _Rope_const_iterator<_CharT, _Alloc>& __x,
			   const _Rope_const_iterator<_CharT, _Alloc>& __y)
    { return (__x._M_current_pos == __y._M_current_pos
	      && __x._M_root == __y._M_root); }

  template <class _CharT, class _Alloc>
    inline bool operator<(const _Rope_const_iterator<_CharT, _Alloc>& __x,
			  const _Rope_const_iterator<_CharT, _Alloc>& __y)
    { return (__x._M_current_pos < __y._M_current_pos); }

  template <class _CharT, class _Alloc>
    inline bool operator!=(const _Rope_const_iterator<_CharT, _Alloc>& __x,
			   const _Rope_const_iterator<_CharT, _Alloc>& __y)
    { return !(__x == __y); }

  template <class _CharT, class _Alloc>
    inline bool operator>(const _Rope_const_iterator<_CharT, _Alloc>& __x,
			  const _Rope_const_iterator<_CharT, _Alloc>& __y)
    { return __y < __x; }

  template <class _CharT, class _Alloc>
    inline bool
    operator<=(const _Rope_const_iterator<_CharT, _Alloc>& __x,
	       const _Rope_const_iterator<_CharT, _Alloc>& __y)
    { return !(__y < __x); }

  template <class _CharT, class _Alloc>
    inline bool
    operator>=(const _Rope_const_iterator<_CharT, _Alloc>& __x,
	       const _Rope_const_iterator<_CharT, _Alloc>& __y)
    { return !(__x < __y); }

  template <class _CharT, class _Alloc>
    inline std::ptrdiff_t
    operator-(const _Rope_const_iterator<_CharT, _Alloc>& __x,
	      const _Rope_const_iterator<_CharT, _Alloc>& __y)
    {
      return (std::ptrdiff_t)__x._M_current_pos
	- (std::ptrdiff_t)__y._M_current_pos;
    }

  template <class _CharT, class _Alloc>
    inline _Rope_const_iterator<_CharT, _Alloc>
    operator-(const _Rope_const_iterator<_CharT, _Alloc>& __x,
	      std::ptrdiff_t __n)
    { return _Rope_const_iterator<_CharT, _Alloc>(__x._M_root,
						  __x._M_current_pos - __n); }

  template <class _CharT, class _Alloc>
    inline _Rope_const_iterator<_CharT, _Alloc>
    operator+(const _Rope_const_iterator<_CharT, _Alloc>& __x,
	      std::ptrdiff_t __n)
    { return _Rope_const_iterator<_CharT, _Alloc>(__x._M_root,
						  __x._M_current_pos + __n); }

  template <class _CharT, class _Alloc>
    inline _Rope_const_iterator<_CharT, _Alloc>
    operator+(std::ptrdiff_t __n,
	      const _Rope_const_iterator<_CharT, _Alloc>& __x)
  { return _Rope_const_iterator<_CharT, _Alloc>(__x._M_root,
						__x._M_current_pos + __n); }

  template <class _CharT, class _Alloc>
    inline bool
    operator==(const _Rope_iterator<_CharT, _Alloc>& __x,
	       const _Rope_iterator<_CharT, _Alloc>& __y)
    {return (__x._M_current_pos == __y._M_current_pos
	     && __x._M_root_rope == __y._M_root_rope); }
  
  template <class _CharT, class _Alloc>
    inline bool
    operator<(const _Rope_iterator<_CharT, _Alloc>& __x,
	      const _Rope_iterator<_CharT, _Alloc>& __y)
    { return (__x._M_current_pos < __y._M_current_pos); }

  template <class _CharT, class _Alloc>
    inline bool
    operator!=(const _Rope_iterator<_CharT, _Alloc>& __x,
	       const _Rope_iterator<_CharT, _Alloc>& __y)
    { return !(__x == __y); }

  template <class _CharT, class _Alloc>
    inline bool
    operator>(const _Rope_iterator<_CharT, _Alloc>& __x,
	      const _Rope_iterator<_CharT, _Alloc>& __y)
    { return __y < __x; }

  template <class _CharT, class _Alloc>
    inline bool
    operator<=(const _Rope_iterator<_CharT, _Alloc>& __x,
	       const _Rope_iterator<_CharT, _Alloc>& __y)
    { return !(__y < __x); }

  template <class _CharT, class _Alloc>
    inline bool
    operator>=(const _Rope_iterator<_CharT, _Alloc>& __x,
	       const _Rope_iterator<_CharT, _Alloc>& __y)
    { return !(__x < __y); }

  template <class _CharT, class _Alloc>
    inline std::ptrdiff_t
    operator-(const _Rope_iterator<_CharT, _Alloc>& __x,
	      const _Rope_iterator<_CharT, _Alloc>& __y)
    { return ((std::ptrdiff_t)__x._M_current_pos
	      - (std::ptrdiff_t)__y._M_current_pos); }

  template <class _CharT, class _Alloc>
    inline _Rope_iterator<_CharT, _Alloc>
    operator-(const _Rope_iterator<_CharT, _Alloc>& __x,
	      std::ptrdiff_t __n)
    { return _Rope_iterator<_CharT, _Alloc>(__x._M_root_rope,
					    __x._M_current_pos - __n); }

  template <class _CharT, class _Alloc>
    inline _Rope_iterator<_CharT, _Alloc>
    operator+(const _Rope_iterator<_CharT, _Alloc>& __x, std::ptrdiff_t __n)
    { return _Rope_iterator<_CharT, _Alloc>(__x._M_root_rope,
					    __x._M_current_pos + __n); }

  template <class _CharT, class _Alloc>
    inline _Rope_iterator<_CharT, _Alloc>
    operator+(std::ptrdiff_t __n, const _Rope_iterator<_CharT, _Alloc>& __x)
    { return _Rope_iterator<_CharT, _Alloc>(__x._M_root_rope,
					    __x._M_current_pos + __n); }

  template <class _CharT, class _Alloc>
    inline rope<_CharT, _Alloc>
    operator+(const rope<_CharT, _Alloc>& __left,
	      const rope<_CharT, _Alloc>& __right)
    {
      // Inlining this should make it possible to keep __left and
      // __right in registers.
      typedef rope<_CharT, _Alloc> rope_type;
      return rope_type(rope_type::_S_concat(__left._M_tree_ptr, 
					    __right._M_tree_ptr));
    }

  template <class _CharT, class _Alloc>
    inline rope<_CharT, _Alloc>&
    operator+=(rope<_CharT, _Alloc>& __left,
	       const rope<_CharT, _Alloc>& __right)
    {
      __left.append(__right);
      return __left;
    }

  template <class _CharT, class _Alloc>
    inline rope<_CharT, _Alloc>
    operator+(const rope<_CharT, _Alloc>& __left,
	      const _CharT* __right)
    {
      typedef rope<_CharT, _Alloc> rope_type;
      std::size_t __rlen = rope_type::_S_char_ptr_len(__right);
      _Alloc __a = __left.get_allocator();
      return rope_type(rope_type::_S_concat_char_iter(__left._M_tree_ptr,
						      __right, __rlen, __a));
    }

  template <class _CharT, class _Alloc>
    inline rope<_CharT, _Alloc>&
    operator+=(rope<_CharT, _Alloc>& __left,
	       const _CharT* __right)
    {
      __left.append(__right);
      return __left;
    }

  template <class _CharT, class _Alloc>
    inline rope<_CharT, _Alloc>
    operator+(const rope<_CharT, _Alloc>& __left, _CharT __right)
    {
      typedef rope<_CharT, _Alloc> rope_type;
      _Alloc __a = __left.get_allocator();
      return rope_type(rope_type::_S_concat_char_iter(__left._M_tree_ptr,
						      &__right, 1, __a));
    }

  template <class _CharT, class _Alloc>
    inline rope<_CharT, _Alloc>&
    operator+=(rope<_CharT, _Alloc>& __left, _CharT __right)
    {
      __left.append(__right);
      return __left;
    }
  
  template <class _CharT, class _Alloc>
    bool
    operator<(const rope<_CharT, _Alloc>& __left,
	      const rope<_CharT, _Alloc>& __right)
    { return __left.compare(__right) < 0; }

  template <class _CharT, class _Alloc>
    bool
    operator==(const rope<_CharT, _Alloc>& __left,
	       const rope<_CharT, _Alloc>& __right)
    { return __left.compare(__right) == 0; }

  template <class _CharT, class _Alloc>
    inline bool
    operator==(const _Rope_char_ptr_proxy<_CharT, _Alloc>& __x,
	       const _Rope_char_ptr_proxy<_CharT, _Alloc>& __y)
    { return (__x._M_pos == __y._M_pos && __x._M_root == __y._M_root); }

  template <class _CharT, class _Alloc>
    inline bool
    operator!=(const rope<_CharT, _Alloc>& __x,
	       const rope<_CharT, _Alloc>& __y)
    { return !(__x == __y); }

  template <class _CharT, class _Alloc>
    inline bool
    operator>(const rope<_CharT, _Alloc>& __x,
	      const rope<_CharT, _Alloc>& __y)
    { return __y < __x; }

  template <class _CharT, class _Alloc>
    inline bool
    operator<=(const rope<_CharT, _Alloc>& __x,
	       const rope<_CharT, _Alloc>& __y)
    { return !(__y < __x); }

  template <class _CharT, class _Alloc>
    inline bool
    operator>=(const rope<_CharT, _Alloc>& __x,
	       const rope<_CharT, _Alloc>& __y)
    { return !(__x < __y); }

  template <class _CharT, class _Alloc>
    inline bool
    operator!=(const _Rope_char_ptr_proxy<_CharT, _Alloc>& __x,
	       const _Rope_char_ptr_proxy<_CharT, _Alloc>& __y)
    { return !(__x == __y); }

  template<class _CharT, class _Traits, class _Alloc>
    std::basic_ostream<_CharT, _Traits>&
    operator<<(std::basic_ostream<_CharT, _Traits>& __o,
	       const rope<_CharT, _Alloc>& __r);

  typedef rope<char> crope;
  typedef rope<wchar_t> wrope;

  inline crope::reference
  __mutable_reference_at(crope& __c, std::size_t __i)
  { return __c.mutable_reference_at(__i); }

  inline wrope::reference
  __mutable_reference_at(wrope& __c, std::size_t __i)
  { return __c.mutable_reference_at(__i); }

  template <class _CharT, class _Alloc>
    inline void
    swap(rope<_CharT, _Alloc>& __x, rope<_CharT, _Alloc>& __y)
    { __x.swap(__y); }

_GLIBCXX_END_NAMESPACE_VERSION
} // namespace


namespace std _GLIBCXX_VISIBILITY(default)
{ 
_GLIBCXX_BEGIN_NAMESPACE_VERSION

namespace tr1
{
  template<>
    struct hash<__gnu_cxx::crope>
    {
      size_t
      operator()(const __gnu_cxx::crope& __str) const
      {
	size_t __size = __str.size();
	if (0 == __size)
	  return 0;
	return 13 * __str[0] + 5 * __str[__size - 1] + __size;
      }
    };


  template<>
    struct hash<__gnu_cxx::wrope>
    {
      size_t
      operator()(const __gnu_cxx::wrope& __str) const
      {
	size_t __size = __str.size();
	if (0 == __size)
	  return 0;
	return 13 * __str[0] + 5 * __str[__size - 1] + __size;
      }
    };
} // namespace tr1

_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std

# include <ext/ropeimpl.h>

#endif
@


1.12
log
@initial merge of GCC 12.3.0.

this doesn't include any of the changes to the .c -> .cc files renamed,
and reverts our local changes to the vax port and libsanitizer subdir.
vax GCC was rewritten and our local fixes no longer are relevant, and
the new libsanitizer is more updated than our old one, and merging via
gcc10->gcc12 is not really possible.

unfortunately, our local changes to libsanitizer that aren't related
to the general update of those sources (ie, the netbsd code) will need
to be re-checked and perhaps re-ported.
@
text
@d3 1
a3 1
// Copyright (C) 2001-2022 Free Software Foundation, Inc.
d48 2
@


1.11
log
@merge GCC 10.4.0.
@
text
@d3 1
a3 1
// Copyright (C) 2001-2020 Free Software Foundation, Inc.
d174 4
d210 1
d221 1
d239 6
a244 1
      
d313 1
d438 4
a441 1
  
d454 1
d471 1
a471 1
    volatile _RC_t _M_ref_count;
d508 1
a508 1
      volatile _RC_t __tmp = --_M_ref_count;
d694 1
a694 1
protected:
d761 1
a761 1
protected:
d797 1
a797 1
protected:
d1071 3
d1151 1
d1531 1
a1531 1
	protected:
d1635 3
a1637 2
					   size_type __slen);
      // Concatenate rope and char ptr, copying __s.
d1642 2
a1643 1
						 size_type __slen)
d1649 1
a1649 1
      { return _S_concat_char_iter(__r, __iter, __slen); }
d1938 1
d1941 1
a1941 1
	  = _S_destr_concat_char_iter(this->_M_tree_ptr, &__x, 1);
d2141 1
d2143 1
a2143 1
	  _S_destr_concat_char_iter(this->_M_tree_ptr, __iter, __n);
d2160 1
d2162 1
a2162 1
	  _S_destr_concat_char_iter(this->_M_tree_ptr, __s, __e - __s);
d2184 1
d2186 1
a2186 1
	  _S_destr_concat_char_iter(this->_M_tree_ptr, &__c, 1);
d2268 2
a2269 1
	_Self_destruct_ptr __left_result(_S_concat_char_iter(__left, __i, __n));
a2416 5
      // Erase, single character
      _GLIBCXX_DEPRECATED void
      erase(size_type __p)
      { erase(__p, __p + 1); }

d2868 1
d2870 1
a2870 1
						      __right, __rlen));
d2887 1
d2889 1
a2889 1
						      &__right, 1));
@


1.10
log
@initial merge of GCC 10.3.0.

these three files are not yet finished merging:

gcc/config/rs6000/rs6000.c
libsanitizer/lsan/lsan_allocator.h
libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h

our current GCC 9 sanitizers are newer than GCC 10's still, so that
may take a little to untease, so it's probable that more than
these 2 will need more changes.

rs6000.c has some changes related to ABI and supported functionality
that need to be merged forward.
@
text
@d2391 1
a2391 1
      void
@


1.9
log
@merge GCC 9.3.0.
@
text
@d3 1
a3 1
// Copyright (C) 2001-2019 Free Software Foundation, Inc.
d56 1
a76 5
  using std::size_t;
  using std::ptrdiff_t;
  using std::allocator;
  using std::_Destroy;

d90 2
a91 2
		   _ForwardIterator __last, allocator<_Tp>)
    { _Destroy(__first, __last); }
d152 1
a152 1
      operator()(size_t __start_pos, size_t __len,
d174 1
a174 1
  template<class _Sequence, size_t _Buf_sz = 100>
d183 1
a183 1
      size_t     _M_buf_count;
d251 1
a251 1
      append(value_type* __s, size_t __len)
d255 2
a256 2
	    size_t __i = _M_buf_count;
	    for (size_t __j = 0; __j < __len; __i++, __j++)
d270 1
a270 1
      write(value_type* __s, size_t __len)
d316 1
a316 1
      operator()(const _CharT* __buffer, size_t __len) = 0;
d322 1
a322 1
  template<class _CharT, class _Alloc = allocator<_CharT> >
d357 1
a357 1
	      ptrdiff_t __n);
d362 1
a362 1
	      ptrdiff_t __n);
d366 1
a366 1
    operator+(ptrdiff_t __n,
d380 1
a380 1
    ptrdiff_t
d386 1
a386 1
    operator-(const _Rope_iterator<_CharT, _Alloc>& __x, ptrdiff_t __n);
d390 1
a390 1
    operator+(const _Rope_iterator<_CharT, _Alloc>& __x, ptrdiff_t __n);
d394 1
a394 1
    operator+(ptrdiff_t __n, const _Rope_iterator<_CharT, _Alloc>& __x);
d407 1
a407 1
    ptrdiff_t
d452 1
a452 1
    typedef size_t _RC_t;
d547 1
d562 1
a562 1
      _Rope_rep_base(size_t __size, const allocator_type&)
d565 1
a565 1
      size_t _M_size;
d569 2
a570 2
          _Alloc::template rebind<_Tp>::other __name##Alloc; \
        static _Tp* __name##_allocate(size_t __n) \
d572 1
a572 1
        static void __name##_deallocate(_Tp *__p, size_t __n) \
d603 1
d608 1
a608 1
      _Rope_RopeRep(__detail::_Tag __t, int __d, bool __b, size_t __size,
d627 1
a627 1
      _S_free_string(__GC_CONST _CharT*, size_t __len,
d689 1
d697 2
a698 2
      static size_t
      _S_rounded_up_size(size_t __n)
d700 1
a700 1
        size_t __size_with_eos;
d710 2
a711 2
	return ((__size_with_eos + size_t(_S_alloc_granularity) - 1)
		&~ (size_t(_S_alloc_granularity) - 1));
d722 1
a722 1
      _Rope_RopeLeaf(__GC_CONST _CharT* __d, size_t __size,
d812 1
a812 1
      _Rope_RopeFunction(char_producer<_CharT>* __f, size_t __size,
d854 1
d858 1
a858 1
      size_t _M_start;
d861 1
a861 1
      operator()(size_t __start_pos, size_t __req_len,
d890 2
a891 2
      _Rope_RopeSubstring(_Rope_RopeRep<_CharT, _Alloc>* __b, size_t __s,
                          size_t __l, const allocator_type& __a)
d969 1
a969 1
      size_t _M_pos;
d974 1
a974 1
      _Rope_char_ref_proxy(_My_rope* __r, size_t __p)
d985 1
a985 1
      _Rope_char_ref_proxy(_My_rope* __r, size_t __p, _CharT __c)
d1015 1
a1015 1
      size_t _M_pos;
d1067 1
a1067 1
      size_t _M_current_pos;
d1069 1
a1069 1
      size_t _M_leaf_pos;    // Starting position for current leaf
d1110 1
a1110 1
      _Rope_iterator_base(_RopeRep* __root, size_t __pos)
d1113 2
a1114 2
      void _M_incr(size_t __n);
      void _M_decr(size_t __n);
d1116 1
a1116 1
      size_t
d1144 1
a1144 1
      _Rope_const_iterator(const _RopeRep* __root, size_t __pos)
d1163 1
a1163 1
      _Rope_const_iterator(const rope<_CharT, _Alloc>& __r, size_t __pos)
d1212 1
a1212 1
      operator+=(ptrdiff_t __n)
d1229 1
a1229 1
      operator-=(ptrdiff_t __n)
d1241 1
a1241 1
        size_t __old_pos = this->_M_current_pos;
d1252 1
a1252 1
        size_t __old_pos = this->_M_current_pos;
d1260 1
a1260 1
		  ptrdiff_t __n);
d1265 1
a1265 1
		  ptrdiff_t __n);
d1269 1
a1269 1
        operator+(ptrdiff_t __n,
d1273 1
a1273 1
      operator[](size_t __n)
d1288 1
a1288 1
        friend ptrdiff_t
d1308 1
a1308 1
      _Rope_iterator(rope<_CharT, _Alloc>* __r, size_t __pos)
d1337 1
a1337 1
      _Rope_iterator(rope<_CharT, _Alloc>& __r, size_t __pos);
d1392 1
a1392 1
      operator+=(ptrdiff_t __n)
d1409 1
a1409 1
      operator-=(ptrdiff_t __n)
d1421 1
a1421 1
        size_t __old_pos = this->_M_current_pos;
d1429 1
a1429 1
        size_t __old_pos = this->_M_current_pos;
d1435 1
a1435 1
      operator[](ptrdiff_t __n)
d1451 1
a1451 1
        friend ptrdiff_t
d1457 2
a1458 1
        operator-(const _Rope_iterator<_CharT2, _Alloc2>& __x, ptrdiff_t __n);
d1462 2
a1463 1
        operator+(const _Rope_iterator<_CharT2, _Alloc2>& __x, ptrdiff_t __n);
d1467 2
a1468 1
        operator+(ptrdiff_t __n, const _Rope_iterator<_CharT2, _Alloc2>& __x);
d1503 2
a1504 2
          _Alloc::template rebind<_Tp>::other __name##Alloc; \
        static _Tp* __name##_allocate(size_t __n) \
d1506 1
a1506 1
        static void __name##_deallocate(_Tp *__p, size_t __n) \
d1528 2
a1529 2
      typedef ptrdiff_t difference_type;
      typedef size_t size_type;
d1586 1
a1586 1
			 size_t __begin, size_t __end);
d1611 1
a1611 1
                                    size_t __start, size_t __endp1);
d1614 2
a1615 1
					   const _CharT* __iter, size_t __slen);
d1621 1
a1621 1
						 size_t __slen)
d1638 1
a1638 1
      apply_to_pieces(size_t __begin, size_t __end,
d1644 2
a1645 2
      static size_t
      _S_rounded_up_size(size_t __n)
d1648 2
a1649 2
      static size_t
      _S_allocated_capacity(size_t __n)
d1662 1
a1662 1
		      size_t __size, allocator_type& __a)
d1678 1
a1678 1
			  size_t __size, bool __d, allocator_type& __a)
d1685 2
a1686 2
      _S_new_RopeSubstring(_Rope_RopeRep<_CharT,_Alloc>* __b, size_t __s,
			   size_t __l, allocator_type& __a)
d1694 1
a1694 1
					size_t __size, allocator_type& __a)
d1725 1
a1725 1
			       const _CharT* __iter, size_t __slen);
d1732 1
a1732 1
				     const _CharT* __iter, size_t __slen);
d1738 1
a1738 1
      static size_t _S_char_ptr_len(const _CharT* __s);
d1753 1
a1753 1
				size_t __start, size_t __len,
d1823 1
a1823 1
      rope(const _CharT* __s, size_t __len,
d1859 2
a1860 1
	_M_get_allocator().construct(__buf, __c);
d1873 1
a1873 1
      rope(size_t __n, _CharT __c,
d1880 1
a1880 1
      rope(char_producer<_CharT> *__fn, size_t __len, bool __delete_fn,
d1990 2
a1991 2
	size_t __size = size();
	size_t __len = (__pos + __n > __size? __size - __pos : __n);
d2116 1
a2116 1
      append(const _CharT* __iter, size_t __n)
d2128 1
a2128 1
	size_t __len = _S_char_ptr_len(__c_string);
d2180 1
a2180 1
      append(size_t __n, _CharT __c)
d2197 2
a2198 2
      replace(_RopeRep* __old, size_t __pos1,
	      size_t __pos2, _RopeRep* __r)
d2221 1
a2221 1
      insert(size_t __p, const rope& __r)
d2230 1
a2230 1
      insert(size_t __p, size_t __n, _CharT __c)
d2237 1
a2237 1
      insert(size_t __p, const _CharT* __i, size_t __n)
d2252 1
a2252 1
      insert(size_t __p, const _CharT* __c_string)
d2256 1
a2256 1
      insert(size_t __p, _CharT __c)
d2260 1
a2260 1
      insert(size_t __p)
d2267 1
a2267 1
      insert(size_t __p, const _CharT* __i, const _CharT* __j)
d2274 1
a2274 1
      insert(size_t __p, const const_iterator& __i,
d2282 1
a2282 1
      insert(size_t __p, const iterator& __i,
d2292 1
a2292 1
      replace(size_t __p, size_t __n, const rope& __r)
d2301 2
a2302 2
      replace(size_t __p, size_t __n,
	      const _CharT* __i, size_t __i_len)
d2309 1
a2309 1
      replace(size_t __p, size_t __n, _CharT __c)
d2316 1
a2316 1
      replace(size_t __p, size_t __n, const _CharT* __c_string)
d2323 1
a2323 1
      replace(size_t __p, size_t __n,
d2331 1
a2331 1
      replace(size_t __p, size_t __n,
d2339 1
a2339 1
      replace(size_t __p, size_t __n,
d2348 1
a2348 1
      replace(size_t __p, _CharT __c)
d2355 1
a2355 1
      replace(size_t __p, const rope& __r)
d2359 1
a2359 1
      replace(size_t __p, const _CharT* __i, size_t __i_len)
d2363 1
a2363 1
      replace(size_t __p, const _CharT* __c_string)
d2367 1
a2367 1
      replace(size_t __p, const _CharT* __i, const _CharT* __j)
d2371 1
a2371 1
      replace(size_t __p, const const_iterator& __i,
d2376 1
a2376 1
      replace(size_t __p, const iterator& __i,
d2382 1
a2382 1
      erase(size_t __p, size_t __n)
d2392 1
a2392 1
      erase(size_t __p)
d2404 1
a2404 1
      insert(const iterator& __p, size_t __n, _CharT __c)
d2431 1
a2431 1
      insert(const iterator& __p, const _CharT* __i, size_t __n)
d2477 1
a2477 1
	      const _CharT* __i, size_t __n)
d2509 1
a2509 1
      replace(const iterator& __p, const _CharT* __i, size_t __n)
d2528 1
a2528 1
	size_t __p_index = __p.index();
d2536 1
a2536 1
	size_t __p_index = __p.index();
d2542 1
a2542 1
      substr(size_t __start, size_t __len = 1) const
d2560 1
a2560 1
	size_t __pos = __start.index();
d2578 1
a2578 1
	size_t __pos = __start.index();
d2726 1
a2726 1
    inline ptrdiff_t
d2729 4
a2732 1
    { return (ptrdiff_t)__x._M_current_pos - (ptrdiff_t)__y._M_current_pos; }
d2736 2
a2737 1
    operator-(const _Rope_const_iterator<_CharT, _Alloc>& __x, ptrdiff_t __n)
d2743 2
a2744 1
    operator+(const _Rope_const_iterator<_CharT, _Alloc>& __x, ptrdiff_t __n)
d2750 2
a2751 1
    operator+(ptrdiff_t __n, const _Rope_const_iterator<_CharT, _Alloc>& __x)
d2793 1
a2793 1
    inline ptrdiff_t
d2796 2
a2797 2
    { return ((ptrdiff_t)__x._M_current_pos
	      - (ptrdiff_t)__y._M_current_pos); }
d2802 1
a2802 1
	      ptrdiff_t __n)
d2808 1
a2808 1
    operator+(const _Rope_iterator<_CharT, _Alloc>& __x, ptrdiff_t __n)
d2814 1
a2814 1
    operator+(ptrdiff_t __n, const _Rope_iterator<_CharT, _Alloc>& __x)
d2845 1
a2845 1
      size_t __rlen = rope_type::_S_char_ptr_len(__right);
d2933 1
a2933 1
  __mutable_reference_at(crope& __c, size_t __i)
d2937 1
a2937 1
  __mutable_reference_at(wrope& __c, size_t __i)
@


1.8
log
@merge GCC 8.3.0 pass 1.  will not compile yet.  thare are still
about 25 files with merge issues.
@
text
@d3 1
a3 1
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
d1122 1
a1122 1
        if (0 != __x._M_buf_ptr)
d1169 1
a1169 1
        if (0 != __x._M_buf_ptr)
d1348 1
a1348 1
        if (0 != __x._M_buf_ptr)
d1800 1
a1800 1
      bool
@


1.7
log
@first pass at merging GCC 7.4.0.  unlikely to compile..
@
text
@d3 1
a3 1
// Copyright (C) 2001-2017 Free Software Foundation, Inc.
d68 2
a80 2
_GLIBCXX_BEGIN_NAMESPACE_VERSION

d153 1
a153 1
      virtual ~char_producer() { };
d317 1
a317 1
      virtual ~_Rope_char_consumer() { };
d927 1
a927 1
      _Rope_self_destruct_ptr() : _M_ptr(0) { };
d929 1
a929 1
      _Rope_self_destruct_ptr() { };
d1156 1
a1156 1
      _Rope_const_iterator() { };
d1328 1
a1328 1
      };
d2940 2
a2943 2
_GLIBCXX_BEGIN_NAMESPACE_VERSION

d2970 1
a2972 1
} // namespace tr1
@


1.6
log
@merge GCC 6.4.0.  sanitizer stuff is probably busted, but most
other changes merged easily.

docs need to be regenerated with modern versions still.
@
text
@d3 1
a3 1
// Copyright (C) 2001-2016 Free Software Foundation, Inc.
@


1.6.4.1
log
@Sync with HEAD
@
text
@d3 1
a3 1
// Copyright (C) 2001-2017 Free Software Foundation, Inc.
@


1.6.4.2
log
@Mostly merge changes from HEAD upto 20200411
@
text
@d3 1
a3 1
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
a67 2
_GLIBCXX_BEGIN_NAMESPACE_VERSION

d79 2
d153 1
a153 1
      virtual ~char_producer() { }
d317 1
a317 1
      virtual ~_Rope_char_consumer() { }
d927 1
a927 1
      _Rope_self_destruct_ptr() : _M_ptr(0) { }
d929 1
a929 1
      _Rope_self_destruct_ptr() { }
d1156 1
a1156 1
      _Rope_const_iterator() { }
d1328 1
a1328 1
      }
d2940 2
a2943 2
namespace tr1
{
a2969 1
} // namespace tr1
d2972 1
@


1.6.2.1
log
@Sync with HEAD
@
text
@d3 1
a3 1
// Copyright (C) 2001-2017 Free Software Foundation, Inc.
@


1.5
log
@merge GCC 5.3.  round 1.  this probably won't work  :-)

libsanitizer likely needs to be re-ported, though i've done most of
the updating we'll need i think already.
@
text
@d3 1
a3 1
// Copyright (C) 2001-2015 Free Software Foundation, Inc.
@


1.4
log
@merge GCC 4.8 2014-10-09, part 1.
@
text
@d3 1
a3 1
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
d926 1
a926 1
#ifdef __EXCEPTIONS
@


1.3
log
@merge gcc 4.8.2 r206687 (part 2).
@
text
@d1547 1
a1547 1
      using _Base::_M_get_allocator;      
d1879 3
a1881 2
	this->_M_tree_ptr = (0 == __len) ?
	  0 : _S_new_RopeFunction(__fn, __len, __delete_fn, __a);
@


1.3.4.1
log
@Apply patch (requested by mrg in ticket #139):
Update to gcc 4.8-20141009, fixing over 50 GCC PRs and making
sh3 usable.
@
text
@d1547 1
a1547 1
      using _Base::_M_get_allocator;
d1879 2
a1880 3
	this->_M_tree_ptr = (0 == __len)
	  ? 0
	  : _S_new_RopeFunction(__fn, __len, __delete_fn, _M_get_allocator());
@


1.2
log
@Fix template lookup.
@
text
@d3 1
a3 2
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
// Free Software Foundation, Inc.
d46 2
d66 2
a67 2
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)

d79 2
d462 3
d466 1
d468 1
a468 1
    _Refcount_Base(_RC_t __n) : _M_ref_count(__n), _M_ref_count_lock()
d470 2
a471 4
#ifdef __GTHREAD_MUTEX_INIT
      __gthread_mutex_t __tmp = __GTHREAD_MUTEX_INIT;
      _M_ref_count_lock = __tmp;
#elif defined(__GTHREAD_MUTEX_INIT_FUNCTION)
d476 1
d479 5
d593 3
d597 1
d618 1
a618 5
    {
      // Do not copy a POSIX/gthr mutex once in use.  However, bits are bits.
      __gthread_mutex_t __tmp = __GTHREAD_MUTEX_INIT;
      _M_c_string_lock = __tmp;
    }
d620 3
a622 1
    { __GTHREAD_MUTEX_INIT_FUNCTION (&_M_c_string_lock); }
d743 1
a743 1
        this->__STL_FREE_STRING(_M_data, this->_M_size, this->_M_get_allocator());
d1313 1
a1313 1
	  _S_setcache(*this);
d2933 2
a2934 1
_GLIBCXX_END_NAMESPACE
d2937 1
a2937 1
namespace std
d2941 2
d2969 2
@


1.1
log
@Initial revision
@
text
@d730 1
a730 1
        __STL_FREE_STRING(_M_data, this->_M_size, this->_M_get_allocator());
d1171 1
a1171 1
	  _S_setcache(*this);
@


1.1.1.1
log
@initial import of GCC 4.5.3 sources.  changes since 4.1 are way too numerous
to review, please see http://gcc.gnu.org/gcc-4.5/changes.html (and the 4.2,
4.3 and 4.4 versions, too.)

this includes the core, c++, objc and the non java/ada/fortran parts of the
testsuite.
@
text
@@


1.1.1.1.2.1
log
@sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs.  ("Protocol error: too many arguments")
@
text
@d3 2
a4 1
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
a46 2
#pragma GCC system_header

d65 2
a66 2
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
a77 2
_GLIBCXX_BEGIN_NAMESPACE_VERSION

a458 3
#ifdef __GTHREAD_MUTEX_INIT
    __gthread_mutex_t _M_ref_count_lock = __GTHREAD_MUTEX_INIT;
#else
a459 1
#endif
d461 1
a461 1
    _Refcount_Base(_RC_t __n) : _M_ref_count(__n)
d463 4
a466 2
#ifndef __GTHREAD_MUTEX_INIT
#ifdef __GTHREAD_MUTEX_INIT_FUNCTION
a470 1
#endif
a472 5
#ifndef __GTHREAD_MUTEX_INIT
    ~_Refcount_Base()
    { __gthread_mutex_destroy(&_M_ref_count_lock); }
#endif

a581 3
#ifdef __GTHREAD_MUTEX_INIT
      __gthread_mutex_t _M_c_string_lock = __GTHREAD_MUTEX_INIT;
#else
a582 1
#endif
d603 5
a607 1
      { }
d609 1
a609 3
      { __GTHREAD_MUTEX_INIT_FUNCTION (&_M_c_string_lock); }
      ~_Rope_RopeRep()
      { __gthread_mutex_destroy (&_M_c_string_lock); }
d730 1
a730 1
	this->__STL_FREE_STRING(_M_data, this->_M_size, this->_M_get_allocator());
d1171 1
a1171 1
	  this->_S_setcache(*this);
d1300 1
a1300 1
	  this->_S_setcache(*this);
d2920 1
a2920 2
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
d2923 1
a2923 1
namespace std _GLIBCXX_VISIBILITY(default)
a2926 2
_GLIBCXX_BEGIN_NAMESPACE_VERSION

a2952 2

_GLIBCXX_END_NAMESPACE_VERSION
@


1.1.1.2
log
@import GCC 4.8 branch at r206687.

highlights from: http://gcc.gnu.org/gcc-4.6/changes.html

   GCC now has stricter checks for invalid command-line options
   New -Wunused-but-set-variable and -Wunused-but-set-parameter
      warnings
   Many platforms have been obsoleted
   Link-time optimization improvements
   A new switch -fstack-usage has been added
   A new function attribute leaf was introduced
   A new warning, enabled by -Wdouble-promotion
   Support for selectively enabling and disabling warnings via
      #pragma GCC diagnostic has been added
   There is now experimental support for some features from the
      upcoming C1X revision of the ISO C standard
   Improved experimental support for the upcoming C++0x ISO C++
      standard
   G++ now issues clearer diagnostics in several cases
   Updates for ARM, x86, MIPS, PPC/PPC64, SPARC
   Darwin, FreeBSD, Solaris 2, MinGW and Cygwin now all support
      __float128 on 32-bit and 64-bit x86 targets. [*1]

highlights from: http://gcc.gnu.org/gcc-4.7/changes.html

   The -fconserve-space flag has been deprecated
   Support for a new parameter --param case-values-threshold=n
      was added
   Interprocedural and Link-time optimization improvements
   A new built-in, __builtin_assume_aligned, has been added
   A new warning option -Wunused-local-typedefs was added
   A new experimental command-line option -ftrack-macro-expansion
      was added
   Support for atomic operations specifying the C++11/C11 memory
      model has been added
   There is support for some more features from the C11 revision
      of the ISO C standard
   Improved experimental support for the new ISO C++ standard,
      C++11
   Updates for ARM, x86, MIPS, PPC/PPC64, SH, SPARC, TILE*
   A new option (-grecord-gcc-switches) was added

highlights from: http://gcc.gnu.org/gcc-4.8/changes.html

   GCC now uses C++ as its implementation language.  This means
      that to build GCC from sources, you will need a C++
      compiler that understands C++ 2003
   DWARF4 is now the default when generating DWARF debug
      information
   A new general optimization level, -Og, has been introduced
   A new option -ftree-partial-pre was added
   The option -fconserve-space has been removed
   The command-line options -fipa-struct-reorg and
      -fipa-matrix-reorg have been removed
   Interprocedural and Link-time optimization improvements
   AddressSanitizer, a fast memory error detector, has been
      added  [*2]
   A new -Wsizeof-pointer-memaccess warning has been added
   G++ now supports a -std=c++1y option for experimentation
      with features proposed for the next revision of the
      standard, expected around 2014
   Improved experimental support for the new ISO C++ standard,
      C++11
   A new port has been added to support AArch64
   Updates for ARM, x86, MIPS, PPC/PPC64, SH, SPARC, TILE*


[*1] we should support this too!
[*2] we should look into this.
     https://code.google.com/p/address-sanitizer/
@
text
@d3 2
a4 1
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
a46 2
#pragma GCC system_header

d65 2
a66 2
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
a77 2
_GLIBCXX_BEGIN_NAMESPACE_VERSION

a458 3
#ifdef __GTHREAD_MUTEX_INIT
    __gthread_mutex_t _M_ref_count_lock = __GTHREAD_MUTEX_INIT;
#else
a459 1
#endif
d461 1
a461 1
    _Refcount_Base(_RC_t __n) : _M_ref_count(__n)
d463 4
a466 2
#ifndef __GTHREAD_MUTEX_INIT
#ifdef __GTHREAD_MUTEX_INIT_FUNCTION
a470 1
#endif
a472 5
#ifndef __GTHREAD_MUTEX_INIT
    ~_Refcount_Base()
    { __gthread_mutex_destroy(&_M_ref_count_lock); }
#endif

a581 3
#ifdef __GTHREAD_MUTEX_INIT
      __gthread_mutex_t _M_c_string_lock = __GTHREAD_MUTEX_INIT;
#else
a582 1
#endif
d603 5
a607 1
      { }
d609 1
a609 3
      { __GTHREAD_MUTEX_INIT_FUNCTION (&_M_c_string_lock); }
      ~_Rope_RopeRep()
      { __gthread_mutex_destroy (&_M_c_string_lock); }
d730 1
a730 1
	this->__STL_FREE_STRING(_M_data, this->_M_size, this->_M_get_allocator());
d1171 1
a1171 1
	  this->_S_setcache(*this);
d1300 1
a1300 1
	  this->_S_setcache(*this);
d2920 1
a2920 2
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
d2923 1
a2923 1
namespace std _GLIBCXX_VISIBILITY(default)
a2926 2
_GLIBCXX_BEGIN_NAMESPACE_VERSION

a2952 2

_GLIBCXX_END_NAMESPACE_VERSION
@


1.1.1.3
log
@initial import of GCC 4.8 snapshot 2014-10-09.  this fixes at
least the below GCC PRs, among many other changes.

it also makes sh3 reasonably useful again.

	c++/60731
	c/61271
	c/61271
	c/61271
	debug/55794
	debug/60655
	debug/61923
	debug/63284
	debug/63342
	inline-asm/63282
	ipa/61986
	ipa/62015
	libobjc/61920
	libobjc/61920
	libstdc++/58962
	libstdc++/60734
	libstdc++/60966
	libstdc++/61946
	libstdc++/63449
	middle-end/61010
	middle-end/61045
	middle-end/62103
	rtl-optimization/57003
	rtl-optimization/60866
	rtl-optimization/60901
	rtl-optimization/61801
	rtl-optimization/62004
	rtl-optimization/62030
	target/49423
	target/52941
	target/61044
	target/61202
	target/61208
	target/61231
	target/61239
	target/61249
	target/61300
	target/61423
	target/61431
	target/61443
	target/61483
	target/61542
	target/61545
	target/61570
	target/61586
	target/61996
	target/62195
	target/62218
	target/63428
	tree-optimization/60196
	tree-optimization/61375
	tree-optimization/61383
	tree-optimization/61452
	tree-optimization/61684
	tree-optimization/61964
	tree-optimization/62073
	tree-optimization/62075
	tree-optimization/63189
	tree-optimization/63341
	tree-optimization/63375
@
text
@d1547 1
a1547 1
      using _Base::_M_get_allocator;
d1879 2
a1880 3
	this->_M_tree_ptr = (0 == __len)
	  ? 0
	  : _S_new_RopeFunction(__fn, __len, __delete_fn, _M_get_allocator());
@


1.1.1.4
log
@import GCC 5.3.0.  see these urls for details which are too large to
include here:

	http://gcc.gnu.org/gcc-4.9/changes.html
	http://gcc.gnu.org/gcc-5/changes.html

(note that GCC 5.x is a release stream like GCC 4.9.x, 4.8.x, etc.)


the main issues we will have are:

The default mode for C is now -std=gnu11 instead of -std=gnu89.

ARM:
The deprecated option -mwords-little-endian has been removed.
The options -mapcs, -mapcs-frame, -mtpcs-frame and -mtpcs-leaf-frame
 which are only applicable to the old ABI have been deprecated.

MIPS:
The o32 ABI has been modified and extended. The o32 64-bit
 floating-point register support is now obsolete and has been removed.
 It has been replaced by three ABI extensions FPXX, FP64A, and FP64.
 The meaning of the -mfp64 command-line option has changed. It is now
 used to enable the FP64A and FP64 ABI extensions.
@
text
@d3 1
a3 1
// Copyright (C) 2001-2015 Free Software Foundation, Inc.
d926 1
a926 1
#if __cpp_exceptions
@


1.1.1.5
log
@import GCC 6.4.0.  see this url for details which are too large to
include here:

   http://gcc.gnu.org/gcc-6/changes.html

the main visible changes appear to be:

- The default mode for C++ is now -std=gnu++14 instead of -std=gnu++98.
- The C and C++ compilers now support attributes on enumerators.
- Diagnostics can now contain "fix-it hints"
- more warnings (some added to -Wall)
@
text
@d3 1
a3 1
// Copyright (C) 2001-2016 Free Software Foundation, Inc.
@


1.1.1.6
log
@import GCC 7.4.0.  main changes include:

The non-standard C++0x type traits has_trivial_default_constructor,
has_trivial_copy_constructor and has_trivial_copy_assign have been
removed.

On ARM targets (arm*-*-*), a bug introduced in GCC 5 that affects
conformance to the procedure call standard (AAPCS) has been fixed.

Many optimiser improvements

DWARF-5 support.

Many new and enhanced warnings.

Warnings about format strings now underline the pertinent part of
the string, and can offer suggested fixes.

Several new warnings related to buffer overflows and buffer
truncation.

New __builtin_add_overflow_p, __builtin_sub_overflow_p,
__builtin_mul_overflow_p built-ins added that test for overflow.

The C++ front end has experimental support for all of the current
C++17 draft.

The -fverbose-asm option has been expanded to prints comments
showing the source lines that correspond to the assembly.

The gcc and g++ driver programs will now provide suggestions for
misspelled arguments to command-line options.


AArch64 specific:

GCC has been updated to the latest revision of the procedure call
standard (AAPCS64) to provide support for parameter passing when
data types have been over-aligned.

The ARMv8.2-A and ARMv8.3-A architecture are now supported.

ARM specific:

Support for the ARMv5 and ARMv5E architectures has been
deprecated (which have no known implementations).

A new command-line option -mpure-code has been added. It does not
allow constant data to be placed in code sections.

x86 specific:

Support for the AVX-512 4FMAPS, 4VNNIW, VPOPCNTDQ and Software
Guard Extensions (SGX) ISA extensions has been added.

PPC specific:

GCC now diagnoses inline assembly that clobbers register r2.

RISC-V specific:

Support for the RISC-V instruction set has been added.

SH specific:

Support for SH5/SH64 has been removed.

Support for SH2A has been enhanced.
@
text
@d3 1
a3 1
// Copyright (C) 2001-2017 Free Software Foundation, Inc.
@


1.1.1.7
log
@import GCC 8.3.  it includes these new features:
- many optimisations improved: inter-procedural, profile-directed,
  LTO, loops including user-controllable unroll support, and more.
- columns numbers added to line numbers in dwarf
- gcov extended significantly
- many sanitizer updates
- many new warning messages
- many better hints and more useful error messages
- minor ABI changes on x86-64 libstdc++, and some c++17 modes
- draft c++2a features
- better c++17 experimental support
- Armv8.4-A supported, better 8.2-A and 8.3-A support, including
  32 bit arm port.  cortex a-55, a-75 and a-55.a-75 combo support.
- in the GCC bugzilla, 8.1 shows 1149 bugs fixed, 8.2 shows 100, and
  8.3 shows 158.
@
text
@d3 1
a3 1
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
a67 2
_GLIBCXX_BEGIN_NAMESPACE_VERSION

d79 2
d153 1
a153 1
      virtual ~char_producer() { }
d317 1
a317 1
      virtual ~_Rope_char_consumer() { }
d927 1
a927 1
      _Rope_self_destruct_ptr() : _M_ptr(0) { }
d929 1
a929 1
      _Rope_self_destruct_ptr() { }
d1156 1
a1156 1
      _Rope_const_iterator() { }
d1328 1
a1328 1
      }
d2940 2
a2943 2
namespace tr1
{
a2969 1
} // namespace tr1
d2972 1
@


1.1.1.8
log
@import GCC 7.5.0.  doing this here so that the vendor branch has
the code we'll merge into gcc.old and the netbsd-9 tree gcc tree.
GCC 8.4.0 will be imported immediately on top of this again,
restoring the current status.

these PRs in the GCC bugzilla are fixed with this update:

89869 80693 89795 84272 85593 86669 87148 87647 87895 88103 88107 88563
88870 88976 89002 89187 89195 89234 89303 89314 89354 89361 89403 89412
89512 89520 89590 89621 89663 89679 89704 89734 89872 89933 90090 90208
87075 85870 89009 89242 88167 80864 81933 85890 86608 87145 88857 89024
89119 89214 89511 89612 89705 89400 81740 82186 84552 86554 87609 88105
88149 88415 88739 88903 89135 89223 89296 89505 89572 89677 89698 89710
90006 90020 90071 90328 90474 91126 91162 91812 91887 90075 88998 89945
87047 87506 88074 88656 88740 91137 89008 84010 89349 91136 91347 91995
89397 87030 60702 78884 85594 87649 87725 88181 88470 88553 88568 88588
88620 88644 88906 88949 89246 89587 89726 89768 89796 89998 90108 90756
90950 91704 88825 88983 86538 51333 89446 90220 91308 92143 89392 90213
90278 91131 91200 91510 89037 91481 87673 88418 88938 88948 90547 27221
58321 61250 67183 67958 77583 83531 86215 88648 88720 88726 89091 89466
89629 90105 90329 90585 90760 90924 91087 89222 81956 71861 35031 69455
81849 82993 85798 88138 88155 88169 88205 88206 88228 88249 88269 88376
77703 80260 82077 86248 88393 90786 57048 66089 66695 67679 68009 71723
72714 84394 85544 87734 88298 90937 91557 63891 64132 65342 68649 68717
71066 71860 71935 77746 78421 78645 78865 78983 79485 79540 85953 88326
89651 90744
@
text
@d3 1
a3 1
// Copyright (C) 2001-2017 Free Software Foundation, Inc.
d68 2
a80 2
_GLIBCXX_BEGIN_NAMESPACE_VERSION

d153 1
a153 1
      virtual ~char_producer() { };
d317 1
a317 1
      virtual ~_Rope_char_consumer() { };
d927 1
a927 1
      _Rope_self_destruct_ptr() : _M_ptr(0) { };
d929 1
a929 1
      _Rope_self_destruct_ptr() { };
d1156 1
a1156 1
      _Rope_const_iterator() { };
d1328 1
a1328 1
      };
d2940 2
a2943 2
_GLIBCXX_BEGIN_NAMESPACE_VERSION

d2970 1
a2972 1
} // namespace tr1
@


1.1.1.9
log
@re-import GCC 8.4.0.
@
text
@d3 1
a3 1
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
a67 2
_GLIBCXX_BEGIN_NAMESPACE_VERSION

d79 2
d153 1
a153 1
      virtual ~char_producer() { }
d317 1
a317 1
      virtual ~_Rope_char_consumer() { }
d927 1
a927 1
      _Rope_self_destruct_ptr() : _M_ptr(0) { }
d929 1
a929 1
      _Rope_self_destruct_ptr() { }
d1156 1
a1156 1
      _Rope_const_iterator() { }
d1328 1
a1328 1
      }
d2940 2
a2943 2
namespace tr1
{
a2969 1
} // namespace tr1
d2972 1
@


1.1.1.10
log
@initial import of GCC 9.3.0.  changes include:

- live patching support
- shell completion help
- generally better diagnostic output (less verbose/more useful)
- diagnostics and optimisation choices can be emitted in json
- asan memory usage reduction
- many general, and specific to switch, inter-procedure,
  profile and link-time optimisations.  from the release notes:
  "Overall compile time of Firefox 66 and LibreOffice 6.2.3 on
  an 8-core machine was reduced by about 5% compared to GCC 8.3"
- OpenMP 5.0 support
- better spell-guesser
- partial experimental support for c2x and c++2a
- c++17 is no longer experimental
- arm AAPCS GCC 6-8 structure passing bug fixed, may cause
  incompatibility (restored compat with GCC 5 and earlier.)
- openrisc support
@
text
@d3 1
a3 1
// Copyright (C) 2001-2019 Free Software Foundation, Inc.
d1122 1
a1122 1
        if (0 != __x._M_buf_ptr && __x._M_buf_start != __x._M_tmp_buf)
d1169 1
a1169 1
        if (0 != __x._M_buf_ptr && __x._M_buf_start != __x._M_tmp_buf)
d1348 1
a1348 1
        if (0 != __x._M_buf_ptr && __x._M_buf_start != __x._M_tmp_buf)
d1800 1
a1800 1
      _GLIBCXX_NODISCARD bool
@


1.1.1.11
log
@initial import of GCC 10.3.0.  main changes include:

caveats:
- ABI issue between c++14 and c++17 fixed
- profile mode is removed from libstdc++
- -fno-common is now the default

new features:
- new flags -fallocation-dce, -fprofile-partial-training,
  -fprofile-reproducible, -fprofile-prefix-path, and -fanalyzer
- many new compile and link time optimisations
- enhanced drive optimisations
- openacc 2.6 support
- openmp 5.0 features
- new warnings: -Wstring-compare and -Wzero-length-bounds
- extended warnings: -Warray-bounds, -Wformat-overflow,
  -Wrestrict, -Wreturn-local-addr, -Wstringop-overflow,
  -Warith-conversion, -Wmismatched-tags, and -Wredundant-tags
- some likely C2X features implemented
- more C++20 implemented
- many new arm & intel CPUs known

hundreds of reported bugs are fixed.  full list of changes
can be found at:

   https://gcc.gnu.org/gcc-10/changes.html
@
text
@d3 1
a3 1
// Copyright (C) 2001-2020 Free Software Foundation, Inc.
a55 1
#include <ext/alloc_traits.h>
d76 5
d94 2
a95 2
		   _ForwardIterator __last, std::allocator<_Tp>)
    { std::_Destroy(__first, __last); }
d156 1
a156 1
      operator()(std::size_t __start_pos, std::size_t __len,
d178 1
a178 1
  template<class _Sequence, std::size_t _Buf_sz = 100>
d187 1
a187 1
      std::size_t _M_buf_count;
d255 1
a255 1
      append(value_type* __s, std::size_t __len)
d259 2
a260 2
	    std::size_t __i = _M_buf_count;
	    for (std::size_t __j = 0; __j < __len; __i++, __j++)
d274 1
a274 1
      write(value_type* __s, std::size_t __len)
d320 1
a320 1
      operator()(const _CharT* __buffer, std::size_t __len) = 0;
d326 1
a326 1
  template<class _CharT, class _Alloc = std::allocator<_CharT> >
d361 1
a361 1
	      std::ptrdiff_t __n);
d366 1
a366 1
	      std::ptrdiff_t __n);
d370 1
a370 1
    operator+(std::ptrdiff_t __n,
d384 1
a384 1
    std::ptrdiff_t
d390 1
a390 1
    operator-(const _Rope_iterator<_CharT, _Alloc>& __x, std::ptrdiff_t __n);
d394 1
a394 1
    operator+(const _Rope_iterator<_CharT, _Alloc>& __x, std::ptrdiff_t __n);
d398 1
a398 1
    operator+(std::ptrdiff_t __n, const _Rope_iterator<_CharT, _Alloc>& __x);
d411 1
a411 1
    std::ptrdiff_t
d456 1
a456 1
    typedef std::size_t _RC_t;
a550 1
      typedef std::size_t size_type;
d565 1
a565 1
      _Rope_rep_base(size_type __size, const allocator_type&)
d568 1
a568 1
      size_type _M_size;
d572 2
a573 2
          __alloc_traits<_Alloc>::template rebind<_Tp>::other __name##Alloc; \
        static _Tp* __name##_allocate(size_type __n) \
d575 1
a575 1
        static void __name##_deallocate(_Tp *__p, size_type __n) \
a605 1
      typedef std::size_t size_type;
d610 1
a610 1
      _Rope_RopeRep(__detail::_Tag __t, int __d, bool __b, size_type __size,
d629 1
a629 1
      _S_free_string(__GC_CONST _CharT*, size_type __len,
a690 1
      typedef std::size_t size_type;
d698 2
a699 2
      static size_type
      _S_rounded_up_size(size_type __n)
d701 1
a701 1
        size_type __size_with_eos;
d711 2
a712 2
	return ((__size_with_eos + size_type(_S_alloc_granularity) - 1)
		&~ (size_type(_S_alloc_granularity) - 1));
d723 1
a723 1
      _Rope_RopeLeaf(__GC_CONST _CharT* __d, size_type __size,
d813 1
a813 1
      _Rope_RopeFunction(char_producer<_CharT>* __f, std::size_t __size,
a854 1
      typedef std::size_t size_type;
d858 1
a858 1
      size_type _M_start;
d861 1
a861 1
      operator()(size_type __start_pos, size_type __req_len,
d890 2
a891 2
      _Rope_RopeSubstring(_Rope_RopeRep<_CharT, _Alloc>* __b, size_type __s,
                          size_type __l, const allocator_type& __a)
d969 1
a969 1
      std::size_t _M_pos;
d974 1
a974 1
      _Rope_char_ref_proxy(_My_rope* __r, std::size_t __p)
d985 1
a985 1
      _Rope_char_ref_proxy(_My_rope* __r, std::size_t __p, _CharT __c)
d1015 1
a1015 1
      std::size_t _M_pos;
d1067 1
a1067 1
      std::size_t _M_current_pos;
d1069 1
a1069 1
      std::size_t _M_leaf_pos; // Starting position for current leaf
d1110 1
a1110 1
      _Rope_iterator_base(_RopeRep* __root, std::size_t __pos)
d1113 2
a1114 2
      void _M_incr(std::size_t __n);
      void _M_decr(std::size_t __n);
d1116 1
a1116 1
      std::size_t
d1144 1
a1144 1
      _Rope_const_iterator(const _RopeRep* __root, std::size_t __pos)
d1163 1
a1163 1
      _Rope_const_iterator(const rope<_CharT, _Alloc>& __r, std::size_t __pos)
d1212 1
a1212 1
      operator+=(std::ptrdiff_t __n)
d1229 1
a1229 1
      operator-=(std::ptrdiff_t __n)
d1241 1
a1241 1
	std::size_t __old_pos = this->_M_current_pos;
d1252 1
a1252 1
	std::size_t __old_pos = this->_M_current_pos;
d1260 1
a1260 1
		  std::ptrdiff_t __n);
d1265 1
a1265 1
		  std::ptrdiff_t __n);
d1269 1
a1269 1
        operator+(std::ptrdiff_t __n,
d1273 1
a1273 1
      operator[](std::size_t __n)
d1288 1
a1288 1
        friend std::ptrdiff_t
d1308 1
a1308 1
      _Rope_iterator(rope<_CharT, _Alloc>* __r, std::size_t __pos)
d1337 1
a1337 1
      _Rope_iterator(rope<_CharT, _Alloc>& __r, std::size_t __pos);
d1392 1
a1392 1
      operator+=(std::ptrdiff_t __n)
d1409 1
a1409 1
      operator-=(std::ptrdiff_t __n)
d1421 1
a1421 1
	std::size_t __old_pos = this->_M_current_pos;
d1429 1
a1429 1
	std::size_t __old_pos = this->_M_current_pos;
d1435 1
a1435 1
      operator[](std::ptrdiff_t __n)
d1451 1
a1451 1
        friend std::ptrdiff_t
d1457 1
a1457 2
        operator-(const _Rope_iterator<_CharT2, _Alloc2>& __x,
		  std::ptrdiff_t __n);
d1461 1
a1461 2
        operator+(const _Rope_iterator<_CharT2, _Alloc2>& __x,
		  std::ptrdiff_t __n);
d1465 1
a1465 2
        operator+(std::ptrdiff_t __n,
		  const _Rope_iterator<_CharT2, _Alloc2>& __x);
d1500 2
a1501 2
          __alloc_traits<_Alloc>::template rebind<_Tp>::other __name##Alloc; \
        static _Tp* __name##_allocate(std::size_t __n) \
d1503 1
a1503 1
        static void __name##_deallocate(_Tp *__p, std::size_t __n) \
d1525 2
a1526 2
      typedef std::ptrdiff_t difference_type;
      typedef std::size_t size_type;
d1583 1
a1583 1
			 size_type __begin, size_type __end);
d1608 1
a1608 1
                                    size_type __start, size_type __endp1);
d1611 1
a1611 2
					   const _CharT* __iter,
					   size_type __slen);
d1617 1
a1617 1
						 size_type __slen)
d1634 1
a1634 1
      apply_to_pieces(size_type __begin, size_type __end,
d1640 2
a1641 2
      static size_type
      _S_rounded_up_size(size_type __n)
d1644 2
a1645 2
      static size_type
      _S_allocated_capacity(size_type __n)
d1658 1
a1658 1
		      size_type __size, allocator_type& __a)
d1674 1
a1674 1
			  size_type __size, bool __d, allocator_type& __a)
d1681 2
a1682 2
      _S_new_RopeSubstring(_Rope_RopeRep<_CharT,_Alloc>* __b, size_type __s,
			   size_type __l, allocator_type& __a)
d1690 1
a1690 1
					size_type __size, allocator_type& __a)
d1721 1
a1721 1
			       const _CharT* __iter, size_type __slen);
d1728 1
a1728 1
				     const _CharT* __iter, size_type __slen);
d1734 1
a1734 1
      static size_type _S_char_ptr_len(const _CharT* __s);
d1749 1
a1749 1
				size_type __start, size_type __len,
d1819 1
a1819 1
      rope(const _CharT* __s, size_type __len,
d1855 1
a1855 2
	__alloc_traits<allocator_type>::construct(_M_get_allocator(),
						  __buf, __c);
d1868 1
a1868 1
      rope(size_type __n, _CharT __c,
d1875 1
a1875 1
      rope(char_producer<_CharT> *__fn, size_type __len, bool __delete_fn,
d1985 2
a1986 2
	size_type __size = size();
	size_type __len = (__pos + __n > __size? __size - __pos : __n);
d2111 1
a2111 1
      append(const _CharT* __iter, size_type __n)
d2123 1
a2123 1
	size_type __len = _S_char_ptr_len(__c_string);
d2175 1
a2175 1
      append(size_type __n, _CharT __c)
d2192 2
a2193 2
      replace(_RopeRep* __old, size_type __pos1,
	      size_type __pos2, _RopeRep* __r)
d2216 1
a2216 1
      insert(size_type __p, const rope& __r)
d2225 1
a2225 1
      insert(size_type __p, size_type __n, _CharT __c)
d2232 1
a2232 1
      insert(size_type __p, const _CharT* __i, size_type __n)
d2247 1
a2247 1
      insert(size_type __p, const _CharT* __c_string)
d2251 1
a2251 1
      insert(size_type __p, _CharT __c)
d2255 1
a2255 1
      insert(size_type __p)
d2262 1
a2262 1
      insert(size_type __p, const _CharT* __i, const _CharT* __j)
d2269 1
a2269 1
      insert(size_type __p, const const_iterator& __i,
d2277 1
a2277 1
      insert(size_type __p, const iterator& __i,
d2287 1
a2287 1
      replace(size_type __p, size_type __n, const rope& __r)
d2296 2
a2297 2
      replace(size_type __p, size_type __n,
	      const _CharT* __i, size_type __i_len)
d2304 1
a2304 1
      replace(size_type __p, size_type __n, _CharT __c)
d2311 1
a2311 1
      replace(size_type __p, size_type __n, const _CharT* __c_string)
d2318 1
a2318 1
      replace(size_type __p, size_type __n,
d2326 1
a2326 1
      replace(size_type __p, size_type __n,
d2334 1
a2334 1
      replace(size_type __p, size_type __n,
d2343 1
a2343 1
      replace(size_type __p, _CharT __c)
d2350 1
a2350 1
      replace(size_type __p, const rope& __r)
d2354 1
a2354 1
      replace(size_type __p, const _CharT* __i, size_type __i_len)
d2358 1
a2358 1
      replace(size_type __p, const _CharT* __c_string)
d2362 1
a2362 1
      replace(size_type __p, const _CharT* __i, const _CharT* __j)
d2366 1
a2366 1
      replace(size_type __p, const const_iterator& __i,
d2371 1
a2371 1
      replace(size_type __p, const iterator& __i,
d2377 1
a2377 1
      erase(size_type __p, size_type __n)
d2387 1
a2387 1
      erase(size_type __p)
d2399 1
a2399 1
      insert(const iterator& __p, size_type __n, _CharT __c)
d2426 1
a2426 1
      insert(const iterator& __p, const _CharT* __i, size_type __n)
d2472 1
a2472 1
	      const _CharT* __i, size_type __n)
d2504 1
a2504 1
      replace(const iterator& __p, const _CharT* __i, size_type __n)
d2523 1
a2523 1
	size_type __p_index = __p.index();
d2531 1
a2531 1
	size_type __p_index = __p.index();
d2537 1
a2537 1
      substr(size_type __start, size_type __len = 1) const
d2555 1
a2555 1
	size_type __pos = __start.index();
d2573 1
a2573 1
	size_type __pos = __start.index();
d2721 1
a2721 1
    inline std::ptrdiff_t
d2724 1
a2724 4
    {
      return (std::ptrdiff_t)__x._M_current_pos
	- (std::ptrdiff_t)__y._M_current_pos;
    }
d2728 1
a2728 2
    operator-(const _Rope_const_iterator<_CharT, _Alloc>& __x,
	      std::ptrdiff_t __n)
d2734 1
a2734 2
    operator+(const _Rope_const_iterator<_CharT, _Alloc>& __x,
	      std::ptrdiff_t __n)
d2740 1
a2740 2
    operator+(std::ptrdiff_t __n,
	      const _Rope_const_iterator<_CharT, _Alloc>& __x)
d2782 1
a2782 1
    inline std::ptrdiff_t
d2785 2
a2786 2
    { return ((std::ptrdiff_t)__x._M_current_pos
	      - (std::ptrdiff_t)__y._M_current_pos); }
d2791 1
a2791 1
	      std::ptrdiff_t __n)
d2797 1
a2797 1
    operator+(const _Rope_iterator<_CharT, _Alloc>& __x, std::ptrdiff_t __n)
d2803 1
a2803 1
    operator+(std::ptrdiff_t __n, const _Rope_iterator<_CharT, _Alloc>& __x)
d2834 1
a2834 1
      std::size_t __rlen = rope_type::_S_char_ptr_len(__right);
d2922 1
a2922 1
  __mutable_reference_at(crope& __c, std::size_t __i)
d2926 1
a2926 1
  __mutable_reference_at(wrope& __c, std::size_t __i)
@


1.1.1.12
log
@initial import of GCC 10.4.0 sources.

mostly a large list of PRs fixed (210 total), plus one x86-64
specific change related to MMX and 64 bit integer return.

https://gcc.gnu.org/gcc-10/changes.html links to the full list
of PRs fixed.
@
text
@d2391 1
a2391 1
      _GLIBCXX_DEPRECATED void
@


1.1.1.13
log
@initial import of GCC 12.3.0.

major changes in GCC 11 included:

- The default mode for C++ is now -std=gnu++17 instead of -std=gnu++14.
- When building GCC itself, the host compiler must now support C++11,
  rather than C++98.
- Some short options of the gcov tool have been renamed: -i to -j and
  -j to -H.
- ThreadSanitizer improvements.
- Introduce Hardware-assisted AddressSanitizer support.
- For targets that produce DWARF debugging information GCC now defaults
  to DWARF version 5. This can produce up to 25% more compact debug
  information compared to earlier versions.
- Many optimisations.
- The existing malloc attribute has been extended so that it can be
  used to identify allocator/deallocator API pairs. A pair of new
  -Wmismatched-dealloc and -Wmismatched-new-delete warnings are added.
- Other new warnings:
  -Wsizeof-array-div, enabled by -Wall, warns about divisions of two
    sizeof operators when the first one is applied to an array and the
    divisor does not equal the size of the array element.
  -Wstringop-overread, enabled by default, warns about calls to string
    functions reading past the end of the arrays passed to them as
    arguments.
  -Wtsan, enabled by default, warns about unsupported features in
    ThreadSanitizer (currently std::atomic_thread_fence).
- Enchanced warnings:
  -Wfree-nonheap-object detects many more instances of calls to
    deallocation functions with pointers not returned from a dynamic
    memory allocation function.
  -Wmaybe-uninitialized diagnoses passing pointers or references to
    uninitialized memory to functions taking const-qualified arguments.
  -Wuninitialized detects reads from uninitialized dynamically
    allocated memory.
  -Warray-parameter warns about functions with inconsistent array forms.
  -Wvla-parameter warns about functions with inconsistent VLA forms.
- Several new features from the upcoming C2X revision of the ISO C
  standard are supported with -std=c2x and -std=gnu2x.
- Several C++20 features have been implemented.
- The C++ front end has experimental support for some of the upcoming
  C++23 draft.
- Several new C++ warnings.
- Enhanced Arm, AArch64, x86, and RISC-V CPU support.
- The implementation of how program state is tracked within
  -fanalyzer has been completely rewritten with many enhancements.

see https://gcc.gnu.org/gcc-11/changes.html for a full list.

major changes in GCC 12 include:

- An ABI incompatibility between C and C++ when passing or returning
  by value certain aggregates containing zero width bit-fields has
  been discovered on various targets. x86-64, ARM and AArch64
  will always ignore them (so there is a C ABI incompatibility
  between GCC 11 and earlier with GCC 12 or later), PowerPC64 ELFv2
  always take them into account (so there is a C++ ABI
  incompatibility, GCC 4.4 and earlier compatible with GCC 12 or
  later, incompatible with GCC 4.5 through GCC 11). RISC-V has
  changed the handling of these already starting with GCC 10. As
  the ABI requires, MIPS takes them into account handling function
  return values so there is a C++ ABI incompatibility with GCC 4.5
  through 11.
- STABS: Support for emitting the STABS debugging format is
  deprecated and will be removed in the next release. All ports now
  default to emit DWARF (version 2 or later) debugging info or are
  obsoleted.
- Vectorization is enabled at -O2 which is now equivalent to the
  original -O2 -ftree-vectorize -fvect-cost-model=very-cheap.
- GCC now supports the ShadowCallStack sanitizer.
- Support for __builtin_shufflevector compatible with the clang
  language extension was added.
- Support for attribute unavailable was added.
- Support for __builtin_dynamic_object_size compatible with the
  clang language extension was added.
- New warnings:
  -Wbidi-chars warns about potentially misleading UTF-8
    bidirectional control characters.
  -Warray-compare warns about comparisons between two operands of
    array type.
- Some new features from the upcoming C2X revision of the ISO C
  standard are supported with -std=c2x and -std=gnu2x.
- Several C++23 features have been implemented.
- Many C++ enhancements across warnings and -f options.

see https://gcc.gnu.org/gcc-12/changes.html for a full list.
@
text
@d3 1
a3 1
// Copyright (C) 2001-2022 Free Software Foundation, Inc.
a173 4
// Ignore warnings about std::iterator.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"

a205 1
      // Non-const "copy" modifies the parameter - yuck
a215 1
      // Non-const "copy" modifies the parameter - yuck
d233 1
a233 6

#if __cplusplus >= 201103L
      sequence_buffer(sequence_buffer&& __x) : sequence_buffer(__x) { }
      sequence_buffer& operator=(sequence_buffer&& __x) { return *this = __x; }
#endif

a301 1
#pragma GCC diagnostic pop
d426 1
a426 4

// Ignore warnings about std::binary_function.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
a438 1
#pragma GCC diagnostic pop
d455 1
a455 1
    _RC_t _M_ref_count;
d492 1
a492 1
      _RC_t __tmp = --_M_ref_count;
d678 1
a678 1
    protected:
d745 1
a745 1
    protected:
d781 1
a781 1
    protected:
a1054 3
// Ignore warnings about std::iterator
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
a1131 1
#pragma GCC diagnostic pop
d1511 1
a1511 1
    protected:
d1615 2
a1616 3
					   size_type __slen,
					   allocator_type& __a);
      // Concatenate rope and char ptr, copying __iter.
d1621 1
a1621 2
						 size_type __slen,
						 allocator_type& __a)
d1627 1
a1627 1
      { return _S_concat_char_iter(__r, __iter, __slen, __a); }
a1915 1
	allocator_type __a = _M_get_allocator();
d1918 1
a1918 1
	  = _S_destr_concat_char_iter(this->_M_tree_ptr, &__x, 1, __a);
a2117 1
	allocator_type __a = _M_get_allocator();
d2119 1
a2119 1
	  _S_destr_concat_char_iter(this->_M_tree_ptr, __iter, __n, __a);
a2135 1
	allocator_type __a = _M_get_allocator();
d2137 1
a2137 1
	  _S_destr_concat_char_iter(this->_M_tree_ptr, __s, __e - __s, __a);
a2158 1
	allocator_type __a = _M_get_allocator();
d2160 1
a2160 1
	  _S_destr_concat_char_iter(this->_M_tree_ptr, &__c, 1, __a);
d2242 1
a2242 2
	_Self_destruct_ptr __left_result(_S_concat_char_iter(__left, __i, __n,
							     _M_get_allocator()));
d2390 5
a2845 1
      _Alloc __a = __left.get_allocator();
d2847 1
a2847 1
						      __right, __rlen, __a));
a2863 1
      _Alloc __a = __left.get_allocator();
d2865 1
a2865 1
						      &__right, 1, __a));
@


1.1.1.14
log
@initial import of GCC 14.3.0.

major changes in GCC 13:
- improved sanitizer
- zstd debug info compression
- LTO improvements
- SARIF based diagnostic support
- new warnings: -Wxor-used-as-pow, -Wenum-int-mismatch, -Wself-move,
  -Wdangling-reference
- many new -Wanalyzer* specific warnings
- enhanced warnings: -Wpessimizing-move, -Wredundant-move
- new attributes to mark file descriptors, c++23 "assume"
- several C23 features added
- several C++23 features added
- many new features for Arm, x86, RISC-V

major changes in GCC 14:
- more strict C99 or newer support
- ia64* marked deprecated (but seemingly still in GCC 15.)
- several new hardening features
- support for "hardbool", which can have user supplied values of true/false
- explicit support for stack scrubbing upon function exit
- better auto-vectorisation support
- added clang-compatible __has_feature and __has_extension
- more C23, including -std=c23
- several C++26 features added
- better diagnostics in C++ templates
- new warnings: -Wnrvo, Welaborated-enum-base
- many new features for Arm, x86, RISC-V
- possible ABI breaking change for SPARC64 and small structures with arrays
  of floats.
@
text
@d3 1
a3 1
// Copyright (C) 2001-2024 Free Software Foundation, Inc.
a47 2
#include <bits/requires_hosted.h> // GNU extensions are currently omitted

@


1.1.1.1.8.1
log
@resync from head
@
text
@d730 1
a730 1
        this->__STL_FREE_STRING(_M_data, this->_M_size, this->_M_get_allocator());
d1171 1
a1171 1
	  this->_S_setcache(*this);
@


1.1.1.1.8.2
log
@Rebase to HEAD as of a few days ago.
@
text
@d3 2
a4 1
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
a46 2
#pragma GCC system_header

d65 2
a66 2
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
a77 2
_GLIBCXX_BEGIN_NAMESPACE_VERSION

a458 3
#ifdef __GTHREAD_MUTEX_INIT
    __gthread_mutex_t _M_ref_count_lock = __GTHREAD_MUTEX_INIT;
#else
a459 1
#endif
d461 1
a461 1
    _Refcount_Base(_RC_t __n) : _M_ref_count(__n)
d463 4
a466 2
#ifndef __GTHREAD_MUTEX_INIT
#ifdef __GTHREAD_MUTEX_INIT_FUNCTION
a470 1
#endif
a472 5
#ifndef __GTHREAD_MUTEX_INIT
    ~_Refcount_Base()
    { __gthread_mutex_destroy(&_M_ref_count_lock); }
#endif

a581 3
#ifdef __GTHREAD_MUTEX_INIT
      __gthread_mutex_t _M_c_string_lock = __GTHREAD_MUTEX_INIT;
#else
a582 1
#endif
d603 5
a607 1
      { }
d609 1
a609 3
      { __GTHREAD_MUTEX_INIT_FUNCTION (&_M_c_string_lock); }
      ~_Rope_RopeRep()
      { __gthread_mutex_destroy (&_M_c_string_lock); }
d730 1
a730 1
	this->__STL_FREE_STRING(_M_data, this->_M_size, this->_M_get_allocator());
d1300 1
a1300 1
	  this->_S_setcache(*this);
d2920 1
a2920 2
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
d2923 1
a2923 1
namespace std _GLIBCXX_VISIBILITY(default)
a2926 2
_GLIBCXX_BEGIN_NAMESPACE_VERSION

a2952 2

_GLIBCXX_END_NAMESPACE_VERSION
@


