head	1.1;
branch	1.1.1;
access;
symbols
	gcc-14-4-0:1.1.1.16
	netbsd-10-2-RELEASE:1.1.1.12
	netbsd-9-5-RELEASE:1.1.1.6
	netbsd-11-0-RELEASE:1.1.1.14
	netbsd-11-0-RC7:1.1.1.14
	netbsd-11-0-RC6:1.1.1.14
	netbsd-11-0-RC5:1.1.1.14
	netbsd-11-0-RC4:1.1.1.14
	netbsd-11-0-RC3:1.1.1.14
	netbsd-11-0-RC2:1.1.1.14
	netbsd-11-0-RC1:1.1.1.14
	gcc-14-3-0:1.1.1.15
	perseant-exfatfs-base-20250801:1.1.1.14
	netbsd-11:1.1.1.14.0.2
	netbsd-11-base:1.1.1.14
	gcc-12-5-0:1.1.1.14
	netbsd-10-1-RELEASE:1.1.1.12
	perseant-exfatfs-base-20240630:1.1.1.13
	gcc-12-4-0:1.1.1.13
	perseant-exfatfs:1.1.1.13.0.2
	perseant-exfatfs-base:1.1.1.13
	netbsd-8-3-RELEASE:1.1.1.3
	netbsd-9-4-RELEASE:1.1.1.6
	netbsd-10-0-RELEASE:1.1.1.12
	netbsd-10-0-RC6:1.1.1.12
	netbsd-10-0-RC5:1.1.1.12
	netbsd-10-0-RC4:1.1.1.12
	netbsd-10-0-RC3:1.1.1.12
	netbsd-10-0-RC2:1.1.1.12
	netbsd-10-0-RC1:1.1.1.12
	gcc-12-3-0:1.1.1.13
	gcc-10-5-0:1.1.1.12
	netbsd-10:1.1.1.12.0.2
	netbsd-10-base:1.1.1.12
	netbsd-9-3-RELEASE:1.1.1.6
	gcc-10-4-0:1.1.1.12
	cjep_sun2x-base1:1.1.1.11
	cjep_sun2x:1.1.1.11.0.4
	cjep_sun2x-base:1.1.1.11
	cjep_staticlib_x-base1:1.1.1.11
	netbsd-9-2-RELEASE:1.1.1.6
	cjep_staticlib_x:1.1.1.11.0.2
	cjep_staticlib_x-base:1.1.1.11
	gcc-10-3-0:1.1.1.11
	netbsd-9-1-RELEASE:1.1.1.6
	gcc-9-3-0:1.1.1.10
	gcc-7-5-0:1.1.1.8
	phil-wifi-20200421:1.1.1.7
	phil-wifi-20200411:1.1.1.7
	is-mlppp:1.1.1.7.0.2
	is-mlppp-base:1.1.1.7
	phil-wifi-20200406:1.1.1.7
	netbsd-8-2-RELEASE:1.1.1.3
	gcc-8-4-0:1.1.1.9
	netbsd-9-0-RELEASE:1.1.1.6
	netbsd-9-0-RC2:1.1.1.6
	netbsd-9-0-RC1:1.1.1.6
	phil-wifi-20191119:1.1.1.7
	gcc-8-3-0:1.1.1.7
	netbsd-9:1.1.1.6.0.2
	netbsd-9-base:1.1.1.6
	phil-wifi-20190609:1.1.1.6
	netbsd-8-1-RELEASE:1.1.1.3
	netbsd-8-1-RC1:1.1.1.3
	pgoyette-compat-merge-20190127:1.1.1.4.2.2
	pgoyette-compat-20190127:1.1.1.6
	gcc-7-4-0:1.1.1.6
	pgoyette-compat-20190118:1.1.1.5
	pgoyette-compat-1226:1.1.1.5
	pgoyette-compat-1126:1.1.1.5
	gcc-6-5-0:1.1.1.5
	pgoyette-compat-1020:1.1.1.4
	pgoyette-compat-0930:1.1.1.4
	pgoyette-compat-0906:1.1.1.4
	netbsd-7-2-RELEASE:1.1.1.2
	pgoyette-compat-0728:1.1.1.4
	netbsd-8-0-RELEASE:1.1.1.3
	phil-wifi:1.1.1.4.0.4
	phil-wifi-base:1.1.1.4
	pgoyette-compat-0625:1.1.1.4
	netbsd-8-0-RC2:1.1.1.3
	pgoyette-compat-0521:1.1.1.4
	pgoyette-compat-0502:1.1.1.4
	pgoyette-compat-0422:1.1.1.4
	netbsd-8-0-RC1:1.1.1.3
	pgoyette-compat-0415:1.1.1.4
	pgoyette-compat-0407:1.1.1.4
	pgoyette-compat-0330:1.1.1.4
	pgoyette-compat-0322:1.1.1.4
	pgoyette-compat-0315:1.1.1.4
	netbsd-7-1-2-RELEASE:1.1.1.2
	pgoyette-compat:1.1.1.4.0.2
	pgoyette-compat-base:1.1.1.4
	gcc-6-4-0:1.1.1.4
	netbsd-7-1-1-RELEASE:1.1.1.2
	gcc-5-5-0:1.1.1.3
	matt-nb8-mediatek:1.1.1.3.0.12
	matt-nb8-mediatek-base:1.1.1.3
	perseant-stdc-iso10646:1.1.1.3.0.10
	perseant-stdc-iso10646-base:1.1.1.3
	netbsd-8:1.1.1.3.0.8
	netbsd-8-base:1.1.1.3
	prg-localcount2-base3:1.1.1.3
	prg-localcount2-base2:1.1.1.3
	prg-localcount2-base1:1.1.1.3
	prg-localcount2:1.1.1.3.0.6
	prg-localcount2-base:1.1.1.3
	pgoyette-localcount-20170426:1.1.1.3
	bouyer-socketcan-base1:1.1.1.3
	pgoyette-localcount-20170320:1.1.1.3
	netbsd-7-1:1.1.1.2.0.10
	netbsd-7-1-RELEASE:1.1.1.2
	netbsd-7-1-RC2:1.1.1.2
	netbsd-7-nhusb-base-20170116:1.1.1.2
	bouyer-socketcan:1.1.1.3.0.4
	bouyer-socketcan-base:1.1.1.3
	pgoyette-localcount-20170107:1.1.1.3
	netbsd-7-1-RC1:1.1.1.2
	pgoyette-localcount-20161104:1.1.1.3
	netbsd-7-0-2-RELEASE:1.1.1.2
	localcount-20160914:1.1.1.3
	netbsd-7-nhusb:1.1.1.2.0.8
	netbsd-7-nhusb-base:1.1.1.2
	pgoyette-localcount-20160806:1.1.1.3
	pgoyette-localcount-20160726:1.1.1.3
	pgoyette-localcount:1.1.1.3.0.2
	pgoyette-localcount-base:1.1.1.3
	gcc-5-4-0:1.1.1.3
	netbsd-7-0-1-RELEASE:1.1.1.2
	gcc-5-3-0:1.1.1.3
	netbsd-7-0:1.1.1.2.0.6
	netbsd-7-0-RELEASE:1.1.1.2
	gcc-4-8-5-pre-gcc-old-import:1.1.1.2
	netbsd-7-0-RC3:1.1.1.2
	netbsd-7-0-RC2:1.1.1.2
	post-gcc-4-8-5-merge:1.1.1.2
	gcc-4-8-5:1.1.1.2
	netbsd-7-0-RC1:1.1.1.2
	gcc-4-8-4:1.1.1.2
	gcc-4-8-20141009:1.1.1.2
	netbsd-6-0-6-RELEASE:1.1.1.1
	netbsd-6-1-5-RELEASE:1.1.1.1
	netbsd-7:1.1.1.2.0.4
	netbsd-7-base:1.1.1.2
	gcc-4-8-3:1.1.1.2
	yamt-pagecache-base9:1.1.1.2
	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.1.1.2.0.2
	tls-earlyentropy-base:1.1.1.2
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.1.1.2
	riastradh-drm2-base3:1.1.1.2
	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.1.1.1
	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.1.1.1
	riastradh-drm2-base1:1.1.1.1
	riastradh-drm2:1.1.1.1.0.12
	riastradh-drm2-base:1.1.1.1
	netbsd-6-1:1.1.1.1.0.16
	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.1.1.1.0.14
	agc-symver-base:1.1.1.1
	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.1.1.2
	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.1
date	2011.06.21.01.24.41;	author mrg;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2011.06.21.01.24.41;	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.34;	author mrg;	state Exp;
branches;
next	1.1.1.3;
commitid	TtaB91QNTknAoYqx;

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

1.1.1.4
date	2018.02.02.01.59.03;	author mrg;	state Exp;
branches
	1.1.1.4.2.1
	1.1.1.4.4.1;
next	1.1.1.5;
commitid	XNKaycqpfhzd5epA;

1.1.1.5
date	2018.11.04.00.12.28;	author mrg;	state Exp;
branches;
next	1.1.1.6;
commitid	bulspy67pMB6EyYA;

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.10;	author mrg;	state Exp;
branches;
next	1.1.1.11;
commitid	ZRYA7IOuwfMjAPmC;

1.1.1.11
date	2021.04.10.22.10.03;	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
	1.1.1.13.2.1;
next	1.1.1.14;
commitid	tk6nV4mbc9nVEMyE;

1.1.1.14
date	2025.07.21.02.43.40;	author mrg;	state Exp;
branches;
next	1.1.1.15;
commitid	9k1gPU4fqf8VHy3G;

1.1.1.15
date	2025.09.13.23.45.47;	author mrg;	state Exp;
branches;
next	1.1.1.16;
commitid	KwhwN4krNWa6XBaG;

1.1.1.16
date	2026.09.26.20.28.18;	author mrg;	state Exp;
branches;
next	;
commitid	Us2gtpl1zAY1IaXG;

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

1.1.1.1.8.1
date	2014.08.19.23.54.49;	author tls;	state Exp;
branches;
next	;
commitid	jTnpym9Qu0o4R1Nx;

1.1.1.4.2.1
date	2018.11.26.01.50.58;	author pgoyette;	state Exp;
branches;
next	1.1.1.4.2.2;
commitid	Zj4q5SspGdKXto1B;

1.1.1.4.2.2
date	2019.01.26.21.59.33;	author pgoyette;	state Exp;
branches;
next	;
commitid	JKpcmvSjdT25dl9B;

1.1.1.4.4.1
date	2019.06.10.21.54.50;	author christos;	state Exp;
branches;
next	1.1.1.4.4.2;
commitid	jtc8rnCzWiEEHGqB;

1.1.1.4.4.2
date	2020.04.13.07.58.36;	author martin;	state Exp;
branches;
next	;
commitid	X01YhRUPVUDaec4C;

1.1.1.13.2.1
date	2025.08.02.05.25.53;	author perseant;	state Exp;
branches;
next	;
commitid	23j6GFaDws3O875G;


desc
@@


1.1
log
@Initial revision
@
text
@// Vector implementation (out of line) -*- C++ -*-

// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
// 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) 1994
 * Hewlett-Packard Company
 *
 * 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.  Hewlett-Packard Company makes no
 * representations about the suitability of this software for any
 * purpose.  It is provided "as is" without express or implied warranty.
 *
 *
 * Copyright (c) 1996
 * 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 vector.tcc
 *  This is an internal header file, included by other library headers.
 *  You should not attempt to use it directly.
 */

#ifndef _VECTOR_TCC
#define _VECTOR_TCC 1

_GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)

  template<typename _Tp, typename _Alloc>
    void
    vector<_Tp, _Alloc>::
    reserve(size_type __n)
    {
      if (__n > this->max_size())
	__throw_length_error(__N("vector::reserve"));
      if (this->capacity() < __n)
	{
	  const size_type __old_size = size();
	  pointer __tmp = _M_allocate_and_copy(__n,
		 _GLIBCXX_MAKE_MOVE_ITERATOR(this->_M_impl._M_start),
		 _GLIBCXX_MAKE_MOVE_ITERATOR(this->_M_impl._M_finish));
	  std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
			_M_get_Tp_allocator());
	  _M_deallocate(this->_M_impl._M_start,
			this->_M_impl._M_end_of_storage
			- this->_M_impl._M_start);
	  this->_M_impl._M_start = __tmp;
	  this->_M_impl._M_finish = __tmp + __old_size;
	  this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
	}
    }

#ifdef __GXX_EXPERIMENTAL_CXX0X__
  template<typename _Tp, typename _Alloc>
    template<typename... _Args>
      void
      vector<_Tp, _Alloc>::
      emplace_back(_Args&&... __args)
      {
	if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
	  {
	    this->_M_impl.construct(this->_M_impl._M_finish,
				    std::forward<_Args>(__args)...);
	    ++this->_M_impl._M_finish;
	  }
	else
	  _M_insert_aux(end(), std::forward<_Args>(__args)...);
      }
#endif

  template<typename _Tp, typename _Alloc>
    typename vector<_Tp, _Alloc>::iterator
    vector<_Tp, _Alloc>::
    insert(iterator __position, const value_type& __x)
    {
      const size_type __n = __position - begin();
      if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage
	  && __position == end())
	{
	  this->_M_impl.construct(this->_M_impl._M_finish, __x);
	  ++this->_M_impl._M_finish;
	}
      else
	{
#ifdef __GXX_EXPERIMENTAL_CXX0X__
	  if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
	    {
	      _Tp __x_copy = __x;
	      _M_insert_aux(__position, std::move(__x_copy));
	    }
	  else
#endif
	    _M_insert_aux(__position, __x);
	}
      return iterator(this->_M_impl._M_start + __n);
    }

  template<typename _Tp, typename _Alloc>
    typename vector<_Tp, _Alloc>::iterator
    vector<_Tp, _Alloc>::
    erase(iterator __position)
    {
      if (__position + 1 != end())
	_GLIBCXX_MOVE3(__position + 1, end(), __position);
      --this->_M_impl._M_finish;
      this->_M_impl.destroy(this->_M_impl._M_finish);
      return __position;
    }

  template<typename _Tp, typename _Alloc>
    typename vector<_Tp, _Alloc>::iterator
    vector<_Tp, _Alloc>::
    erase(iterator __first, iterator __last)
    {
      if (__last != end())
	_GLIBCXX_MOVE3(__last, end(), __first);
      _M_erase_at_end(__first.base() + (end() - __last));
      return __first;
    }

  template<typename _Tp, typename _Alloc>
    vector<_Tp, _Alloc>&
    vector<_Tp, _Alloc>::
    operator=(const vector<_Tp, _Alloc>& __x)
    {
      if (&__x != this)
	{
	  const size_type __xlen = __x.size();
	  if (__xlen > capacity())
	    {
	      pointer __tmp = _M_allocate_and_copy(__xlen, __x.begin(),
						   __x.end());
	      std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
			    _M_get_Tp_allocator());
	      _M_deallocate(this->_M_impl._M_start,
			    this->_M_impl._M_end_of_storage
			    - this->_M_impl._M_start);
	      this->_M_impl._M_start = __tmp;
	      this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __xlen;
	    }
	  else if (size() >= __xlen)
	    {
	      std::_Destroy(std::copy(__x.begin(), __x.end(), begin()),
			    end(), _M_get_Tp_allocator());
	    }
	  else
	    {
	      std::copy(__x._M_impl._M_start, __x._M_impl._M_start + size(),
			this->_M_impl._M_start);
	      std::__uninitialized_copy_a(__x._M_impl._M_start + size(),
					  __x._M_impl._M_finish,
					  this->_M_impl._M_finish,
					  _M_get_Tp_allocator());
	    }
	  this->_M_impl._M_finish = this->_M_impl._M_start + __xlen;
	}
      return *this;
    }

  template<typename _Tp, typename _Alloc>
    void
    vector<_Tp, _Alloc>::
    _M_fill_assign(size_t __n, const value_type& __val)
    {
      if (__n > capacity())
	{
	  vector __tmp(__n, __val, _M_get_Tp_allocator());
	  __tmp.swap(*this);
	}
      else if (__n > size())
	{
	  std::fill(begin(), end(), __val);
	  std::__uninitialized_fill_n_a(this->_M_impl._M_finish,
					__n - size(), __val,
					_M_get_Tp_allocator());
	  this->_M_impl._M_finish += __n - size();
	}
      else
        _M_erase_at_end(std::fill_n(this->_M_impl._M_start, __n, __val));
    }

  template<typename _Tp, typename _Alloc>
    template<typename _InputIterator>
      void
      vector<_Tp, _Alloc>::
      _M_assign_aux(_InputIterator __first, _InputIterator __last,
		    std::input_iterator_tag)
      {
	pointer __cur(this->_M_impl._M_start);
	for (; __first != __last && __cur != this->_M_impl._M_finish;
	     ++__cur, ++__first)
	  *__cur = *__first;
	if (__first == __last)
	  _M_erase_at_end(__cur);
	else
	  insert(end(), __first, __last);
      }

  template<typename _Tp, typename _Alloc>
    template<typename _ForwardIterator>
      void
      vector<_Tp, _Alloc>::
      _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
		    std::forward_iterator_tag)
      {
	const size_type __len = std::distance(__first, __last);

	if (__len > capacity())
	  {
	    pointer __tmp(_M_allocate_and_copy(__len, __first, __last));
	    std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
			  _M_get_Tp_allocator());
	    _M_deallocate(this->_M_impl._M_start,
			  this->_M_impl._M_end_of_storage
			  - this->_M_impl._M_start);
	    this->_M_impl._M_start = __tmp;
	    this->_M_impl._M_finish = this->_M_impl._M_start + __len;
	    this->_M_impl._M_end_of_storage = this->_M_impl._M_finish;
	  }
	else if (size() >= __len)
	  _M_erase_at_end(std::copy(__first, __last, this->_M_impl._M_start));
	else
	  {
	    _ForwardIterator __mid = __first;
	    std::advance(__mid, size());
	    std::copy(__first, __mid, this->_M_impl._M_start);
	    this->_M_impl._M_finish =
	      std::__uninitialized_copy_a(__mid, __last,
					  this->_M_impl._M_finish,
					  _M_get_Tp_allocator());
	  }
      }

#ifdef __GXX_EXPERIMENTAL_CXX0X__
  template<typename _Tp, typename _Alloc>
    template<typename... _Args>
      typename vector<_Tp, _Alloc>::iterator
      vector<_Tp, _Alloc>::
      emplace(iterator __position, _Args&&... __args)
      {
	const size_type __n = __position - begin();
	if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage
	    && __position == end())
	  {
	    this->_M_impl.construct(this->_M_impl._M_finish,
				    std::forward<_Args>(__args)...);
	    ++this->_M_impl._M_finish;
	  }
	else
	  _M_insert_aux(__position, std::forward<_Args>(__args)...);
	return iterator(this->_M_impl._M_start + __n);
      }

  template<typename _Tp, typename _Alloc>
    template<typename... _Args>
      void
      vector<_Tp, _Alloc>::
      _M_insert_aux(iterator __position, _Args&&... __args)
#else
  template<typename _Tp, typename _Alloc>
    void
    vector<_Tp, _Alloc>::
    _M_insert_aux(iterator __position, const _Tp& __x)
#endif
    {
      if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
	{
	  this->_M_impl.construct(this->_M_impl._M_finish,
				  _GLIBCXX_MOVE(*(this->_M_impl._M_finish
						  - 1)));
	  ++this->_M_impl._M_finish;
#ifndef __GXX_EXPERIMENTAL_CXX0X__
	  _Tp __x_copy = __x;
#endif
	  _GLIBCXX_MOVE_BACKWARD3(__position.base(),
				  this->_M_impl._M_finish - 2,
				  this->_M_impl._M_finish - 1);
#ifndef __GXX_EXPERIMENTAL_CXX0X__
	  *__position = __x_copy;
#else
	  *__position = _Tp(std::forward<_Args>(__args)...);
#endif
	}
      else
	{
	  const size_type __len =
	    _M_check_len(size_type(1), "vector::_M_insert_aux");
	  const size_type __elems_before = __position - begin();
	  pointer __new_start(this->_M_allocate(__len));
	  pointer __new_finish(__new_start);
	  __try
	    {
	      // The order of the three operations is dictated by the C++0x
	      // case, where the moves could alter a new element belonging
	      // to the existing vector.  This is an issue only for callers
	      // taking the element by const lvalue ref (see 23.1/13).
	      this->_M_impl.construct(__new_start + __elems_before,
#ifdef __GXX_EXPERIMENTAL_CXX0X__
				      std::forward<_Args>(__args)...);
#else
	                              __x);
#endif
	      __new_finish = 0;

	      __new_finish =
		std::__uninitialized_move_a(this->_M_impl._M_start,
					    __position.base(), __new_start,
					    _M_get_Tp_allocator());
	      ++__new_finish;

	      __new_finish =
		std::__uninitialized_move_a(__position.base(),
					    this->_M_impl._M_finish,
					    __new_finish,
					    _M_get_Tp_allocator());
	    }
          __catch(...)
	    {
	      if (!__new_finish)
		this->_M_impl.destroy(__new_start + __elems_before);
	      else
		std::_Destroy(__new_start, __new_finish, _M_get_Tp_allocator());
	      _M_deallocate(__new_start, __len);
	      __throw_exception_again;
	    }
	  std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
			_M_get_Tp_allocator());
	  _M_deallocate(this->_M_impl._M_start,
			this->_M_impl._M_end_of_storage
			- this->_M_impl._M_start);
	  this->_M_impl._M_start = __new_start;
	  this->_M_impl._M_finish = __new_finish;
	  this->_M_impl._M_end_of_storage = __new_start + __len;
	}
    }

  template<typename _Tp, typename _Alloc>
    void
    vector<_Tp, _Alloc>::
    _M_fill_insert(iterator __position, size_type __n, const value_type& __x)
    {
      if (__n != 0)
	{
	  if (size_type(this->_M_impl._M_end_of_storage
			- this->_M_impl._M_finish) >= __n)
	    {
	      value_type __x_copy = __x;
	      const size_type __elems_after = end() - __position;
	      pointer __old_finish(this->_M_impl._M_finish);
	      if (__elems_after > __n)
		{
		  std::__uninitialized_move_a(this->_M_impl._M_finish - __n,
					      this->_M_impl._M_finish,
					      this->_M_impl._M_finish,
					      _M_get_Tp_allocator());
		  this->_M_impl._M_finish += __n;
		  _GLIBCXX_MOVE_BACKWARD3(__position.base(),
					  __old_finish - __n, __old_finish);
		  std::fill(__position.base(), __position.base() + __n,
			    __x_copy);
		}
	      else
		{
		  std::__uninitialized_fill_n_a(this->_M_impl._M_finish,
						__n - __elems_after,
						__x_copy,
						_M_get_Tp_allocator());
		  this->_M_impl._M_finish += __n - __elems_after;
		  std::__uninitialized_move_a(__position.base(), __old_finish,
					      this->_M_impl._M_finish,
					      _M_get_Tp_allocator());
		  this->_M_impl._M_finish += __elems_after;
		  std::fill(__position.base(), __old_finish, __x_copy);
		}
	    }
	  else
	    {
	      const size_type __len =
		_M_check_len(__n, "vector::_M_fill_insert");
	      const size_type __elems_before = __position - begin();
	      pointer __new_start(this->_M_allocate(__len));
	      pointer __new_finish(__new_start);
	      __try
		{
		  // See _M_insert_aux above.
		  std::__uninitialized_fill_n_a(__new_start + __elems_before,
						__n, __x,
						_M_get_Tp_allocator());
		  __new_finish = 0;

		  __new_finish =
		    std::__uninitialized_move_a(this->_M_impl._M_start,
						__position.base(),
						__new_start,
						_M_get_Tp_allocator());
		  __new_finish += __n;

		  __new_finish =
		    std::__uninitialized_move_a(__position.base(),
						this->_M_impl._M_finish,
						__new_finish,
						_M_get_Tp_allocator());
		}
	      __catch(...)
		{
		  if (!__new_finish)
		    std::_Destroy(__new_start + __elems_before,
				  __new_start + __elems_before + __n,
				  _M_get_Tp_allocator());
		  else
		    std::_Destroy(__new_start, __new_finish,
				  _M_get_Tp_allocator());
		  _M_deallocate(__new_start, __len);
		  __throw_exception_again;
		}
	      std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
			    _M_get_Tp_allocator());
	      _M_deallocate(this->_M_impl._M_start,
			    this->_M_impl._M_end_of_storage
			    - this->_M_impl._M_start);
	      this->_M_impl._M_start = __new_start;
	      this->_M_impl._M_finish = __new_finish;
	      this->_M_impl._M_end_of_storage = __new_start + __len;
	    }
	}
    }

  template<typename _Tp, typename _Alloc>
    template<typename _InputIterator>
      void
      vector<_Tp, _Alloc>::
      _M_range_insert(iterator __pos, _InputIterator __first,
		      _InputIterator __last, std::input_iterator_tag)
      {
	for (; __first != __last; ++__first)
	  {
	    __pos = insert(__pos, *__first);
	    ++__pos;
	  }
      }

  template<typename _Tp, typename _Alloc>
    template<typename _ForwardIterator>
      void
      vector<_Tp, _Alloc>::
      _M_range_insert(iterator __position, _ForwardIterator __first,
		      _ForwardIterator __last, std::forward_iterator_tag)
      {
	if (__first != __last)
	  {
	    const size_type __n = std::distance(__first, __last);
	    if (size_type(this->_M_impl._M_end_of_storage
			  - this->_M_impl._M_finish) >= __n)
	      {
		const size_type __elems_after = end() - __position;
		pointer __old_finish(this->_M_impl._M_finish);
		if (__elems_after > __n)
		  {
		    std::__uninitialized_move_a(this->_M_impl._M_finish - __n,
						this->_M_impl._M_finish,
						this->_M_impl._M_finish,
						_M_get_Tp_allocator());
		    this->_M_impl._M_finish += __n;
		    _GLIBCXX_MOVE_BACKWARD3(__position.base(),
					    __old_finish - __n, __old_finish);
		    std::copy(__first, __last, __position);
		  }
		else
		  {
		    _ForwardIterator __mid = __first;
		    std::advance(__mid, __elems_after);
		    std::__uninitialized_copy_a(__mid, __last,
						this->_M_impl._M_finish,
						_M_get_Tp_allocator());
		    this->_M_impl._M_finish += __n - __elems_after;
		    std::__uninitialized_move_a(__position.base(),
						__old_finish,
						this->_M_impl._M_finish,
						_M_get_Tp_allocator());
		    this->_M_impl._M_finish += __elems_after;
		    std::copy(__first, __mid, __position);
		  }
	      }
	    else
	      {
		const size_type __len =
		  _M_check_len(__n, "vector::_M_range_insert");
		pointer __new_start(this->_M_allocate(__len));
		pointer __new_finish(__new_start);
		__try
		  {
		    __new_finish =
		      std::__uninitialized_move_a(this->_M_impl._M_start,
						  __position.base(),
						  __new_start,
						  _M_get_Tp_allocator());
		    __new_finish =
		      std::__uninitialized_copy_a(__first, __last,
						  __new_finish,
						  _M_get_Tp_allocator());
		    __new_finish =
		      std::__uninitialized_move_a(__position.base(),
						  this->_M_impl._M_finish,
						  __new_finish,
						  _M_get_Tp_allocator());
		  }
		__catch(...)
		  {
		    std::_Destroy(__new_start, __new_finish,
				  _M_get_Tp_allocator());
		    _M_deallocate(__new_start, __len);
		    __throw_exception_again;
		  }
		std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
			      _M_get_Tp_allocator());
		_M_deallocate(this->_M_impl._M_start,
			      this->_M_impl._M_end_of_storage
			      - this->_M_impl._M_start);
		this->_M_impl._M_start = __new_start;
		this->_M_impl._M_finish = __new_finish;
		this->_M_impl._M_end_of_storage = __new_start + __len;
	      }
	  }
      }


  // vector<bool>

  template<typename _Alloc>
    void
    vector<bool, _Alloc>::
    reserve(size_type __n)
    {
      if (__n > this->max_size())
	__throw_length_error(__N("vector::reserve"));
      if (this->capacity() < __n)
	{
	  _Bit_type* __q = this->_M_allocate(__n);
	  this->_M_impl._M_finish = _M_copy_aligned(begin(), end(),
						    iterator(__q, 0));
	  this->_M_deallocate();
	  this->_M_impl._M_start = iterator(__q, 0);
	  this->_M_impl._M_end_of_storage = (__q + (__n + int(_S_word_bit) - 1)
					     / int(_S_word_bit));
	}
    }

  template<typename _Alloc>
    void
    vector<bool, _Alloc>::
    _M_fill_insert(iterator __position, size_type __n, bool __x)
    {
      if (__n == 0)
	return;
      if (capacity() - size() >= __n)
	{
	  std::copy_backward(__position, end(),
			     this->_M_impl._M_finish + difference_type(__n));
	  std::fill(__position, __position + difference_type(__n), __x);
	  this->_M_impl._M_finish += difference_type(__n);
	}
      else
	{
	  const size_type __len = 
	    _M_check_len(__n, "vector<bool>::_M_fill_insert");
	  _Bit_type * __q = this->_M_allocate(__len);
	  iterator __i = _M_copy_aligned(begin(), __position,
					 iterator(__q, 0));
	  std::fill(__i, __i + difference_type(__n), __x);
	  this->_M_impl._M_finish = std::copy(__position, end(),
					      __i + difference_type(__n));
	  this->_M_deallocate();
	  this->_M_impl._M_end_of_storage = (__q + ((__len
						     + int(_S_word_bit) - 1)
						    / int(_S_word_bit)));
	  this->_M_impl._M_start = iterator(__q, 0);
	}
    }

  template<typename _Alloc>
    template<typename _ForwardIterator>
      void
      vector<bool, _Alloc>::
      _M_insert_range(iterator __position, _ForwardIterator __first, 
		      _ForwardIterator __last, std::forward_iterator_tag)
      {
	if (__first != __last)
	  {
	    size_type __n = std::distance(__first, __last);
	    if (capacity() - size() >= __n)
	      {
		std::copy_backward(__position, end(),
				   this->_M_impl._M_finish
				   + difference_type(__n));
		std::copy(__first, __last, __position);
		this->_M_impl._M_finish += difference_type(__n);
	      }
	    else
	      {
		const size_type __len =
		  _M_check_len(__n, "vector<bool>::_M_insert_range");
		_Bit_type * __q = this->_M_allocate(__len);
		iterator __i = _M_copy_aligned(begin(), __position,
					       iterator(__q, 0));
		__i = std::copy(__first, __last, __i);
		this->_M_impl._M_finish = std::copy(__position, end(), __i);
		this->_M_deallocate();
		this->_M_impl._M_end_of_storage = (__q
						   + ((__len
						       + int(_S_word_bit) - 1)
						      / int(_S_word_bit)));
		this->_M_impl._M_start = iterator(__q, 0);
	      }
	  }
      }

  template<typename _Alloc>
    void
    vector<bool, _Alloc>::
    _M_insert_aux(iterator __position, bool __x)
    {
      if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_of_storage)
	{
	  std::copy_backward(__position, this->_M_impl._M_finish, 
			     this->_M_impl._M_finish + 1);
	  *__position = __x;
	  ++this->_M_impl._M_finish;
	}
      else
	{
	  const size_type __len =
	    _M_check_len(size_type(1), "vector<bool>::_M_insert_aux");
	  _Bit_type * __q = this->_M_allocate(__len);
	  iterator __i = _M_copy_aligned(begin(), __position,
					 iterator(__q, 0));
	  *__i++ = __x;
	  this->_M_impl._M_finish = std::copy(__position, end(), __i);
	  this->_M_deallocate();
	  this->_M_impl._M_end_of_storage = (__q + ((__len
						     + int(_S_word_bit) - 1)
						    / int(_S_word_bit)));
	  this->_M_impl._M_start = iterator(__q, 0);
	}
    }

_GLIBCXX_END_NESTED_NAMESPACE

#ifdef __GXX_EXPERIMENTAL_CXX0X__

_GLIBCXX_BEGIN_NAMESPACE(std)

  template<typename _Alloc>
    size_t
    hash<_GLIBCXX_STD_D::vector<bool, _Alloc>>::
    operator()(const _GLIBCXX_STD_D::vector<bool, _Alloc>& __b) const
    {
      size_t __hash = 0;
      using _GLIBCXX_STD_D::_S_word_bit;
      using _GLIBCXX_STD_D::_Bit_type;

      const size_t __words = __b.size() / _S_word_bit;
      if (__words)
	{
	  const size_t __clength = __words * sizeof(_Bit_type);
	  __hash = std::_Fnv_hash::hash(__b._M_impl._M_start._M_p, __clength);
	}

      const size_t __extrabits = __b.size() % _S_word_bit;
      if (__extrabits)
	{
	  _Bit_type __hiword = *__b._M_impl._M_finish._M_p;
	  __hiword &= ~((~static_cast<_Bit_type>(0)) << __extrabits);

	  const size_t __clength
	    = (__extrabits + __CHAR_BIT__ - 1) / __CHAR_BIT__;
	  if (__words)
	    __hash = std::_Fnv_hash::hash(&__hiword, __clength, __hash);
	  else
	    __hash = std::_Fnv_hash::hash(&__hiword, __clength);
	}

      return __hash;
    }

_GLIBCXX_END_NAMESPACE

#endif // __GXX_EXPERIMENTAL_CXX0X__

#endif /* _VECTOR_TCC */
@


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.8.1
log
@Rebase to HEAD as of a few days ago.
@
text
@d3 2
a4 1
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
d52 1
a52 1
/** @@file bits/vector.tcc
d54 1
a54 1
 *  Do not attempt to use it directly. @@headername{vector}
d60 1
a60 3
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
d73 2
a74 2
	    _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(this->_M_impl._M_start),
	    _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(this->_M_impl._M_finish));
d86 1
a86 1
#if __cplusplus >= 201103L
d95 2
a96 2
	    _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
				     std::forward<_Args>(__args)...);
d100 1
a100 1
	  _M_emplace_back_aux(std::forward<_Args>(__args)...);
d113 1
a113 1
	  _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, __x);
d118 1
a118 1
#if __cplusplus >= 201103L
d139 1
a139 1
      _Alloc_traits::destroy(this->_M_impl, this->_M_impl._M_finish);
d148 3
a150 6
      if (__first != __last)
	{
	  if (__last != end())
	    _GLIBCXX_MOVE3(__last, end(), __first);
	  _M_erase_at_end(__first.base() + (end() - __last));
	}
a160 19
#if __cplusplus >= 201103L
	  if (_Alloc_traits::_S_propagate_on_copy_assign())
	    {
	      if (!_Alloc_traits::_S_always_equal()
	          && _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
	        {
		  // replacement allocator cannot free existing storage
		  this->clear();
		  _M_deallocate(this->_M_impl._M_start,
				this->_M_impl._M_end_of_storage
				- this->_M_impl._M_start);
		  this->_M_impl._M_start = nullptr;
		  this->_M_impl._M_finish = nullptr;
		  this->_M_impl._M_end_of_storage = nullptr;
		}
	      std::__alloc_on_copy(_M_get_Tp_allocator(),
				   __x._M_get_Tp_allocator());
	    }
#endif
d267 1
a267 1
#if __cplusplus >= 201103L
d278 2
a279 2
	    _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
				     std::forward<_Args>(__args)...);
d301 3
a303 3
	  _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
			           _GLIBCXX_MOVE(*(this->_M_impl._M_finish
				                   - 1)));
d305 1
a305 1
#if __cplusplus < 201103L
d311 1
a311 1
#if __cplusplus < 201103L
d330 3
a332 4
	      _Alloc_traits::construct(this->_M_impl,
		                       __new_start + __elems_before,
#if __cplusplus >= 201103L
				       std::forward<_Args>(__args)...);
d334 1
a334 1
	                               __x);
d338 4
a341 5
	      __new_finish
		= std::__uninitialized_move_if_noexcept_a
		(this->_M_impl._M_start, __position.base(),
		 __new_start, _M_get_Tp_allocator());

d344 5
a348 4
	      __new_finish
		= std::__uninitialized_move_if_noexcept_a
		(__position.base(), this->_M_impl._M_finish,
		 __new_finish, _M_get_Tp_allocator());
d353 1
a353 2
		_Alloc_traits::destroy(this->_M_impl,
		                       __new_start + __elems_before);
a369 44
#if __cplusplus >= 201103L
  template<typename _Tp, typename _Alloc>
    template<typename... _Args>
      void
      vector<_Tp, _Alloc>::
      _M_emplace_back_aux(_Args&&... __args)
      {
	const size_type __len =
	  _M_check_len(size_type(1), "vector::_M_emplace_back_aux");
	pointer __new_start(this->_M_allocate(__len));
	pointer __new_finish(__new_start);
	__try
	  {
	    _Alloc_traits::construct(this->_M_impl, __new_start + size(),
				     std::forward<_Args>(__args)...);
	    __new_finish = 0;

	    __new_finish
	      = std::__uninitialized_move_if_noexcept_a
	      (this->_M_impl._M_start, this->_M_impl._M_finish,
	       __new_start, _M_get_Tp_allocator());

	    ++__new_finish;
	  }
	__catch(...)
	  {
	    if (!__new_finish)
	      _Alloc_traits::destroy(this->_M_impl, __new_start + size());
	    else
	      std::_Destroy(__new_start, __new_finish, _M_get_Tp_allocator());
	    _M_deallocate(__new_start, __len);
	    __throw_exception_again;
	  }
	std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
		      _M_get_Tp_allocator());
	_M_deallocate(this->_M_impl._M_start,
		      this->_M_impl._M_end_of_storage
		      - this->_M_impl._M_start);
	this->_M_impl._M_start = __new_start;
	this->_M_impl._M_finish = __new_finish;
	this->_M_impl._M_end_of_storage = __new_start + __len;
      }
#endif

d424 5
a428 5
		  __new_finish
		    = std::__uninitialized_move_if_noexcept_a
		    (this->_M_impl._M_start, __position.base(),
		     __new_start, _M_get_Tp_allocator());

d431 5
a435 4
		  __new_finish
		    = std::__uninitialized_move_if_noexcept_a
		    (__position.base(), this->_M_impl._M_finish,
		     __new_finish, _M_get_Tp_allocator());
a460 62
#if __cplusplus >= 201103L
  template<typename _Tp, typename _Alloc>
    void
    vector<_Tp, _Alloc>::
    _M_default_append(size_type __n)
    {
      if (__n != 0)
	{
	  if (size_type(this->_M_impl._M_end_of_storage
			- this->_M_impl._M_finish) >= __n)
	    {
	      std::__uninitialized_default_n_a(this->_M_impl._M_finish,
					       __n, _M_get_Tp_allocator());
	      this->_M_impl._M_finish += __n;
	    }
	  else
	    {
	      const size_type __len =
		_M_check_len(__n, "vector::_M_default_append");
	      const size_type __old_size = this->size();
	      pointer __new_start(this->_M_allocate(__len));
	      pointer __new_finish(__new_start);
	      __try
		{
		  __new_finish
		    = std::__uninitialized_move_if_noexcept_a
		    (this->_M_impl._M_start, this->_M_impl._M_finish,
		     __new_start, _M_get_Tp_allocator());
		  std::__uninitialized_default_n_a(__new_finish, __n,
						   _M_get_Tp_allocator());
		  __new_finish += __n;
		}
	      __catch(...)
		{
		  std::_Destroy(__new_start, __new_finish,
				_M_get_Tp_allocator());
		  _M_deallocate(__new_start, __len);
		  __throw_exception_again;
		}
	      std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
			    _M_get_Tp_allocator());
	      _M_deallocate(this->_M_impl._M_start,
			    this->_M_impl._M_end_of_storage
			    - this->_M_impl._M_start);
	      this->_M_impl._M_start = __new_start;
	      this->_M_impl._M_finish = __new_finish;
	      this->_M_impl._M_end_of_storage = __new_start + __len;
	    }
	}
    }

  template<typename _Tp, typename _Alloc>
    bool
    vector<_Tp, _Alloc>::
    _M_shrink_to_fit()
    {
      if (capacity() == size())
	return false;
      return std::__shrink_to_fit_aux<vector>::_S_do_it(*this);
    }
#endif

d525 14
a538 12
		    __new_finish
		      = std::__uninitialized_move_if_noexcept_a
		      (this->_M_impl._M_start, __position.base(),
		       __new_start, _M_get_Tp_allocator());
		    __new_finish
		      = std::__uninitialized_copy_a(__first, __last,
						    __new_finish,
						    _M_get_Tp_allocator());
		    __new_finish
		      = std::__uninitialized_move_if_noexcept_a
		      (__position.base(), this->_M_impl._M_finish,
		       __new_finish, _M_get_Tp_allocator());
d561 1
d565 1
a565 1
    _M_reallocate(size_type __n)
d567 12
a578 6
      _Bit_type* __q = this->_M_allocate(__n);
      this->_M_impl._M_finish = _M_copy_aligned(begin(), end(),
						iterator(__q, 0));
      this->_M_deallocate();
      this->_M_impl._M_start = iterator(__q, 0);
      this->_M_impl._M_end_of_storage = __q + _S_nword(__n);
d606 3
a608 1
	  this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
d641 4
a644 1
		this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
d672 3
a674 1
	  this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
d679 1
a679 20
#if __cplusplus >= 201103L
  template<typename _Alloc>
    bool
    vector<bool, _Alloc>::
    _M_shrink_to_fit()
    {
      if (capacity() - size() < int(_S_word_bit))
	return false;
      __try
	{
	  _M_reallocate(size());
	  return true;
	}
      __catch(...)
	{ return false; }
    }
#endif

_GLIBCXX_END_NAMESPACE_CONTAINER
} // namespace std
d681 1
a681 1
#if __cplusplus >= 201103L
d683 1
a683 3
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
d687 2
a688 2
    hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>::
    operator()(const _GLIBCXX_STD_C::vector<bool, _Alloc>& __b) const noexcept
d691 2
a692 2
      using _GLIBCXX_STD_C::_S_word_bit;
      using _GLIBCXX_STD_C::_Bit_type;
d698 1
a698 1
	  __hash = std::_Hash_impl::hash(__b._M_impl._M_start._M_p, __clength);
d710 1
a710 1
	    __hash = std::_Hash_impl::hash(&__hiword, __clength, __hash);
d712 1
a712 1
	    __hash = std::_Hash_impl::hash(&__hiword, __clength);
d718 1
a718 2
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
d720 1
a720 1
#endif // C++11
@


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.
d52 1
a52 1
/** @@file bits/vector.tcc
d54 1
a54 1
 *  Do not attempt to use it directly. @@headername{vector}
d60 1
a60 3
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
d73 2
a74 2
	    _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(this->_M_impl._M_start),
	    _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(this->_M_impl._M_finish));
d86 1
a86 1
#if __cplusplus >= 201103L
d95 2
a96 2
	    _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
				     std::forward<_Args>(__args)...);
d100 1
a100 1
	  _M_emplace_back_aux(std::forward<_Args>(__args)...);
d113 1
a113 1
	  _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, __x);
d118 1
a118 1
#if __cplusplus >= 201103L
d139 1
a139 1
      _Alloc_traits::destroy(this->_M_impl, this->_M_impl._M_finish);
d148 3
a150 6
      if (__first != __last)
	{
	  if (__last != end())
	    _GLIBCXX_MOVE3(__last, end(), __first);
	  _M_erase_at_end(__first.base() + (end() - __last));
	}
a160 19
#if __cplusplus >= 201103L
	  if (_Alloc_traits::_S_propagate_on_copy_assign())
	    {
	      if (!_Alloc_traits::_S_always_equal()
	          && _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
	        {
		  // replacement allocator cannot free existing storage
		  this->clear();
		  _M_deallocate(this->_M_impl._M_start,
				this->_M_impl._M_end_of_storage
				- this->_M_impl._M_start);
		  this->_M_impl._M_start = nullptr;
		  this->_M_impl._M_finish = nullptr;
		  this->_M_impl._M_end_of_storage = nullptr;
		}
	      std::__alloc_on_copy(_M_get_Tp_allocator(),
				   __x._M_get_Tp_allocator());
	    }
#endif
d267 1
a267 1
#if __cplusplus >= 201103L
d278 2
a279 2
	    _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
				     std::forward<_Args>(__args)...);
d301 3
a303 3
	  _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
			           _GLIBCXX_MOVE(*(this->_M_impl._M_finish
				                   - 1)));
d305 1
a305 1
#if __cplusplus < 201103L
d311 1
a311 1
#if __cplusplus < 201103L
d330 3
a332 4
	      _Alloc_traits::construct(this->_M_impl,
		                       __new_start + __elems_before,
#if __cplusplus >= 201103L
				       std::forward<_Args>(__args)...);
d334 1
a334 1
	                               __x);
d338 4
a341 5
	      __new_finish
		= std::__uninitialized_move_if_noexcept_a
		(this->_M_impl._M_start, __position.base(),
		 __new_start, _M_get_Tp_allocator());

d344 5
a348 4
	      __new_finish
		= std::__uninitialized_move_if_noexcept_a
		(__position.base(), this->_M_impl._M_finish,
		 __new_finish, _M_get_Tp_allocator());
d353 1
a353 2
		_Alloc_traits::destroy(this->_M_impl,
		                       __new_start + __elems_before);
a369 44
#if __cplusplus >= 201103L
  template<typename _Tp, typename _Alloc>
    template<typename... _Args>
      void
      vector<_Tp, _Alloc>::
      _M_emplace_back_aux(_Args&&... __args)
      {
	const size_type __len =
	  _M_check_len(size_type(1), "vector::_M_emplace_back_aux");
	pointer __new_start(this->_M_allocate(__len));
	pointer __new_finish(__new_start);
	__try
	  {
	    _Alloc_traits::construct(this->_M_impl, __new_start + size(),
				     std::forward<_Args>(__args)...);
	    __new_finish = 0;

	    __new_finish
	      = std::__uninitialized_move_if_noexcept_a
	      (this->_M_impl._M_start, this->_M_impl._M_finish,
	       __new_start, _M_get_Tp_allocator());

	    ++__new_finish;
	  }
	__catch(...)
	  {
	    if (!__new_finish)
	      _Alloc_traits::destroy(this->_M_impl, __new_start + size());
	    else
	      std::_Destroy(__new_start, __new_finish, _M_get_Tp_allocator());
	    _M_deallocate(__new_start, __len);
	    __throw_exception_again;
	  }
	std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
		      _M_get_Tp_allocator());
	_M_deallocate(this->_M_impl._M_start,
		      this->_M_impl._M_end_of_storage
		      - this->_M_impl._M_start);
	this->_M_impl._M_start = __new_start;
	this->_M_impl._M_finish = __new_finish;
	this->_M_impl._M_end_of_storage = __new_start + __len;
      }
#endif

d424 5
a428 5
		  __new_finish
		    = std::__uninitialized_move_if_noexcept_a
		    (this->_M_impl._M_start, __position.base(),
		     __new_start, _M_get_Tp_allocator());

d431 5
a435 4
		  __new_finish
		    = std::__uninitialized_move_if_noexcept_a
		    (__position.base(), this->_M_impl._M_finish,
		     __new_finish, _M_get_Tp_allocator());
a460 62
#if __cplusplus >= 201103L
  template<typename _Tp, typename _Alloc>
    void
    vector<_Tp, _Alloc>::
    _M_default_append(size_type __n)
    {
      if (__n != 0)
	{
	  if (size_type(this->_M_impl._M_end_of_storage
			- this->_M_impl._M_finish) >= __n)
	    {
	      std::__uninitialized_default_n_a(this->_M_impl._M_finish,
					       __n, _M_get_Tp_allocator());
	      this->_M_impl._M_finish += __n;
	    }
	  else
	    {
	      const size_type __len =
		_M_check_len(__n, "vector::_M_default_append");
	      const size_type __old_size = this->size();
	      pointer __new_start(this->_M_allocate(__len));
	      pointer __new_finish(__new_start);
	      __try
		{
		  __new_finish
		    = std::__uninitialized_move_if_noexcept_a
		    (this->_M_impl._M_start, this->_M_impl._M_finish,
		     __new_start, _M_get_Tp_allocator());
		  std::__uninitialized_default_n_a(__new_finish, __n,
						   _M_get_Tp_allocator());
		  __new_finish += __n;
		}
	      __catch(...)
		{
		  std::_Destroy(__new_start, __new_finish,
				_M_get_Tp_allocator());
		  _M_deallocate(__new_start, __len);
		  __throw_exception_again;
		}
	      std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
			    _M_get_Tp_allocator());
	      _M_deallocate(this->_M_impl._M_start,
			    this->_M_impl._M_end_of_storage
			    - this->_M_impl._M_start);
	      this->_M_impl._M_start = __new_start;
	      this->_M_impl._M_finish = __new_finish;
	      this->_M_impl._M_end_of_storage = __new_start + __len;
	    }
	}
    }

  template<typename _Tp, typename _Alloc>
    bool
    vector<_Tp, _Alloc>::
    _M_shrink_to_fit()
    {
      if (capacity() == size())
	return false;
      return std::__shrink_to_fit_aux<vector>::_S_do_it(*this);
    }
#endif

d525 14
a538 12
		    __new_finish
		      = std::__uninitialized_move_if_noexcept_a
		      (this->_M_impl._M_start, __position.base(),
		       __new_start, _M_get_Tp_allocator());
		    __new_finish
		      = std::__uninitialized_copy_a(__first, __last,
						    __new_finish,
						    _M_get_Tp_allocator());
		    __new_finish
		      = std::__uninitialized_move_if_noexcept_a
		      (__position.base(), this->_M_impl._M_finish,
		       __new_finish, _M_get_Tp_allocator());
d561 1
d565 1
a565 1
    _M_reallocate(size_type __n)
d567 12
a578 6
      _Bit_type* __q = this->_M_allocate(__n);
      this->_M_impl._M_finish = _M_copy_aligned(begin(), end(),
						iterator(__q, 0));
      this->_M_deallocate();
      this->_M_impl._M_start = iterator(__q, 0);
      this->_M_impl._M_end_of_storage = __q + _S_nword(__n);
d606 3
a608 1
	  this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
d641 4
a644 1
		this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
d672 3
a674 1
	  this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
d679 1
a679 20
#if __cplusplus >= 201103L
  template<typename _Alloc>
    bool
    vector<bool, _Alloc>::
    _M_shrink_to_fit()
    {
      if (capacity() - size() < int(_S_word_bit))
	return false;
      __try
	{
	  _M_reallocate(size());
	  return true;
	}
      __catch(...)
	{ return false; }
    }
#endif

_GLIBCXX_END_NAMESPACE_CONTAINER
} // namespace std
d681 1
a681 1
#if __cplusplus >= 201103L
d683 1
a683 3
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
d687 2
a688 2
    hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>::
    operator()(const _GLIBCXX_STD_C::vector<bool, _Alloc>& __b) const noexcept
d691 2
a692 2
      using _GLIBCXX_STD_C::_S_word_bit;
      using _GLIBCXX_STD_C::_Bit_type;
d698 1
a698 1
	  __hash = std::_Hash_impl::hash(__b._M_impl._M_start._M_p, __clength);
d710 1
a710 1
	    __hash = std::_Hash_impl::hash(&__hiword, __clength, __hash);
d712 1
a712 1
	    __hash = std::_Hash_impl::hash(&__hiword, __clength);
d718 1
a718 2
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
d720 1
a720 1
#endif // C++11
@


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.
d52 1
a52 1
/** @@file bits/vector.tcc
d54 1
a54 1
 *  Do not attempt to use it directly. @@headername{vector}
d60 1
a60 3
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
d73 2
a74 2
	    _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(this->_M_impl._M_start),
	    _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(this->_M_impl._M_finish));
d86 1
a86 1
#if __cplusplus >= 201103L
d95 2
a96 2
	    _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
				     std::forward<_Args>(__args)...);
d100 1
a100 1
	  _M_emplace_back_aux(std::forward<_Args>(__args)...);
d113 1
a113 1
	  _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, __x);
d118 1
a118 1
#if __cplusplus >= 201103L
d139 1
a139 1
      _Alloc_traits::destroy(this->_M_impl, this->_M_impl._M_finish);
d148 3
a150 6
      if (__first != __last)
	{
	  if (__last != end())
	    _GLIBCXX_MOVE3(__last, end(), __first);
	  _M_erase_at_end(__first.base() + (end() - __last));
	}
a160 19
#if __cplusplus >= 201103L
	  if (_Alloc_traits::_S_propagate_on_copy_assign())
	    {
	      if (!_Alloc_traits::_S_always_equal()
	          && _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
	        {
		  // replacement allocator cannot free existing storage
		  this->clear();
		  _M_deallocate(this->_M_impl._M_start,
				this->_M_impl._M_end_of_storage
				- this->_M_impl._M_start);
		  this->_M_impl._M_start = nullptr;
		  this->_M_impl._M_finish = nullptr;
		  this->_M_impl._M_end_of_storage = nullptr;
		}
	      std::__alloc_on_copy(_M_get_Tp_allocator(),
				   __x._M_get_Tp_allocator());
	    }
#endif
d267 1
a267 1
#if __cplusplus >= 201103L
d278 2
a279 2
	    _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
				     std::forward<_Args>(__args)...);
d301 3
a303 3
	  _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
			           _GLIBCXX_MOVE(*(this->_M_impl._M_finish
				                   - 1)));
d305 1
a305 1
#if __cplusplus < 201103L
d311 1
a311 1
#if __cplusplus < 201103L
d330 3
a332 4
	      _Alloc_traits::construct(this->_M_impl,
		                       __new_start + __elems_before,
#if __cplusplus >= 201103L
				       std::forward<_Args>(__args)...);
d334 1
a334 1
	                               __x);
d338 4
a341 5
	      __new_finish
		= std::__uninitialized_move_if_noexcept_a
		(this->_M_impl._M_start, __position.base(),
		 __new_start, _M_get_Tp_allocator());

d344 5
a348 4
	      __new_finish
		= std::__uninitialized_move_if_noexcept_a
		(__position.base(), this->_M_impl._M_finish,
		 __new_finish, _M_get_Tp_allocator());
d353 1
a353 2
		_Alloc_traits::destroy(this->_M_impl,
		                       __new_start + __elems_before);
a369 44
#if __cplusplus >= 201103L
  template<typename _Tp, typename _Alloc>
    template<typename... _Args>
      void
      vector<_Tp, _Alloc>::
      _M_emplace_back_aux(_Args&&... __args)
      {
	const size_type __len =
	  _M_check_len(size_type(1), "vector::_M_emplace_back_aux");
	pointer __new_start(this->_M_allocate(__len));
	pointer __new_finish(__new_start);
	__try
	  {
	    _Alloc_traits::construct(this->_M_impl, __new_start + size(),
				     std::forward<_Args>(__args)...);
	    __new_finish = 0;

	    __new_finish
	      = std::__uninitialized_move_if_noexcept_a
	      (this->_M_impl._M_start, this->_M_impl._M_finish,
	       __new_start, _M_get_Tp_allocator());

	    ++__new_finish;
	  }
	__catch(...)
	  {
	    if (!__new_finish)
	      _Alloc_traits::destroy(this->_M_impl, __new_start + size());
	    else
	      std::_Destroy(__new_start, __new_finish, _M_get_Tp_allocator());
	    _M_deallocate(__new_start, __len);
	    __throw_exception_again;
	  }
	std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
		      _M_get_Tp_allocator());
	_M_deallocate(this->_M_impl._M_start,
		      this->_M_impl._M_end_of_storage
		      - this->_M_impl._M_start);
	this->_M_impl._M_start = __new_start;
	this->_M_impl._M_finish = __new_finish;
	this->_M_impl._M_end_of_storage = __new_start + __len;
      }
#endif

d424 5
a428 5
		  __new_finish
		    = std::__uninitialized_move_if_noexcept_a
		    (this->_M_impl._M_start, __position.base(),
		     __new_start, _M_get_Tp_allocator());

d431 5
a435 4
		  __new_finish
		    = std::__uninitialized_move_if_noexcept_a
		    (__position.base(), this->_M_impl._M_finish,
		     __new_finish, _M_get_Tp_allocator());
a460 62
#if __cplusplus >= 201103L
  template<typename _Tp, typename _Alloc>
    void
    vector<_Tp, _Alloc>::
    _M_default_append(size_type __n)
    {
      if (__n != 0)
	{
	  if (size_type(this->_M_impl._M_end_of_storage
			- this->_M_impl._M_finish) >= __n)
	    {
	      std::__uninitialized_default_n_a(this->_M_impl._M_finish,
					       __n, _M_get_Tp_allocator());
	      this->_M_impl._M_finish += __n;
	    }
	  else
	    {
	      const size_type __len =
		_M_check_len(__n, "vector::_M_default_append");
	      const size_type __old_size = this->size();
	      pointer __new_start(this->_M_allocate(__len));
	      pointer __new_finish(__new_start);
	      __try
		{
		  __new_finish
		    = std::__uninitialized_move_if_noexcept_a
		    (this->_M_impl._M_start, this->_M_impl._M_finish,
		     __new_start, _M_get_Tp_allocator());
		  std::__uninitialized_default_n_a(__new_finish, __n,
						   _M_get_Tp_allocator());
		  __new_finish += __n;
		}
	      __catch(...)
		{
		  std::_Destroy(__new_start, __new_finish,
				_M_get_Tp_allocator());
		  _M_deallocate(__new_start, __len);
		  __throw_exception_again;
		}
	      std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
			    _M_get_Tp_allocator());
	      _M_deallocate(this->_M_impl._M_start,
			    this->_M_impl._M_end_of_storage
			    - this->_M_impl._M_start);
	      this->_M_impl._M_start = __new_start;
	      this->_M_impl._M_finish = __new_finish;
	      this->_M_impl._M_end_of_storage = __new_start + __len;
	    }
	}
    }

  template<typename _Tp, typename _Alloc>
    bool
    vector<_Tp, _Alloc>::
    _M_shrink_to_fit()
    {
      if (capacity() == size())
	return false;
      return std::__shrink_to_fit_aux<vector>::_S_do_it(*this);
    }
#endif

d525 14
a538 12
		    __new_finish
		      = std::__uninitialized_move_if_noexcept_a
		      (this->_M_impl._M_start, __position.base(),
		       __new_start, _M_get_Tp_allocator());
		    __new_finish
		      = std::__uninitialized_copy_a(__first, __last,
						    __new_finish,
						    _M_get_Tp_allocator());
		    __new_finish
		      = std::__uninitialized_move_if_noexcept_a
		      (__position.base(), this->_M_impl._M_finish,
		       __new_finish, _M_get_Tp_allocator());
d561 1
d565 1
a565 1
    _M_reallocate(size_type __n)
d567 12
a578 6
      _Bit_type* __q = this->_M_allocate(__n);
      this->_M_impl._M_finish = _M_copy_aligned(begin(), end(),
						iterator(__q, 0));
      this->_M_deallocate();
      this->_M_impl._M_start = iterator(__q, 0);
      this->_M_impl._M_end_of_storage = __q + _S_nword(__n);
d606 3
a608 1
	  this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
d641 4
a644 1
		this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
d672 3
a674 1
	  this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
d679 1
a679 20
#if __cplusplus >= 201103L
  template<typename _Alloc>
    bool
    vector<bool, _Alloc>::
    _M_shrink_to_fit()
    {
      if (capacity() - size() < int(_S_word_bit))
	return false;
      __try
	{
	  _M_reallocate(size());
	  return true;
	}
      __catch(...)
	{ return false; }
    }
#endif

_GLIBCXX_END_NAMESPACE_CONTAINER
} // namespace std
d681 1
a681 1
#if __cplusplus >= 201103L
d683 1
a683 3
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
d687 2
a688 2
    hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>::
    operator()(const _GLIBCXX_STD_C::vector<bool, _Alloc>& __b) const noexcept
d691 2
a692 2
      using _GLIBCXX_STD_C::_S_word_bit;
      using _GLIBCXX_STD_C::_Bit_type;
d698 1
a698 1
	  __hash = std::_Hash_impl::hash(__b._M_impl._M_start._M_p, __clength);
d710 1
a710 1
	    __hash = std::_Hash_impl::hash(&__hiword, __clength, __hash);
d712 1
a712 1
	    __hash = std::_Hash_impl::hash(&__hiword, __clength);
d718 1
a718 2
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
d720 1
a720 1
#endif // C++11
@


1.1.1.3
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.
a107 3
#if __cplusplus >= 201103L
    insert(const_iterator __position, const value_type& __x)
#else
a108 1
#endif
a119 1
	  const auto __pos = begin() + (__position - cbegin());
d123 1
a123 1
	      _M_insert_aux(__pos, std::move(__x_copy));
d126 1
a126 2
	    _M_insert_aux(__pos, __x);
#else
a127 1
#endif
d135 1
a135 1
    _M_erase(iterator __position)
d147 1
a147 1
    _M_erase(iterator __first, iterator __last)
d224 1
a224 1
	  __tmp._M_impl._M_swap_data(this->_M_impl);
d229 4
a232 4
	  this->_M_impl._M_finish =
	    std::__uninitialized_fill_n_a(this->_M_impl._M_finish,
					  __n - size(), __val,
					  _M_get_Tp_allocator());
d295 1
a295 1
      emplace(const_iterator __position, _Args&&... __args)
d306 1
a306 2
	  _M_insert_aux(begin() + (__position - cbegin()),
			std::forward<_Args>(__args)...);
d360 1
a360 1
	      __new_finish = pointer();
d410 1
a410 1
	    __new_finish = pointer();
d466 5
a470 5
		  this->_M_impl._M_finish =
		    std::__uninitialized_fill_n_a(this->_M_impl._M_finish,
						  __n - __elems_after,
						  __x_copy,
						  _M_get_Tp_allocator());
d491 1
a491 1
		  __new_finish = pointer();
d540 3
a542 3
	      this->_M_impl._M_finish =
		std::__uninitialized_default_n_a(this->_M_impl._M_finish,
						 __n, _M_get_Tp_allocator());
d557 3
a559 3
		  __new_finish =
		    std::__uninitialized_default_n_a(__new_finish, __n,
						     _M_get_Tp_allocator());
d694 3
a696 3
      _Bit_pointer __q = this->_M_allocate(__n);
      iterator __start(std::__addressof(*__q), 0);
      this->_M_impl._M_finish = _M_copy_aligned(begin(), end(), __start);
d698 1
a698 1
      this->_M_impl._M_start = __start;
d720 3
a722 3
	  _Bit_pointer __q = this->_M_allocate(__len);
	  iterator __start(std::__addressof(*__q), 0);
	  iterator __i = _M_copy_aligned(begin(), __position, __start);
d728 1
a728 1
	  this->_M_impl._M_start = __start;
d754 3
a756 3
		_Bit_pointer __q = this->_M_allocate(__len);
		iterator __start(std::__addressof(*__q), 0);
		iterator __i = _M_copy_aligned(begin(), __position, __start);
d761 1
a761 1
		this->_M_impl._M_start = __start;
d771 1
a771 1
      if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr())
d782 3
a784 3
	  _Bit_pointer __q = this->_M_allocate(__len);
	  iterator __start(std::__addressof(*__q), 0);
	  iterator __i = _M_copy_aligned(begin(), __position, __start);
d789 1
a789 1
	  this->_M_impl._M_start = __start;
a792 21
  template<typename _Alloc>
    typename vector<bool, _Alloc>::iterator
    vector<bool, _Alloc>::
    _M_erase(iterator __position)
    {
      if (__position + 1 != end())
        std::copy(__position + 1, end(), __position);
      --this->_M_impl._M_finish;
      return __position;
    }

  template<typename _Alloc>
    typename vector<bool, _Alloc>::iterator
    vector<bool, _Alloc>::
    _M_erase(iterator __first, iterator __last)
    {
      if (__first != __last)
	_M_erase_at_end(std::copy(__last, end(), __first));
      return __first;
    }

@


1.1.1.4
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.4.4.1
log
@Sync with HEAD
@
text
@d3 1
a3 1
// Copyright (C) 2001-2017 Free Software Foundation, Inc.
a89 3
#if __cplusplus > 201402L
      typename vector<_Tp, _Alloc>::reference
#else
a90 1
#endif
d101 1
a101 4
	  _M_realloc_insert(end(), std::forward<_Args>(__args)...);
#if __cplusplus > 201402L
	return back();
#endif
d115 8
a122 9
      if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
	if (__position == end())
	  {
	    _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
				     __x);
	    ++this->_M_impl._M_finish;
	  }
	else
	  {
d124 8
a131 5
	    const auto __pos = begin() + (__position - cbegin());
	    // __x could be an existing element of this vector, so make a
	    // copy of it before _M_insert_aux moves elements around.
	    _Temporary_value __x_copy(this, __x);
	    _M_insert_aux(__pos, std::move(__x_copy._M_val()));
d135 1
a135 8
	  }
      else
#if __cplusplus >= 201103L
	_M_realloc_insert(begin() + (__position - cbegin()), __x);
#else
	_M_realloc_insert(__position, __x);
#endif

d259 1
a259 2
	  _M_range_insert(end(), __first, __last,
			  std::__iterator_category(__first));
d299 8
a306 7
    auto
    vector<_Tp, _Alloc>::
    _M_insert_rval(const_iterator __position, value_type&& __v) -> iterator
    {
      const auto __n = __position - cbegin();
      if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
	if (__position == cend())
d309 1
a309 1
				     std::move(__v));
d313 2
a314 33
	  _M_insert_aux(begin() + __n, std::move(__v));
      else
	_M_realloc_insert(begin() + __n, std::move(__v));

      return iterator(this->_M_impl._M_start + __n);
    }

  template<typename _Tp, typename _Alloc>
    template<typename... _Args>
      auto
      vector<_Tp, _Alloc>::
      _M_emplace_aux(const_iterator __position, _Args&&... __args)
      -> iterator
      {
	const auto __n = __position - cbegin();
	if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
	  if (__position == cend())
	    {
	      _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
				       std::forward<_Args>(__args)...);
	      ++this->_M_impl._M_finish;
	    }
	  else
	    {
	      // We need to construct a temporary because something in __args...
	      // could alias one of the elements of the container and so we
	      // need to use it before _M_insert_aux moves elements around.
	      _Temporary_value __tmp(this, std::forward<_Args>(__args)...);
	      _M_insert_aux(begin() + __n, std::move(__tmp._M_val()));
	    }
	else
	  _M_realloc_insert(begin() + __n, std::forward<_Args>(__args)...);

d319 1
a319 1
    template<typename _Arg>
d322 1
a322 1
      _M_insert_aux(iterator __position, _Arg&& __arg)
d330 6
a335 4
      _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
			       _GLIBCXX_MOVE(*(this->_M_impl._M_finish
					       - 1)));
      ++this->_M_impl._M_finish;
d337 1
a337 1
      _Tp __x_copy = __x;
d339 3
a341 3
      _GLIBCXX_MOVE_BACKWARD3(__position.base(),
			      this->_M_impl._M_finish - 2,
			      this->_M_impl._M_finish - 1);
d343 1
a343 1
      *__position = __x_copy;
d345 1
a345 1
      *__position = std::forward<_Arg>(__arg);
d347 54
d408 11
a418 28
      _M_realloc_insert(iterator __position, _Args&&... __args)
#else
  template<typename _Tp, typename _Alloc>
    void
    vector<_Tp, _Alloc>::
    _M_realloc_insert(iterator __position, const _Tp& __x)
#endif
    {
      const size_type __len =
	_M_check_len(size_type(1), "vector::_M_realloc_insert");
      const size_type __elems_before = __position - begin();
      pointer __new_start(this->_M_allocate(__len));
      pointer __new_finish(__new_start);
      __try
	{
	  // The order of the three operations is dictated by the C++11
	  // case, where the moves could alter a new element belonging
	  // to the existing vector.  This is an issue only for callers
	  // taking the element by lvalue ref (see last bullet of C++11
	  // [res.on.arguments]).
	  _Alloc_traits::construct(this->_M_impl,
				   __new_start + __elems_before,
#if __cplusplus >= 201103L
				   std::forward<_Args>(__args)...);
#else
				   __x);
#endif
	  __new_finish = pointer();
d420 4
a423 4
	  __new_finish
	    = std::__uninitialized_move_if_noexcept_a
	    (this->_M_impl._M_start, __position.base(),
	     __new_start, _M_get_Tp_allocator());
d425 21
a445 26
	  ++__new_finish;

	  __new_finish
	    = std::__uninitialized_move_if_noexcept_a
	    (__position.base(), this->_M_impl._M_finish,
	     __new_finish, _M_get_Tp_allocator());
	}
      __catch(...)
	{
	  if (!__new_finish)
	    _Alloc_traits::destroy(this->_M_impl,
				   __new_start + __elems_before);
	  else
	    std::_Destroy(__new_start, __new_finish, _M_get_Tp_allocator());
	  _M_deallocate(__new_start, __len);
	  __throw_exception_again;
	}
      std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
		    _M_get_Tp_allocator());
      _M_deallocate(this->_M_impl._M_start,
		    this->_M_impl._M_end_of_storage
		    - this->_M_impl._M_start);
      this->_M_impl._M_start = __new_start;
      this->_M_impl._M_finish = __new_finish;
      this->_M_impl._M_end_of_storage = __new_start + __len;
    }
a456 1
#if __cplusplus < 201103L
a457 4
#else
	      _Temporary_value __tmp(this, __x);
	      value_type& __x_copy = __tmp._M_val();
#endif
d495 1
a495 1
		  // See _M_realloc_insert above.
d556 1
a556 1
	      const size_type __size = this->size();
d558 1
a558 1
	      pointer __destroy_from = pointer();
d561 7
a567 6
		  std::__uninitialized_default_n_a(__new_start + __size,
						   __n, _M_get_Tp_allocator());
		  __destroy_from = __new_start + __size;
		  std::__uninitialized_move_if_noexcept_a(
		      this->_M_impl._M_start, this->_M_impl._M_finish,
		      __new_start, _M_get_Tp_allocator());
d571 2
a572 3
		  if (__destroy_from)
		    std::_Destroy(__destroy_from, __destroy_from + __n,
				  _M_get_Tp_allocator());
d582 1
a582 1
	      this->_M_impl._M_finish = __new_start + __size + __n;
d704 1
a704 1
      iterator __finish(_M_copy_aligned(begin(), end(), __start));
a706 1
      this->_M_impl._M_finish = __finish;
d732 2
a733 2
	  iterator __finish = std::copy(__position, end(),
					__i + difference_type(__n));
a736 1
	  this->_M_impl._M_finish = __finish;
d766 1
a766 1
		iterator __finish = std::copy(__position, end(), __i);
a769 1
		this->_M_impl._M_finish = __finish;
d794 1
a794 1
	  iterator __finish = std::copy(__position, end(), __i);
a797 1
	  this->_M_impl._M_finish = __finish;
@


1.1.1.4.4.2
log
@Mostly merge changes from HEAD upto 20200411
@
text
@d3 1
a3 1
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
a60 1
_GLIBCXX_BEGIN_NAMESPACE_VERSION
a75 1
	  _GLIBCXX_ASAN_ANNOTATE_REINIT;
a99 1
	    _GLIBCXX_ASAN_ANNOTATE_GROW(1);
a102 1
	    _GLIBCXX_ASAN_ANNOTATE_GREW(1);
a124 1
	    _GLIBCXX_ASAN_ANNOTATE_GROW(1);
a127 1
	    _GLIBCXX_ASAN_ANNOTATE_GREW(1);
a159 1
      _GLIBCXX_ASAN_ANNOTATE_SHRINK(1);
a183 1
	  _GLIBCXX_ASAN_ANNOTATE_REINIT;
a247 2
	  const size_type __add = __n - size();
	  _GLIBCXX_ASAN_ANNOTATE_GROW(__add);
d250 2
a251 2
					  __add, __val, _M_get_Tp_allocator());
	  _GLIBCXX_ASAN_ANNOTATE_GREW(__add);
a286 1
	    _GLIBCXX_ASAN_ANNOTATE_REINIT;
a302 2
	    const size_type __attribute__((__unused__)) __n = __len - size();
	    _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
a306 1
	    _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
a319 1
	    _GLIBCXX_ASAN_ANNOTATE_GROW(1);
a322 1
	    _GLIBCXX_ASAN_ANNOTATE_GREW(1);
a342 1
	      _GLIBCXX_ASAN_ANNOTATE_GROW(1);
a345 1
	      _GLIBCXX_ASAN_ANNOTATE_GREW(1);
a372 1
      _GLIBCXX_ASAN_ANNOTATE_GROW(1);
d374 2
a375 1
			       _GLIBCXX_MOVE(*(this->_M_impl._M_finish - 1)));
a376 1
      _GLIBCXX_ASAN_ANNOTATE_GREW(1);
a404 2
      pointer __old_start = this->_M_impl._M_start;
      pointer __old_finish = this->_M_impl._M_finish;
d426 1
a426 1
	    (__old_start, __position.base(),
d433 1
a433 1
	    (__position.base(), __old_finish,
d446 5
a450 4
      _GLIBCXX_ASAN_ANNOTATE_REINIT;
      std::_Destroy(__old_start, __old_finish, _M_get_Tp_allocator());
      _M_deallocate(__old_start,
		    this->_M_impl._M_end_of_storage - __old_start);
a475 1
		  _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
a480 1
		  _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
a487 1
		  _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
a492 1
		  _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
a496 1
		  _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
a538 1
	      _GLIBCXX_ASAN_ANNOTATE_REINIT;
d559 2
a560 8
	  const size_type __size = size();
	  size_type __navail = size_type(this->_M_impl._M_end_of_storage
					 - this->_M_impl._M_finish);

	  if (__size > max_size() || __navail > max_size() - __size)
	    __builtin_unreachable();

	  if (__navail >= __n)
a561 1
	      _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
a564 1
	      _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
d570 1
a589 1
	      _GLIBCXX_ASAN_ANNOTATE_REINIT;
a608 1
      _GLIBCXX_ASAN_ANNOTATE_REINIT;
d620 1
a620 6
	if (__pos == end())
	  {
	    for (; __first != __last; ++__first)
	      insert(end(), *__first);
	  }
	else if (__first != __last)
d622 2
a623 4
	    vector __tmp(__first, __last, _M_get_Tp_allocator());
	    insert(__pos,
		   _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.begin()),
		   _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.end()));
a643 1
		    _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
a648 1
		    _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
a656 1
		    _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
a660 1
		    _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
a665 1
		    _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
a696 1
		_GLIBCXX_ASAN_ANNOTATE_REINIT;
a858 1
_GLIBCXX_END_NAMESPACE_VERSION
a904 5
#undef _GLIBCXX_ASAN_ANNOTATE_REINIT
#undef _GLIBCXX_ASAN_ANNOTATE_GROW
#undef _GLIBCXX_ASAN_ANNOTATE_GREW
#undef _GLIBCXX_ASAN_ANNOTATE_SHRINK

@


1.1.1.4.2.1
log
@Sync with HEAD, resolve a couple of conflicts
@
text
@d556 1
a556 1
	      const size_type __size = this->size();
d558 1
a558 1
	      pointer __destroy_from = pointer();
d561 7
a567 6
		  std::__uninitialized_default_n_a(__new_start + __size,
						   __n, _M_get_Tp_allocator());
		  __destroy_from = __new_start + __size;
		  std::__uninitialized_move_if_noexcept_a(
		      this->_M_impl._M_start, this->_M_impl._M_finish,
		      __new_start, _M_get_Tp_allocator());
d571 2
a572 3
		  if (__destroy_from)
		    std::_Destroy(__destroy_from, __destroy_from + __n,
				  _M_get_Tp_allocator());
d582 1
a582 1
	      this->_M_impl._M_finish = __new_start + __size + __n;
@


1.1.1.4.2.2
log
@Sync with HEAD
@
text
@d3 1
a3 1
// Copyright (C) 2001-2017 Free Software Foundation, Inc.
a89 3
#if __cplusplus > 201402L
      typename vector<_Tp, _Alloc>::reference
#else
a90 1
#endif
d101 1
a101 4
	  _M_realloc_insert(end(), std::forward<_Args>(__args)...);
#if __cplusplus > 201402L
	return back();
#endif
d115 8
a122 9
      if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
	if (__position == end())
	  {
	    _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
				     __x);
	    ++this->_M_impl._M_finish;
	  }
	else
	  {
d124 8
a131 5
	    const auto __pos = begin() + (__position - cbegin());
	    // __x could be an existing element of this vector, so make a
	    // copy of it before _M_insert_aux moves elements around.
	    _Temporary_value __x_copy(this, __x);
	    _M_insert_aux(__pos, std::move(__x_copy._M_val()));
d135 1
a135 8
	  }
      else
#if __cplusplus >= 201103L
	_M_realloc_insert(begin() + (__position - cbegin()), __x);
#else
	_M_realloc_insert(__position, __x);
#endif

d259 1
a259 2
	  _M_range_insert(end(), __first, __last,
			  std::__iterator_category(__first));
d299 8
a306 7
    auto
    vector<_Tp, _Alloc>::
    _M_insert_rval(const_iterator __position, value_type&& __v) -> iterator
    {
      const auto __n = __position - cbegin();
      if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
	if (__position == cend())
d309 1
a309 1
				     std::move(__v));
d313 2
a314 33
	  _M_insert_aux(begin() + __n, std::move(__v));
      else
	_M_realloc_insert(begin() + __n, std::move(__v));

      return iterator(this->_M_impl._M_start + __n);
    }

  template<typename _Tp, typename _Alloc>
    template<typename... _Args>
      auto
      vector<_Tp, _Alloc>::
      _M_emplace_aux(const_iterator __position, _Args&&... __args)
      -> iterator
      {
	const auto __n = __position - cbegin();
	if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
	  if (__position == cend())
	    {
	      _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
				       std::forward<_Args>(__args)...);
	      ++this->_M_impl._M_finish;
	    }
	  else
	    {
	      // We need to construct a temporary because something in __args...
	      // could alias one of the elements of the container and so we
	      // need to use it before _M_insert_aux moves elements around.
	      _Temporary_value __tmp(this, std::forward<_Args>(__args)...);
	      _M_insert_aux(begin() + __n, std::move(__tmp._M_val()));
	    }
	else
	  _M_realloc_insert(begin() + __n, std::forward<_Args>(__args)...);

d319 1
a319 1
    template<typename _Arg>
d322 1
a322 1
      _M_insert_aux(iterator __position, _Arg&& __arg)
d330 6
a335 4
      _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
			       _GLIBCXX_MOVE(*(this->_M_impl._M_finish
					       - 1)));
      ++this->_M_impl._M_finish;
d337 1
a337 1
      _Tp __x_copy = __x;
d339 3
a341 3
      _GLIBCXX_MOVE_BACKWARD3(__position.base(),
			      this->_M_impl._M_finish - 2,
			      this->_M_impl._M_finish - 1);
d343 1
a343 1
      *__position = __x_copy;
d345 1
a345 1
      *__position = std::forward<_Arg>(__arg);
d347 54
d408 11
a418 28
      _M_realloc_insert(iterator __position, _Args&&... __args)
#else
  template<typename _Tp, typename _Alloc>
    void
    vector<_Tp, _Alloc>::
    _M_realloc_insert(iterator __position, const _Tp& __x)
#endif
    {
      const size_type __len =
	_M_check_len(size_type(1), "vector::_M_realloc_insert");
      const size_type __elems_before = __position - begin();
      pointer __new_start(this->_M_allocate(__len));
      pointer __new_finish(__new_start);
      __try
	{
	  // The order of the three operations is dictated by the C++11
	  // case, where the moves could alter a new element belonging
	  // to the existing vector.  This is an issue only for callers
	  // taking the element by lvalue ref (see last bullet of C++11
	  // [res.on.arguments]).
	  _Alloc_traits::construct(this->_M_impl,
				   __new_start + __elems_before,
#if __cplusplus >= 201103L
				   std::forward<_Args>(__args)...);
#else
				   __x);
#endif
	  __new_finish = pointer();
d420 4
a423 4
	  __new_finish
	    = std::__uninitialized_move_if_noexcept_a
	    (this->_M_impl._M_start, __position.base(),
	     __new_start, _M_get_Tp_allocator());
d425 21
a445 26
	  ++__new_finish;

	  __new_finish
	    = std::__uninitialized_move_if_noexcept_a
	    (__position.base(), this->_M_impl._M_finish,
	     __new_finish, _M_get_Tp_allocator());
	}
      __catch(...)
	{
	  if (!__new_finish)
	    _Alloc_traits::destroy(this->_M_impl,
				   __new_start + __elems_before);
	  else
	    std::_Destroy(__new_start, __new_finish, _M_get_Tp_allocator());
	  _M_deallocate(__new_start, __len);
	  __throw_exception_again;
	}
      std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
		    _M_get_Tp_allocator());
      _M_deallocate(this->_M_impl._M_start,
		    this->_M_impl._M_end_of_storage
		    - this->_M_impl._M_start);
      this->_M_impl._M_start = __new_start;
      this->_M_impl._M_finish = __new_finish;
      this->_M_impl._M_end_of_storage = __new_start + __len;
    }
a456 1
#if __cplusplus < 201103L
a457 4
#else
	      _Temporary_value __tmp(this, __x);
	      value_type& __x_copy = __tmp._M_val();
#endif
d495 1
a495 1
		  // See _M_realloc_insert above.
d704 1
a704 1
      iterator __finish(_M_copy_aligned(begin(), end(), __start));
a706 1
      this->_M_impl._M_finish = __finish;
d732 2
a733 2
	  iterator __finish = std::copy(__position, end(),
					__i + difference_type(__n));
a736 1
	  this->_M_impl._M_finish = __finish;
d766 1
a766 1
		iterator __finish = std::copy(__position, end(), __i);
a769 1
		this->_M_impl._M_finish = __finish;
d794 1
a794 1
	  iterator __finish = std::copy(__position, end(), __i);
a797 1
	  this->_M_impl._M_finish = __finish;
@


1.1.1.5
log
@import GCC 6.5.0.  this is largely a maint release with no
particularly features listed here:

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

this fixes over 250 PRs in the GCC bugzilla:

   https://gcc.gnu.org/bugzilla/buglist.cgi?bug_status=RESOLVED&resolution=FIXED&target_milestone=6.5
@
text
@d556 1
a556 1
	      const size_type __size = this->size();
d558 1
a558 1
	      pointer __destroy_from = pointer();
d561 7
a567 6
		  std::__uninitialized_default_n_a(__new_start + __size,
						   __n, _M_get_Tp_allocator());
		  __destroy_from = __new_start + __size;
		  std::__uninitialized_move_if_noexcept_a(
		      this->_M_impl._M_start, this->_M_impl._M_finish,
		      __new_start, _M_get_Tp_allocator());
d571 2
a572 3
		  if (__destroy_from)
		    std::_Destroy(__destroy_from, __destroy_from + __n,
				  _M_get_Tp_allocator());
d582 1
a582 1
	      this->_M_impl._M_finish = __new_start + __size + __n;
@


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.
a89 3
#if __cplusplus > 201402L
      typename vector<_Tp, _Alloc>::reference
#else
a90 1
#endif
d101 1
a101 4
	  _M_realloc_insert(end(), std::forward<_Args>(__args)...);
#if __cplusplus > 201402L
	return back();
#endif
d115 8
a122 9
      if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
	if (__position == end())
	  {
	    _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
				     __x);
	    ++this->_M_impl._M_finish;
	  }
	else
	  {
d124 8
a131 5
	    const auto __pos = begin() + (__position - cbegin());
	    // __x could be an existing element of this vector, so make a
	    // copy of it before _M_insert_aux moves elements around.
	    _Temporary_value __x_copy(this, __x);
	    _M_insert_aux(__pos, std::move(__x_copy._M_val()));
d135 1
a135 8
	  }
      else
#if __cplusplus >= 201103L
	_M_realloc_insert(begin() + (__position - cbegin()), __x);
#else
	_M_realloc_insert(__position, __x);
#endif

d259 1
a259 2
	  _M_range_insert(end(), __first, __last,
			  std::__iterator_category(__first));
d299 8
a306 7
    auto
    vector<_Tp, _Alloc>::
    _M_insert_rval(const_iterator __position, value_type&& __v) -> iterator
    {
      const auto __n = __position - cbegin();
      if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
	if (__position == cend())
d309 1
a309 1
				     std::move(__v));
d313 2
a314 33
	  _M_insert_aux(begin() + __n, std::move(__v));
      else
	_M_realloc_insert(begin() + __n, std::move(__v));

      return iterator(this->_M_impl._M_start + __n);
    }

  template<typename _Tp, typename _Alloc>
    template<typename... _Args>
      auto
      vector<_Tp, _Alloc>::
      _M_emplace_aux(const_iterator __position, _Args&&... __args)
      -> iterator
      {
	const auto __n = __position - cbegin();
	if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
	  if (__position == cend())
	    {
	      _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
				       std::forward<_Args>(__args)...);
	      ++this->_M_impl._M_finish;
	    }
	  else
	    {
	      // We need to construct a temporary because something in __args...
	      // could alias one of the elements of the container and so we
	      // need to use it before _M_insert_aux moves elements around.
	      _Temporary_value __tmp(this, std::forward<_Args>(__args)...);
	      _M_insert_aux(begin() + __n, std::move(__tmp._M_val()));
	    }
	else
	  _M_realloc_insert(begin() + __n, std::forward<_Args>(__args)...);

d319 1
a319 1
    template<typename _Arg>
d322 1
a322 1
      _M_insert_aux(iterator __position, _Arg&& __arg)
d330 6
a335 4
      _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
			       _GLIBCXX_MOVE(*(this->_M_impl._M_finish
					       - 1)));
      ++this->_M_impl._M_finish;
d337 1
a337 1
      _Tp __x_copy = __x;
d339 3
a341 3
      _GLIBCXX_MOVE_BACKWARD3(__position.base(),
			      this->_M_impl._M_finish - 2,
			      this->_M_impl._M_finish - 1);
d343 1
a343 1
      *__position = __x_copy;
d345 1
a345 1
      *__position = std::forward<_Arg>(__arg);
d347 54
d408 11
a418 28
      _M_realloc_insert(iterator __position, _Args&&... __args)
#else
  template<typename _Tp, typename _Alloc>
    void
    vector<_Tp, _Alloc>::
    _M_realloc_insert(iterator __position, const _Tp& __x)
#endif
    {
      const size_type __len =
	_M_check_len(size_type(1), "vector::_M_realloc_insert");
      const size_type __elems_before = __position - begin();
      pointer __new_start(this->_M_allocate(__len));
      pointer __new_finish(__new_start);
      __try
	{
	  // The order of the three operations is dictated by the C++11
	  // case, where the moves could alter a new element belonging
	  // to the existing vector.  This is an issue only for callers
	  // taking the element by lvalue ref (see last bullet of C++11
	  // [res.on.arguments]).
	  _Alloc_traits::construct(this->_M_impl,
				   __new_start + __elems_before,
#if __cplusplus >= 201103L
				   std::forward<_Args>(__args)...);
#else
				   __x);
#endif
	  __new_finish = pointer();
d420 4
a423 4
	  __new_finish
	    = std::__uninitialized_move_if_noexcept_a
	    (this->_M_impl._M_start, __position.base(),
	     __new_start, _M_get_Tp_allocator());
d425 21
a445 26
	  ++__new_finish;

	  __new_finish
	    = std::__uninitialized_move_if_noexcept_a
	    (__position.base(), this->_M_impl._M_finish,
	     __new_finish, _M_get_Tp_allocator());
	}
      __catch(...)
	{
	  if (!__new_finish)
	    _Alloc_traits::destroy(this->_M_impl,
				   __new_start + __elems_before);
	  else
	    std::_Destroy(__new_start, __new_finish, _M_get_Tp_allocator());
	  _M_deallocate(__new_start, __len);
	  __throw_exception_again;
	}
      std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
		    _M_get_Tp_allocator());
      _M_deallocate(this->_M_impl._M_start,
		    this->_M_impl._M_end_of_storage
		    - this->_M_impl._M_start);
      this->_M_impl._M_start = __new_start;
      this->_M_impl._M_finish = __new_finish;
      this->_M_impl._M_end_of_storage = __new_start + __len;
    }
a456 1
#if __cplusplus < 201103L
a457 4
#else
	      _Temporary_value __tmp(this, __x);
	      value_type& __x_copy = __tmp._M_val();
#endif
d495 1
a495 1
		  // See _M_realloc_insert above.
d704 1
a704 1
      iterator __finish(_M_copy_aligned(begin(), end(), __start));
a706 1
      this->_M_impl._M_finish = __finish;
d732 2
a733 2
	  iterator __finish = std::copy(__position, end(),
					__i + difference_type(__n));
a736 1
	  this->_M_impl._M_finish = __finish;
d766 1
a766 1
		iterator __finish = std::copy(__position, end(), __i);
a769 1
		this->_M_impl._M_finish = __finish;
d794 1
a794 1
	  iterator __finish = std::copy(__position, end(), __i);
a797 1
	  this->_M_impl._M_finish = __finish;
@


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.
a60 1
_GLIBCXX_BEGIN_NAMESPACE_VERSION
a75 1
	  _GLIBCXX_ASAN_ANNOTATE_REINIT;
a99 1
	    _GLIBCXX_ASAN_ANNOTATE_GROW(1);
a102 1
	    _GLIBCXX_ASAN_ANNOTATE_GREW(1);
a124 1
	    _GLIBCXX_ASAN_ANNOTATE_GROW(1);
a127 1
	    _GLIBCXX_ASAN_ANNOTATE_GREW(1);
a159 1
      _GLIBCXX_ASAN_ANNOTATE_SHRINK(1);
a183 1
	  _GLIBCXX_ASAN_ANNOTATE_REINIT;
a247 2
	  const size_type __add = __n - size();
	  _GLIBCXX_ASAN_ANNOTATE_GROW(__add);
d250 2
a251 2
					  __add, __val, _M_get_Tp_allocator());
	  _GLIBCXX_ASAN_ANNOTATE_GREW(__add);
a286 1
	    _GLIBCXX_ASAN_ANNOTATE_REINIT;
a302 2
	    const size_type __attribute__((__unused__)) __n = __len - size();
	    _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
a306 1
	    _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
a319 1
	    _GLIBCXX_ASAN_ANNOTATE_GROW(1);
a322 1
	    _GLIBCXX_ASAN_ANNOTATE_GREW(1);
a342 1
	      _GLIBCXX_ASAN_ANNOTATE_GROW(1);
a345 1
	      _GLIBCXX_ASAN_ANNOTATE_GREW(1);
a372 1
      _GLIBCXX_ASAN_ANNOTATE_GROW(1);
d374 2
a375 1
			       _GLIBCXX_MOVE(*(this->_M_impl._M_finish - 1)));
a376 1
      _GLIBCXX_ASAN_ANNOTATE_GREW(1);
a404 2
      pointer __old_start = this->_M_impl._M_start;
      pointer __old_finish = this->_M_impl._M_finish;
d426 1
a426 1
	    (__old_start, __position.base(),
d433 1
a433 1
	    (__position.base(), __old_finish,
d446 5
a450 4
      _GLIBCXX_ASAN_ANNOTATE_REINIT;
      std::_Destroy(__old_start, __old_finish, _M_get_Tp_allocator());
      _M_deallocate(__old_start,
		    this->_M_impl._M_end_of_storage - __old_start);
a475 1
		  _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
a480 1
		  _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
a487 1
		  _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
a492 1
		  _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
a496 1
		  _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
a538 1
	      _GLIBCXX_ASAN_ANNOTATE_REINIT;
d559 2
a560 8
	  const size_type __size = size();
	  size_type __navail = size_type(this->_M_impl._M_end_of_storage
					 - this->_M_impl._M_finish);

	  if (__size > max_size() || __navail > max_size() - __size)
	    __builtin_unreachable();

	  if (__navail >= __n)
a561 1
	      _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
a564 1
	      _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
d570 1
a589 1
	      _GLIBCXX_ASAN_ANNOTATE_REINIT;
a608 1
      _GLIBCXX_ASAN_ANNOTATE_REINIT;
d620 1
a620 6
	if (__pos == end())
	  {
	    for (; __first != __last; ++__first)
	      insert(end(), *__first);
	  }
	else if (__first != __last)
d622 2
a623 4
	    vector __tmp(__first, __last, _M_get_Tp_allocator());
	    insert(__pos,
		   _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.begin()),
		   _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.end()));
a643 1
		    _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
a648 1
		    _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
a656 1
		    _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
a660 1
		    _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
a665 1
		    _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
a696 1
		_GLIBCXX_ASAN_ANNOTATE_REINIT;
a858 1
_GLIBCXX_END_NAMESPACE_VERSION
a904 5
#undef _GLIBCXX_ASAN_ANNOTATE_REINIT
#undef _GLIBCXX_ASAN_ANNOTATE_GROW
#undef _GLIBCXX_ASAN_ANNOTATE_GREW
#undef _GLIBCXX_ASAN_ANNOTATE_SHRINK

@


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.
d61 1
d77 1
d102 1
d106 1
d129 1
d133 1
d166 1
d191 1
d256 2
d260 2
a261 2
					  __n - size(), __val,
					  _M_get_Tp_allocator());
d297 1
d314 2
d320 1
d334 1
d338 1
d359 1
d363 1
d391 1
d393 1
a393 2
			       _GLIBCXX_MOVE(*(this->_M_impl._M_finish
					       - 1)));
d395 1
d424 2
d447 1
a447 1
	    (this->_M_impl._M_start, __position.base(),
d454 1
a454 1
	    (__position.base(), this->_M_impl._M_finish,
d467 4
a470 5
      std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
		    _M_get_Tp_allocator());
      _M_deallocate(this->_M_impl._M_start,
		    this->_M_impl._M_end_of_storage
		    - this->_M_impl._M_start);
d496 1
d502 1
d510 1
d516 1
d521 1
d564 1
d585 8
a592 2
	  if (size_type(this->_M_impl._M_end_of_storage
			- this->_M_impl._M_finish) >= __n)
d594 1
d598 1
a603 1
	      const size_type __size = this->size();
d623 1
d643 1
d655 6
a660 1
	for (; __first != __last; ++__first)
d662 4
a665 2
	    __pos = insert(__pos, *__first);
	    ++__pos;
d686 1
d692 1
d701 1
d706 1
d712 1
d744 1
d907 1
d954 5
@


1.1.1.9
log
@re-import GCC 8.4.0.
@
text
@d3 1
a3 1
// Copyright (C) 2001-2018 Free Software Foundation, Inc.
a60 1
_GLIBCXX_BEGIN_NAMESPACE_VERSION
a75 1
	  _GLIBCXX_ASAN_ANNOTATE_REINIT;
a99 1
	    _GLIBCXX_ASAN_ANNOTATE_GROW(1);
a102 1
	    _GLIBCXX_ASAN_ANNOTATE_GREW(1);
a124 1
	    _GLIBCXX_ASAN_ANNOTATE_GROW(1);
a127 1
	    _GLIBCXX_ASAN_ANNOTATE_GREW(1);
a159 1
      _GLIBCXX_ASAN_ANNOTATE_SHRINK(1);
a183 1
	  _GLIBCXX_ASAN_ANNOTATE_REINIT;
a247 2
	  const size_type __add = __n - size();
	  _GLIBCXX_ASAN_ANNOTATE_GROW(__add);
d250 2
a251 2
					  __add, __val, _M_get_Tp_allocator());
	  _GLIBCXX_ASAN_ANNOTATE_GREW(__add);
a286 1
	    _GLIBCXX_ASAN_ANNOTATE_REINIT;
a302 2
	    const size_type __attribute__((__unused__)) __n = __len - size();
	    _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
a306 1
	    _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
a319 1
	    _GLIBCXX_ASAN_ANNOTATE_GROW(1);
a322 1
	    _GLIBCXX_ASAN_ANNOTATE_GREW(1);
a342 1
	      _GLIBCXX_ASAN_ANNOTATE_GROW(1);
a345 1
	      _GLIBCXX_ASAN_ANNOTATE_GREW(1);
a372 1
      _GLIBCXX_ASAN_ANNOTATE_GROW(1);
d374 2
a375 1
			       _GLIBCXX_MOVE(*(this->_M_impl._M_finish - 1)));
a376 1
      _GLIBCXX_ASAN_ANNOTATE_GREW(1);
a404 2
      pointer __old_start = this->_M_impl._M_start;
      pointer __old_finish = this->_M_impl._M_finish;
d426 1
a426 1
	    (__old_start, __position.base(),
d433 1
a433 1
	    (__position.base(), __old_finish,
d446 5
a450 4
      _GLIBCXX_ASAN_ANNOTATE_REINIT;
      std::_Destroy(__old_start, __old_finish, _M_get_Tp_allocator());
      _M_deallocate(__old_start,
		    this->_M_impl._M_end_of_storage - __old_start);
a475 1
		  _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
a480 1
		  _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
a487 1
		  _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
a492 1
		  _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
a496 1
		  _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
a538 1
	      _GLIBCXX_ASAN_ANNOTATE_REINIT;
d559 2
a560 8
	  const size_type __size = size();
	  size_type __navail = size_type(this->_M_impl._M_end_of_storage
					 - this->_M_impl._M_finish);

	  if (__size > max_size() || __navail > max_size() - __size)
	    __builtin_unreachable();

	  if (__navail >= __n)
a561 1
	      _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
a564 1
	      _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
d570 1
a589 1
	      _GLIBCXX_ASAN_ANNOTATE_REINIT;
a608 1
      _GLIBCXX_ASAN_ANNOTATE_REINIT;
d620 1
a620 6
	if (__pos == end())
	  {
	    for (; __first != __last; ++__first)
	      insert(end(), *__first);
	  }
	else if (__first != __last)
d622 2
a623 4
	    vector __tmp(__first, __last, _M_get_Tp_allocator());
	    insert(__pos,
		   _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.begin()),
		   _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.end()));
a643 1
		    _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
a648 1
		    _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
a656 1
		    _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
a660 1
		    _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after);
a665 1
		    _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after);
a696 1
		_GLIBCXX_ASAN_ANNOTATE_REINIT;
a858 1
_GLIBCXX_END_NAMESPACE_VERSION
a904 5
#undef _GLIBCXX_ASAN_ANNOTATE_REINIT
#undef _GLIBCXX_ASAN_ANNOTATE_GROW
#undef _GLIBCXX_ASAN_ANNOTATE_GREW
#undef _GLIBCXX_ASAN_ANNOTATE_SHRINK

@


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.
d74 3
a76 17
	  pointer __tmp;
#if __cplusplus >= 201103L
	  if _GLIBCXX17_CONSTEXPR (_S_use_relocate())
	    {
	      __tmp = this->_M_allocate(__n);
	      _S_relocate(this->_M_impl._M_start, this->_M_impl._M_finish,
			  __tmp, _M_get_Tp_allocator());
	    }
	  else
#endif
	    {
	      __tmp = _M_allocate_and_copy(__n,
		_GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(this->_M_impl._M_start),
		_GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(this->_M_impl._M_finish));
	      std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
			    _M_get_Tp_allocator());
	    }
d78 2
d276 1
a276 1
	     ++__cur, (void)++__first)
a295 1
	    _S_check_init_len(__len, _M_get_Tp_allocator());
d297 1
a299 1
	    _GLIBCXX_ASAN_ANNOTATE_REINIT;
d445 11
a455 26
#if __cplusplus >= 201103L
	  if _GLIBCXX17_CONSTEXPR (_S_use_relocate())
	    {
	      __new_finish = _S_relocate(__old_start, __position.base(),
					 __new_start, _M_get_Tp_allocator());

	      ++__new_finish;

	      __new_finish = _S_relocate(__position.base(), __old_finish,
					 __new_finish, _M_get_Tp_allocator());
	    }
	  else
#endif
	    {
	      __new_finish
		= std::__uninitialized_move_if_noexcept_a
		(__old_start, __position.base(),
		 __new_start, _M_get_Tp_allocator());

	      ++__new_finish;

	      __new_finish
		= std::__uninitialized_move_if_noexcept_a
		(__position.base(), __old_finish,
		 __new_finish, _M_get_Tp_allocator());
	    }
a466 4
#if __cplusplus >= 201103L
      if _GLIBCXX17_CONSTEXPR (!_S_use_relocate())
#endif
	std::_Destroy(__old_start, __old_finish, _M_get_Tp_allocator());
d468 1
d564 1
a566 1
	      _GLIBCXX_ASAN_ANNOTATE_REINIT;
d605 2
a606 1
	      if _GLIBCXX17_CONSTEXPR (_S_use_relocate())
d608 6
a613 12
		  __try
		    {
		      std::__uninitialized_default_n_a(__new_start + __size,
			      __n, _M_get_Tp_allocator());
		    }
		  __catch(...)
		    {
		      _M_deallocate(__new_start, __len);
		      __throw_exception_again;
		    }
		  _S_relocate(this->_M_impl._M_start, this->_M_impl._M_finish,
			      __new_start, _M_get_Tp_allocator());
d615 1
a615 1
	      else
d617 5
a621 20
		  pointer __destroy_from = pointer();
		  __try
		    {
		      std::__uninitialized_default_n_a(__new_start + __size,
			      __n, _M_get_Tp_allocator());
		      __destroy_from = __new_start + __size;
		      std::__uninitialized_move_if_noexcept_a(
			      this->_M_impl._M_start, this->_M_impl._M_finish,
			      __new_start, _M_get_Tp_allocator());
		    }
		  __catch(...)
		    {
		      if (__destroy_from)
			std::_Destroy(__destroy_from, __destroy_from + __n,
				      _M_get_Tp_allocator());
		      _M_deallocate(__new_start, __len);
		      __throw_exception_again;
		    }
		  std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
				_M_get_Tp_allocator());
d624 2
d744 1
a746 1
		_GLIBCXX_ASAN_ANNOTATE_REINIT;
@


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.
@


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
@d947 1
a947 7
	  if (size_type __n = size())
	    _M_reallocate(__n);
	  else
	    {
	      this->_M_deallocate();
	      this->_M_impl._M_reset();
	    }
@


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.
a64 1
    _GLIBCXX20_CONSTEXPR
a104 1
      _GLIBCXX20_CONSTEXPR
a128 1
    _GLIBCXX20_CONSTEXPR
a169 1
    _GLIBCXX20_CONSTEXPR
a182 1
    _GLIBCXX20_CONSTEXPR
a196 1
    _GLIBCXX20_CONSTEXPR
d201 1
a201 1
      if (std::__addressof(__x) != this)
a255 1
    _GLIBCXX20_CONSTEXPR
a280 1
      _GLIBCXX20_CONSTEXPR
a298 1
      _GLIBCXX20_CONSTEXPR
a338 1
    _GLIBCXX20_CONSTEXPR
a362 1
      _GLIBCXX20_CONSTEXPR
a393 1
      _GLIBCXX20_CONSTEXPR
a424 1
      _GLIBCXX20_CONSTEXPR
a507 1
    _GLIBCXX20_CONSTEXPR
d528 3
a530 3
		  std::__uninitialized_move_a(__old_finish - __n,
					      __old_finish,
					      __old_finish,
d543 1
a543 1
		    std::__uninitialized_fill_n_a(__old_finish,
a557 6
	      // Make local copies of these members because the compiler thinks
	      // the allocator can alter them if 'this' is globally reachable.
	      pointer __old_start = this->_M_impl._M_start;
	      pointer __old_finish = this->_M_impl._M_finish;
	      const pointer __pos = __position.base();

d560 1
a560 1
	      const size_type __elems_before = __pos - __old_start;
d573 2
a574 1
		    (__old_start, __pos, __new_start, _M_get_Tp_allocator());
d580 2
a581 1
		    (__pos, __old_finish, __new_finish, _M_get_Tp_allocator());
d595 2
a596 1
	      std::_Destroy(__old_start, __old_finish, _M_get_Tp_allocator());
d598 3
a600 2
	      _M_deallocate(__old_start,
			    this->_M_impl._M_end_of_storage - __old_start);
a609 1
    _GLIBCXX20_CONSTEXPR
a632 5
	      // Make local copies of these members because the compiler thinks
	      // the allocator can alter them if 'this' is globally reachable.
	      pointer __old_start = this->_M_impl._M_start;
	      pointer __old_finish = this->_M_impl._M_finish;

d648 1
a648 1
		  _S_relocate(__old_start, __old_finish,
d660 1
a660 1
			      __old_start, __old_finish,
d671 1
a671 1
		  std::_Destroy(__old_start, __old_finish,
d675 3
a677 2
	      _M_deallocate(__old_start,
			    this->_M_impl._M_end_of_storage - __old_start);
a685 1
    _GLIBCXX20_CONSTEXPR
a698 1
      _GLIBCXX20_CONSTEXPR
a719 1
      _GLIBCXX20_CONSTEXPR
a766 6
		// Make local copies of these members because the compiler
		// thinks the allocator can alter them if 'this' is globally
		// reachable.
		pointer __old_start = this->_M_impl._M_start;
		pointer __old_finish = this->_M_impl._M_finish;

d775 1
a775 1
		      (__old_start, __position.base(),
d783 1
a783 1
		      (__position.base(), __old_finish,
d793 1
a793 1
		std::_Destroy(__old_start, __old_finish,
d796 3
a798 2
		_M_deallocate(__old_start,
			      this->_M_impl._M_end_of_storage - __old_start);
a808 1
    _GLIBCXX20_CONSTEXPR
a822 1
    _GLIBCXX20_CONSTEXPR
a854 1
      _GLIBCXX20_CONSTEXPR
a888 1
    _GLIBCXX20_CONSTEXPR
a916 1
    _GLIBCXX20_CONSTEXPR
a927 1
    _GLIBCXX20_CONSTEXPR
a938 1
    _GLIBCXX20_CONSTEXPR
d977 3
@


1.1.1.13.2.1
log
@Sync with HEAD
@
text
@a795 2
		if ((__old_finish - __old_start) < 0)
		  __builtin_unreachable();
@


1.1.1.14
log
@initial import of GCC 12.5.0.

this is the final GCC 12 release, and fixes at least 241 specific bugs
in the GCC bugzilla:

   https://gcc.gnu.org/bugzilla/buglist.cgi?bug_status=RESOLVED&resolution=FIXED&target_milestone=12.5

though many are in components we don't ship in base (ada, fortran, etc.)
@
text
@a795 2
		if ((__old_finish - __old_start) < 0)
		  __builtin_unreachable();
@


1.1.1.15
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.
d123 1
a123 1
	  _M_realloc_append(std::forward<_Args>(__args)...);
d142 10
a151 15
	{
	  __glibcxx_assert(__position != const_iterator());
	  if (!(__position != const_iterator()))
	    __builtin_unreachable(); // PR 106434

	  if (__position == end())
	    {
	      _GLIBCXX_ASAN_ANNOTATE_GROW(1);
	      _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
				       __x);
	      ++this->_M_impl._M_finish;
	      _GLIBCXX_ASAN_ANNOTATE_GREW(1);
	    }
	  else
	    {
d153 5
a157 5
	      const auto __pos = begin() + (__position - cbegin());
	      // __x could be an existing element of this vector, so make a
	      // copy of it before _M_insert_aux moves elements around.
	      _Temporary_value __x_copy(this, __x);
	      _M_insert_aux(__pos, std::move(__x_copy._M_val()));
d159 1
a159 1
	      _M_insert_aux(__position, __x);
d161 1
a161 2
	    }
	}
a266 1
      const size_type __sz = size();
a268 2
	  if (__n <= __sz)
	    __builtin_unreachable();
d272 1
a272 1
      else if (__n > __sz)
d275 1
a275 1
	  const size_type __add = __n - __sz;
a312 1
	const size_type __sz = size();
a316 3
	    if (__len <= __sz)
	      __builtin_unreachable();

d329 1
a329 1
	else if (__sz >= __len)
d334 1
a334 1
	    std::advance(__mid, __sz);
d336 1
a336 1
	    const size_type __attribute__((__unused__)) __n = __len - __sz;
d448 2
a449 3
      const size_type __len = _M_check_len(1u, "vector::_M_realloc_insert");
      if (__len <= 0)
	__builtin_unreachable ();
d455 1
a455 15

      // RAII guard for allocated storage.
      struct _Guard
      {
	pointer _M_storage;	    // Storage to deallocate
	size_type _M_len;
	_Tp_alloc_type& _M_alloc;

	_GLIBCXX20_CONSTEXPR
	_Guard(pointer __s, size_type __l, _Tp_alloc_type& __a)
	: _M_storage(__s), _M_len(__l), _M_alloc(__a)
	{ }

	_GLIBCXX20_CONSTEXPR
	~_Guard()
d457 7
a463 19
	  if (_M_storage)
	    __gnu_cxx::__alloc_traits<_Tp_alloc_type>::
	      deallocate(_M_alloc, _M_storage, _M_len);
	}

      private:
	_Guard(const _Guard&);
      };

      {
	_Guard __guard(__new_start, __len, _M_impl);

	// The order of the three operations is dictated by the C++11
	// case, where the moves could alter a new element belonging
	// to the existing vector.  This is an issue only for callers
	// taking the element by lvalue ref (see last bullet of C++11
	// [res.on.arguments]).

	// If this throws, the existing elements are unchanged.
d465 1
a465 3
	_Alloc_traits::construct(this->_M_impl,
				 std::__to_address(__new_start + __elems_before),
				 std::forward<_Args>(__args)...);
d467 1
a467 3
	_Alloc_traits::construct(this->_M_impl,
				 __new_start + __elems_before,
				 __x);
d469 1
d472 1
a472 14
	if _GLIBCXX17_CONSTEXPR (_S_use_relocate())
	  {
	    // Relocation cannot throw.
	    __new_finish = _S_relocate(__old_start, __position.base(),
				       __new_start, _M_get_Tp_allocator());
	    ++__new_finish;
	    __new_finish = _S_relocate(__position.base(), __old_finish,
				       __new_finish, _M_get_Tp_allocator());
	  }
	else
#endif
	  {
	    // RAII type to destroy initialized elements.
	    struct _Guard_elts
d474 2
a475 2
	      pointer _M_first, _M_last;  // Elements to destroy
	      _Tp_alloc_type& _M_alloc;
d477 1
a477 37
	      _GLIBCXX20_CONSTEXPR
	      _Guard_elts(pointer __elt, _Tp_alloc_type& __a)
	      : _M_first(__elt), _M_last(__elt + 1), _M_alloc(__a)
	      { }

	      _GLIBCXX20_CONSTEXPR
	      ~_Guard_elts()
	      { std::_Destroy(_M_first, _M_last, _M_alloc); }

	    private:
	      _Guard_elts(const _Guard_elts&);
	    };

	    // Guard the new element so it will be destroyed if anything throws.
	    _Guard_elts __guard_elts(__new_start + __elems_before, _M_impl);

	    __new_finish = std::__uninitialized_move_if_noexcept_a(
			     __old_start, __position.base(),
			     __new_start, _M_get_Tp_allocator());

	    ++__new_finish;
	    // Guard everything before the new element too.
	    __guard_elts._M_first = __new_start;

	    __new_finish = std::__uninitialized_move_if_noexcept_a(
			      __position.base(), __old_finish,
			      __new_finish, _M_get_Tp_allocator());

	    // New storage has been fully initialized, destroy the old elements.
	    __guard_elts._M_first = __old_start;
	    __guard_elts._M_last = __old_finish;
	  }
	__guard._M_storage = __old_start;
	__guard._M_len = this->_M_impl._M_end_of_storage - __old_start;
      }
      // deallocate should be called before assignments to _M_impl,
      // to avoid call-clobbering
d479 4
a482 17
      this->_M_impl._M_start = __new_start;
      this->_M_impl._M_finish = __new_finish;
      this->_M_impl._M_end_of_storage = __new_start + __len;
    }

#if __cplusplus >= 201103L
  template<typename _Tp, typename _Alloc>
    template<typename... _Args>
      _GLIBCXX20_CONSTEXPR
      void
      vector<_Tp, _Alloc>::
      _M_realloc_append(_Args&&... __args)
#else
  template<typename _Tp, typename _Alloc>
    void
    vector<_Tp, _Alloc>::
    _M_realloc_append(const _Tp& __x)
d484 15
a498 24
    {
      const size_type __len = _M_check_len(1u, "vector::_M_realloc_append");
      if (__len <= 0)
	__builtin_unreachable ();
      pointer __old_start = this->_M_impl._M_start;
      pointer __old_finish = this->_M_impl._M_finish;
      const size_type __elems = end() - begin();
      pointer __new_start(this->_M_allocate(__len));
      pointer __new_finish(__new_start);

      // RAII guard for allocated storage.
      struct _Guard
      {
	pointer _M_storage;	    // Storage to deallocate
	size_type _M_len;
	_Tp_alloc_type& _M_alloc;

	_GLIBCXX20_CONSTEXPR
	_Guard(pointer __s, size_type __l, _Tp_alloc_type& __a)
	: _M_storage(__s), _M_len(__l), _M_alloc(__a)
	{ }

	_GLIBCXX20_CONSTEXPR
	~_Guard()
d500 7
a506 3
	  if (_M_storage)
	    __gnu_cxx::__alloc_traits<_Tp_alloc_type>::
	      deallocate(_M_alloc, _M_storage, _M_len);
a507 15

      private:
	_Guard(const _Guard&);
      };

      {
	_Guard __guard(__new_start, __len, _M_impl);

	// The order of the three operations is dictated by the C++11
	// case, where the moves could alter a new element belonging
	// to the existing vector.  This is an issue only for callers
	// taking the element by lvalue ref (see last bullet of C++11
	// [res.on.arguments]).

	// If this throws, the existing elements are unchanged.
d509 1
a509 7
	_Alloc_traits::construct(this->_M_impl,
				 std::__to_address(__new_start + __elems),
				 std::forward<_Args>(__args)...);
#else
	_Alloc_traits::construct(this->_M_impl,
				 __new_start + __elems,
				 __x);
d511 4
a514 50

#if __cplusplus >= 201103L
	if _GLIBCXX17_CONSTEXPR (_S_use_relocate())
	  {
	    // Relocation cannot throw.
	    __new_finish = _S_relocate(__old_start, __old_finish,
				       __new_start, _M_get_Tp_allocator());
	    ++__new_finish;
	  }
	else
#endif
	  {
	    // RAII type to destroy initialized elements.
	    struct _Guard_elts
	    {
	      pointer _M_first, _M_last;  // Elements to destroy
	      _Tp_alloc_type& _M_alloc;

	      _GLIBCXX20_CONSTEXPR
	      _Guard_elts(pointer __elt, _Tp_alloc_type& __a)
	      : _M_first(__elt), _M_last(__elt + 1), _M_alloc(__a)
	      { }

	      _GLIBCXX20_CONSTEXPR
	      ~_Guard_elts()
	      { std::_Destroy(_M_first, _M_last, _M_alloc); }

	    private:
	      _Guard_elts(const _Guard_elts&);
	    };

	    // Guard the new element so it will be destroyed if anything throws.
	    _Guard_elts __guard_elts(__new_start + __elems, _M_impl);

	    __new_finish = std::__uninitialized_move_if_noexcept_a(
			     __old_start, __old_finish,
			     __new_start, _M_get_Tp_allocator());

	    ++__new_finish;

	    // New storage has been fully initialized, destroy the old elements.
	    __guard_elts._M_first = __old_start;
	    __guard_elts._M_last = __old_finish;
	  }
	__guard._M_storage = __old_start;
	__guard._M_len = this->_M_impl._M_end_of_storage - __old_start;
      }
      // deallocate should be called before assignments to _M_impl,
      // to avoid call-clobbering

a641 3
	      if (!this->_M_impl._M_finish)
		__builtin_unreachable();

d658 1
a658 15

	      // RAII guard for allocated storage.
	      struct _Guard
	      {
		pointer _M_storage;         // Storage to deallocate
		size_type _M_len;
		_Tp_alloc_type& _M_alloc;

		_GLIBCXX20_CONSTEXPR
		_Guard(pointer __s, size_type __l, _Tp_alloc_type& __a)
		: _M_storage(__s), _M_len(__l), _M_alloc(__a)
		{ }

		_GLIBCXX20_CONSTEXPR
		~_Guard()
d660 12
a671 3
		  if (_M_storage)
		    __gnu_cxx::__alloc_traits<_Tp_alloc_type>::
		      deallocate(_M_alloc, _M_storage, _M_len);
d673 13
a685 20

	      private:
		_Guard(const _Guard&);
	      };

	      {
		_Guard __guard(__new_start, __len, _M_impl);

		std::__uninitialized_default_n_a(__new_start + __size, __n,
						 _M_get_Tp_allocator());

		if _GLIBCXX17_CONSTEXPR (_S_use_relocate())
		  {
		    _S_relocate(__old_start, __old_finish,
				__new_start, _M_get_Tp_allocator());
		  }
		else
		  {
		    // RAII type to destroy initialized elements.
		    struct _Guard_elts
d687 12
a698 32
		      pointer _M_first, _M_last;  // Elements to destroy
		      _Tp_alloc_type& _M_alloc;

		      _GLIBCXX20_CONSTEXPR
		      _Guard_elts(pointer __first, size_type __n,
				  _Tp_alloc_type& __a)
		      : _M_first(__first), _M_last(__first + __n), _M_alloc(__a)
		      { }

		      _GLIBCXX20_CONSTEXPR
		      ~_Guard_elts()
		      { std::_Destroy(_M_first, _M_last, _M_alloc); }

		    private:
		      _Guard_elts(const _Guard_elts&);
		    };
		    _Guard_elts __guard_elts(__new_start + __size, __n, _M_impl);

		    std::__uninitialized_move_if_noexcept_a(
		      __old_start, __old_finish, __new_start,
		      _M_get_Tp_allocator());

		    __guard_elts._M_first = __old_start;
		    __guard_elts._M_last = __old_finish;
		  }
		_GLIBCXX_ASAN_ANNOTATE_REINIT;
		__guard._M_storage = __old_start;
		__guard._M_len = this->_M_impl._M_end_of_storage - __old_start;
	      }
	      // deallocate should be called before assignments to _M_impl,
	      // to avoid call-clobbering

a800 5
#if __cplusplus < 201103L
		if (__len < (__n + (__old_finish - __old_start)))
		  __builtin_unreachable();
#endif

a844 3
      const iterator __begin = begin(), __end = end();
      if (size_type(__end - __begin) > __n)
	__builtin_unreachable();
d847 1
a847 1
      iterator __finish(_M_copy_aligned(__begin, __end, __start));
a872 1
	  iterator __begin = begin(), __end = end();
d875 1
a875 1
	  iterator __i = _M_copy_aligned(__begin, __position, __start);
d877 1
a877 1
	  iterator __finish = std::copy(__position, __end,
a908 1
		const iterator __begin = begin(), __end = end();
d911 1
a911 1
		iterator __i = _M_copy_aligned(__begin, __position, __start);
d913 1
a913 1
		iterator __finish = std::copy(__position, __end, __i);
@


1.1.1.16
log
@initial import of GCC 14.4.0 sources.

changes include fixes for at least 113 GCC bugs.  the ones found
to be interesting include:

122943 - Wrong code for switch on int64_t on ilp32 targets at -O2 since r14-8302
123271 - -ftrapv fails to detect overflow on ARM32 since GCC 10 since r10-3995

and there are a lot of less scary ICE and runtime fixes.

mknative-gcc coming up next.
@
text
@d705 2
a706 4
	  if (__position.base() == this->_M_impl._M_finish)
	    _M_fill_append(__n, __x);
	  else if (size_type(this->_M_impl._M_end_of_storage
			       - this->_M_impl._M_finish) >= __n)
a800 54
  template<typename _Tp, typename _Alloc>
    _GLIBCXX20_CONSTEXPR
    void
    vector<_Tp, _Alloc>::
    _M_fill_append(size_type __n, const value_type& __x)
    {
       if (size_type(this->_M_impl._M_end_of_storage
		     - this->_M_impl._M_finish) >= __n)
	 {
	   _GLIBCXX_ASAN_ANNOTATE_GROW(__n);
	   this->_M_impl._M_finish =
	     std::__uninitialized_fill_n_a(this->_M_impl._M_finish, __n, __x,
					   _M_get_Tp_allocator());
	   _GLIBCXX_ASAN_ANNOTATE_GREW(__n);
	 }
       else
	 {
	   // Make local copies of these members because the compiler thinks
	   // the allocator can alter them if 'this' is globally reachable.
	   pointer __old_start = this->_M_impl._M_start;
	   pointer __old_finish = this->_M_impl._M_finish;
	   const size_type __old_size = __old_finish - __old_start;

	   const size_type __len =
	     _M_check_len(__n, "vector::_M_fill_append");
	   pointer __new_start(this->_M_allocate(__len));
	   pointer __new_finish(__new_start + __old_size);
	   __try
	     {
	       // See _M_realloc_insert above.
	       __new_finish = std::__uninitialized_fill_n_a(
				__new_finish, __n, __x,
				_M_get_Tp_allocator());
	       std::__uninitialized_move_if_noexcept_a(
		 __old_start, __old_finish, __new_start,
		 _M_get_Tp_allocator());
	     }
	   __catch(...)
	     {
		std::_Destroy(__new_start + __old_size, __new_finish,
			      _M_get_Tp_allocator());
		_M_deallocate(__new_start, __len);
		__throw_exception_again;
	      }
	   std::_Destroy(__old_start, __old_finish, _M_get_Tp_allocator());
	   _GLIBCXX_ASAN_ANNOTATE_REINIT;
	   _M_deallocate(__old_start,
			 this->_M_impl._M_end_of_storage - __old_start);
	   this->_M_impl._M_start = __new_start;
	   this->_M_impl._M_finish = __new_finish;
	   this->_M_impl._M_end_of_storage = __new_start + __len;
	 }
    }

@


