2001-06-27 19:09:53 +02:00
|
|
|
// Iterators -*- C++ -*-
|
|
|
|
|
2011-08-30 17:34:50 +02:00
|
|
|
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
2012-01-14 18:47:18 +01:00
|
|
|
// 2010, 2011, 2012
|
2006-09-18 15:30:56 +02:00
|
|
|
// Free Software Foundation, Inc.
|
2001-06-27 19:09:53 +02:00
|
|
|
//
|
|
|
|
// 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
|
2009-04-09 17:00:19 +02:00
|
|
|
// Free Software Foundation; either version 3, or (at your option)
|
2001-06-27 19:09:53 +02:00
|
|
|
// 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.
|
|
|
|
|
2009-04-09 17:00:19 +02:00
|
|
|
// 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.
|
2001-06-27 19:09:53 +02:00
|
|
|
|
2009-04-09 17:00:19 +02:00
|
|
|
// 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/>.
|
2001-06-27 19:09:53 +02:00
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* 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-1998
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2010-12-19 10:21:16 +01:00
|
|
|
/** @file bits/stl_iterator.h
|
c_io_stdio.h: Correct grammar in comments.
2001-11-02 Phil Edwards <pme@gcc.gnu.org>
* config/io/c_io_stdio.h: Correct grammar in comments.
* docs/doxygen/Intro.3: Expand "top-level" man page.
* docs/doxygen/doxygroups.cc: New module definitions (comments).
* docs/doxygen/mainpage.doxy: Tweaks.
* docs/doxygen/run_doxygen: Update Doxygen version, massage man pages.
Add @file hooks so that headers are considered to be documented.
* include/bits/basic_ios.h, include/bits/basic_file.h,
include/bits/basic_string.h, include/bits/boost_concept_check.h,
include/bits/char_traits.h, include/bits/codecvt.h,
include/bits/concept_check.h, include/bits/cpp_type_traits.h,
include/bits/fpos.h, include/bits/gslice.h, include/bits/gslice_array.h,
include/bits/indirect_array.h, include/bits/ios_base.h,
include/bits/locale_facets.h, include/bits/localefwd.h,
include/bits/mask_array.h, include/bits/pthread_allocimpl.h,
include/bits/slice.h, include/bits/slice_array.h,
include/bits/std_algorithm.h, include/bits/std_bitset.h,
include/bits/std_complex.h, include/bits/std_deque.h,
include/bits/std_fstream.h, include/bits/std_functional.h,
include/bits/std_iomanip.h, include/bits/std_ios.h,
include/bits/std_iosfwd.h, include/bits/std_iostream.h,
include/bits/std_istream.h, include/bits/std_iterator.h,
include/bits/std_limits.h, include/bits/std_list.h,
include/bits/std_locale.h, include/bits/std_map.h,
include/bits/std_memory.h, include/bits/std_numeric.h,
include/bits/std_ostream.h, include/bits/std_queue.h,
include/bits/std_set.h, include/bits/std_sstream.h,
include/bits/std_stack.h, include/bits/std_streambuf.h,
include/bits/std_string.h, include/bits/std_utility.h,
include/bits/std_valarray.h, include/bits/std_vector.h,
include/bits/stl_algo.h, include/bits/stl_alloc.h,
include/bits/stl_bvector.h, include/bits/stl_construct.h,
include/bits/stl_deque.h, include/bits/stl_heap.h,
include/bits/stl_iterator.h, include/bits/stl_iterator_base_funcs.h,
include/bits/stl_iterator_base_types.h, include/bits/stl_list.h,
include/bits/stl_map.h, include/bits/stl_multimap.h,
include/bits/stl_multiset.h, include/bits/stl_numeric.h,
include/bits/stl_pair.h, include/bits/stl_pthread_alloc.h,
include/bits/stl_queue.h, include/bits/stl_raw_storage_iter.h,
include/bits/stl_relops.h, include/bits/stl_set.h,
include/bits/stl_stack.h, include/bits/stl_tempbuf.h,
include/bits/stl_threads.h, include/bits/stl_tree.h,
include/bits/stl_uninitialized.h, include/bits/stl_vector.h,
include/bits/stream_iterator.h, include/bits/streambuf_iterator.h,
include/bits/stringfwd.h, include/bits/type_traits.h,
include/bits/valarray_array.h, include/bits/valarray_meta.h:
Add hooks, tweak comments only.
* include/bits/stl_algobase.h (swap, min, iter_swap): Also
document these functions.
* include/bits/stl_function.h: Tweak link comments.
From-SVN: r46717
2001-11-02 18:38:11 +01:00
|
|
|
* This is an internal header file, included by other library headers.
|
2010-12-19 10:21:16 +01:00
|
|
|
* Do not attempt to use it directly. @headername{iterator}
|
2002-02-08 08:34:54 +01:00
|
|
|
*
|
|
|
|
* This file implements reverse_iterator, back_insert_iterator,
|
|
|
|
* front_insert_iterator, insert_iterator, __normal_iterator, and their
|
|
|
|
* supporting functions and overloaded operators.
|
2000-10-05 13:27:02 +02:00
|
|
|
*/
|
|
|
|
|
2007-06-18 19:22:53 +02:00
|
|
|
#ifndef _STL_ITERATOR_H
|
|
|
|
#define _STL_ITERATOR_H 1
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2005-09-12 11:42:34 +02:00
|
|
|
#include <bits/cpp_type_traits.h>
|
2006-09-18 15:30:56 +02:00
|
|
|
#include <ext/type_traits.h>
|
2008-06-21 18:55:17 +02:00
|
|
|
#include <bits/move.h>
|
2005-09-12 11:42:34 +02:00
|
|
|
|
PR libstdc++/36104 part four
2011-01-30 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/36104 part four
* include/bits/c++config (_GLIBCXX_STD): Remove.
(_GLIBCXX_STD_D, _GLIBCXX_PR): Now _GLIBCXX_STD_C.
(_GLIBCXX_P): Now _GLIBCXX_STD_A.
(_GLIBCXX_NAMESPACE_DEBUG, _GLIBCXX_NAMESPACE_PARALLEL,
_GLIBCXX_NAMESPACE_PROFILE, _GLIBCXX_NAMESPACE_VERSION): Remove.
(_GLIBCXX_INLINE_DEBUG, _GLIBCXX_INLINE_PARALLEL,
_GLIBCXX_INLINE_PROFILE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE(X)): Remove.
(_GLIBCXX_END_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NESTED_NAMESPACE(X, Y)): Remove.
(_GLIBCXX_END_NESTED_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE_ALGO): Add.
(_GLIBCXX_END_NAMESPACE_ALGO): Add.
(_GLIBCXX_BEGIN_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_END_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_BEGIN_NAMESPACE_VERSION): Add.
(_GLIBCXX_END_NAMESPACE_VERSION): Add.
(_GLIBCXX_BEGIN_LDBL_NAMESPACE): To _GLIBCXX_BEGIN_NAMESPACE_LDBL.
(_GLIBCXX_END_LDBL_NAMESPACE): To _GLIBCXX_END_NAMESPACE_LDBL.
(_GLIBCXX_VISIBILITY_ATTR): Revert to _GLIBCXX_VISIBILITY.
* include/*: Use new macros for namespace scope.
* config/*: Same.
* src/*: Same.
* src/Makefile.am (sources): Remove debug_list.cc, add
compatibility-debug_list-2.cc.
(parallel_sources): Remove parallel_list.cc, add
compatibility-parallel_list-2.cc.
(compatibility-parallel_list-2.[o,lo]): New rule.
* src/Makefile.in: Regenerate.
* src/debug_list.cc: Remove.
* src/parallel_list.cc: Remove.
* src/compatibility-list-2.cc: New.
* src/compatibility-debug_list-2.cc: New.
* src/compatibility-parallel_list-2.cc: New.
* doc/doxygen/user.cfg.in: Adjust macros.
* testsuite/20_util/auto_ptr/assign_neg.cc: Adjust line numbers, macros.
* testsuite/20_util/declval/requirements/1_neg.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg1.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg2.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg3.cc: Same.
* testsuite/20_util/forward/c_neg.cc: Same.
* testsuite/20_util/forward/f_neg.cc: Same.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Same.
* testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Same.
* testsuite/20_util/shared_ptr/cons/43820_neg.cc: Same.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/forward_list/capacity/1.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
assign_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
insert_neg.cc: Same.
* testsuite/23_containers/list/capacity/29134.cc: Same.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/vector/bool/capacity/29134.cc: Same.
* testsuite/23_containers/vector/bool/modifiers/insert/31370.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc: Same.
* testsuite/25_algorithms/sort/35588.cc: Same.
* testsuite/27_io/ios_base/cons/assign_neg.cc: Same.
* testsuite/27_io/ios_base/cons/copy_neg.cc: Same.
* testsuite/ext/profile/mutex_extensions_neg.cc: Same.
* testsuite/ext/profile/profiler_algos.cc: Same.
* testsuite/ext/type_traits/add_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/add_unsigned_integer_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_integer_neg.cc: Same.
* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc: Same.
From-SVN: r169421
2011-01-30 23:39:36 +01:00
|
|
|
namespace std _GLIBCXX_VISIBILITY(default)
|
|
|
|
{
|
|
|
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
2005-12-19 01:56:05 +01:00
|
|
|
|
2009-11-06 23:15:17 +01:00
|
|
|
/**
|
|
|
|
* @addtogroup iterators
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2001-06-23 02:08:47 +02:00
|
|
|
// 24.4.1 Reverse iterators
|
2002-02-08 08:34:54 +01:00
|
|
|
/**
|
2009-12-30 11:34:41 +01:00
|
|
|
* Bidirectional and random access iterators have corresponding reverse
|
2002-02-08 08:34:54 +01:00
|
|
|
* %iterator adaptors that iterate through the data structure in the
|
|
|
|
* opposite direction. They have the same signatures as the corresponding
|
|
|
|
* iterators. The fundamental relation between a reverse %iterator and its
|
|
|
|
* corresponding %iterator @c i is established by the identity:
|
|
|
|
* @code
|
|
|
|
* &*(reverse_iterator(i)) == &*(i - 1)
|
|
|
|
* @endcode
|
|
|
|
*
|
2010-02-04 19:20:34 +01:00
|
|
|
* <em>This mapping is dictated by the fact that while there is always a
|
2002-02-08 08:34:54 +01:00
|
|
|
* pointer past the end of an array, there might not be a valid pointer
|
2010-02-04 19:20:34 +01:00
|
|
|
* before the beginning of an array.</em> [24.4.1]/1,2
|
2002-02-08 08:34:54 +01:00
|
|
|
*
|
|
|
|
* Reverse iterators can be tricky and surprising at first. Their
|
|
|
|
* semantics make sense, however, and the trickiness is a side effect of
|
|
|
|
* the requirement that the iterators must be safe.
|
|
|
|
*/
|
2001-06-26 09:01:09 +02:00
|
|
|
template<typename _Iterator>
|
2004-02-08 05:46:42 +01:00
|
|
|
class reverse_iterator
|
2001-12-26 22:56:17 +01:00
|
|
|
: public iterator<typename iterator_traits<_Iterator>::iterator_category,
|
|
|
|
typename iterator_traits<_Iterator>::value_type,
|
|
|
|
typename iterator_traits<_Iterator>::difference_type,
|
|
|
|
typename iterator_traits<_Iterator>::pointer,
|
|
|
|
typename iterator_traits<_Iterator>::reference>
|
2001-06-23 02:08:47 +02:00
|
|
|
{
|
|
|
|
protected:
|
2002-01-17 04:59:42 +01:00
|
|
|
_Iterator current;
|
2001-06-23 02:08:47 +02:00
|
|
|
|
2009-11-06 23:15:17 +01:00
|
|
|
typedef iterator_traits<_Iterator> __traits_type;
|
2001-06-23 02:08:47 +02:00
|
|
|
|
|
|
|
public:
|
2009-11-06 23:15:17 +01:00
|
|
|
typedef _Iterator iterator_type;
|
|
|
|
typedef typename __traits_type::difference_type difference_type;
|
|
|
|
typedef typename __traits_type::pointer pointer;
|
|
|
|
typedef typename __traits_type::reference reference;
|
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/**
|
2012-01-14 18:47:18 +01:00
|
|
|
* The default constructor value-initializes member @p current.
|
2003-06-06 19:19:56 +02:00
|
|
|
* If it is a pointer, that means it is zero-initialized.
|
2002-02-08 08:34:54 +01:00
|
|
|
*/
|
2003-07-05 06:05:45 +02:00
|
|
|
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
2003-06-06 19:19:56 +02:00
|
|
|
// 235 No specification of default ctor for reverse_iterator
|
|
|
|
reverse_iterator() : current() { }
|
2001-06-23 02:08:47 +02:00
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/**
|
|
|
|
* This %iterator will move in the opposite direction that @p x does.
|
|
|
|
*/
|
2004-02-08 05:46:42 +01:00
|
|
|
explicit
|
2002-01-17 04:59:42 +01:00
|
|
|
reverse_iterator(iterator_type __x) : current(__x) { }
|
2001-06-23 02:08:47 +02:00
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/**
|
|
|
|
* The copy constructor is normal.
|
|
|
|
*/
|
2004-02-08 05:46:42 +01:00
|
|
|
reverse_iterator(const reverse_iterator& __x)
|
2002-01-17 04:59:42 +01:00
|
|
|
: current(__x.current) { }
|
2001-06-23 02:08:47 +02:00
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/**
|
2012-01-14 18:47:18 +01:00
|
|
|
* A %reverse_iterator across other types can be copied if the
|
|
|
|
* underlying %iterator can be converted to the type of @c current.
|
2002-02-08 08:34:54 +01:00
|
|
|
*/
|
2001-06-26 09:01:09 +02:00
|
|
|
template<typename _Iter>
|
2001-06-23 02:08:47 +02:00
|
|
|
reverse_iterator(const reverse_iterator<_Iter>& __x)
|
2002-01-17 04:59:42 +01:00
|
|
|
: current(__x.base()) { }
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/**
|
|
|
|
* @return @c current, the %iterator used for underlying work.
|
|
|
|
*/
|
2004-02-08 05:46:42 +01:00
|
|
|
iterator_type
|
2004-02-01 18:34:44 +01:00
|
|
|
base() const
|
|
|
|
{ return current; }
|
2001-06-23 02:08:47 +02:00
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/**
|
2012-01-14 18:47:18 +01:00
|
|
|
* @return A reference to the value at @c --current
|
2002-02-08 08:34:54 +01:00
|
|
|
*
|
2012-01-14 18:47:18 +01:00
|
|
|
* This requires that @c --current is dereferenceable.
|
|
|
|
*
|
|
|
|
* @warning This implementation requires that for an iterator of the
|
|
|
|
* underlying iterator type, @c x, a reference obtained by
|
|
|
|
* @c *x remains valid after @c x has been modified or
|
|
|
|
* destroyed. This is a bug: http://gcc.gnu.org/PR51823
|
2002-02-08 08:34:54 +01:00
|
|
|
*/
|
2004-02-08 05:46:42 +01:00
|
|
|
reference
|
|
|
|
operator*() const
|
2001-06-23 02:08:47 +02:00
|
|
|
{
|
2002-01-17 04:59:42 +01:00
|
|
|
_Iterator __tmp = current;
|
2001-06-23 02:08:47 +02:00
|
|
|
return *--__tmp;
|
|
|
|
}
|
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/**
|
2012-01-14 18:47:18 +01:00
|
|
|
* @return A pointer to the value at @c --current
|
2002-02-08 08:34:54 +01:00
|
|
|
*
|
2012-01-14 18:47:18 +01:00
|
|
|
* This requires that @c --current is dereferenceable.
|
2002-02-08 08:34:54 +01:00
|
|
|
*/
|
2004-02-08 05:46:42 +01:00
|
|
|
pointer
|
2004-02-01 18:34:44 +01:00
|
|
|
operator->() const
|
|
|
|
{ return &(operator*()); }
|
2001-06-23 02:08:47 +02:00
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/**
|
2012-01-14 18:47:18 +01:00
|
|
|
* @return @c *this
|
2002-02-08 08:34:54 +01:00
|
|
|
*
|
2012-01-14 18:47:18 +01:00
|
|
|
* Decrements the underlying iterator.
|
2002-02-08 08:34:54 +01:00
|
|
|
*/
|
2004-02-08 05:46:42 +01:00
|
|
|
reverse_iterator&
|
|
|
|
operator++()
|
2001-06-23 02:08:47 +02:00
|
|
|
{
|
2002-01-17 04:59:42 +01:00
|
|
|
--current;
|
2001-06-23 02:08:47 +02:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/**
|
2012-01-14 18:47:18 +01:00
|
|
|
* @return The original value of @c *this
|
2002-02-08 08:34:54 +01:00
|
|
|
*
|
2012-01-14 18:47:18 +01:00
|
|
|
* Decrements the underlying iterator.
|
2002-02-08 08:34:54 +01:00
|
|
|
*/
|
2004-02-08 05:46:42 +01:00
|
|
|
reverse_iterator
|
|
|
|
operator++(int)
|
2001-06-23 02:08:47 +02:00
|
|
|
{
|
2001-06-26 09:01:09 +02:00
|
|
|
reverse_iterator __tmp = *this;
|
2002-01-17 04:59:42 +01:00
|
|
|
--current;
|
2001-06-23 02:08:47 +02:00
|
|
|
return __tmp;
|
|
|
|
}
|
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/**
|
2012-01-14 18:47:18 +01:00
|
|
|
* @return @c *this
|
2002-02-08 08:34:54 +01:00
|
|
|
*
|
2012-01-14 18:47:18 +01:00
|
|
|
* Increments the underlying iterator.
|
2002-02-08 08:34:54 +01:00
|
|
|
*/
|
2004-02-08 05:46:42 +01:00
|
|
|
reverse_iterator&
|
|
|
|
operator--()
|
2001-06-23 02:08:47 +02:00
|
|
|
{
|
2002-01-17 04:59:42 +01:00
|
|
|
++current;
|
2001-06-23 02:08:47 +02:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/**
|
2012-01-14 18:47:18 +01:00
|
|
|
* @return A reverse_iterator with the previous value of @c *this
|
2002-02-08 08:34:54 +01:00
|
|
|
*
|
2012-01-14 18:47:18 +01:00
|
|
|
* Increments the underlying iterator.
|
2002-02-08 08:34:54 +01:00
|
|
|
*/
|
2005-10-05 17:49:39 +02:00
|
|
|
reverse_iterator
|
|
|
|
operator--(int)
|
2001-06-23 02:08:47 +02:00
|
|
|
{
|
2001-06-26 09:01:09 +02:00
|
|
|
reverse_iterator __tmp = *this;
|
2002-01-17 04:59:42 +01:00
|
|
|
++current;
|
2001-06-23 02:08:47 +02:00
|
|
|
return __tmp;
|
|
|
|
}
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/**
|
2012-01-14 18:47:18 +01:00
|
|
|
* @return A reverse_iterator that refers to @c current - @a __n
|
2002-02-08 08:34:54 +01:00
|
|
|
*
|
2012-01-14 18:47:18 +01:00
|
|
|
* The underlying iterator must be a Random Access Iterator.
|
2002-02-08 08:34:54 +01:00
|
|
|
*/
|
2004-02-08 05:46:42 +01:00
|
|
|
reverse_iterator
|
|
|
|
operator+(difference_type __n) const
|
2002-01-17 04:59:42 +01:00
|
|
|
{ return reverse_iterator(current - __n); }
|
2001-06-23 02:08:47 +02:00
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/**
|
2012-01-14 18:47:18 +01:00
|
|
|
* @return *this
|
2002-02-08 08:34:54 +01:00
|
|
|
*
|
2012-01-14 18:47:18 +01:00
|
|
|
* Moves the underlying iterator backwards @a __n steps.
|
|
|
|
* The underlying iterator must be a Random Access Iterator.
|
2002-02-08 08:34:54 +01:00
|
|
|
*/
|
2004-02-08 05:46:42 +01:00
|
|
|
reverse_iterator&
|
|
|
|
operator+=(difference_type __n)
|
2001-06-23 02:08:47 +02:00
|
|
|
{
|
2002-01-17 04:59:42 +01:00
|
|
|
current -= __n;
|
2001-06-23 02:08:47 +02:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/**
|
2012-01-14 18:47:18 +01:00
|
|
|
* @return A reverse_iterator that refers to @c current - @a __n
|
2002-02-08 08:34:54 +01:00
|
|
|
*
|
2012-01-14 18:47:18 +01:00
|
|
|
* The underlying iterator must be a Random Access Iterator.
|
2002-02-08 08:34:54 +01:00
|
|
|
*/
|
2004-02-08 05:46:42 +01:00
|
|
|
reverse_iterator
|
|
|
|
operator-(difference_type __n) const
|
2002-01-17 04:59:42 +01:00
|
|
|
{ return reverse_iterator(current + __n); }
|
2001-06-23 02:08:47 +02:00
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/**
|
2012-01-14 18:47:18 +01:00
|
|
|
* @return *this
|
2002-02-08 08:34:54 +01:00
|
|
|
*
|
2012-01-14 18:47:18 +01:00
|
|
|
* Moves the underlying iterator forwards @a __n steps.
|
|
|
|
* The underlying iterator must be a Random Access Iterator.
|
2002-02-08 08:34:54 +01:00
|
|
|
*/
|
2004-02-08 05:46:42 +01:00
|
|
|
reverse_iterator&
|
|
|
|
operator-=(difference_type __n)
|
2001-06-23 02:08:47 +02:00
|
|
|
{
|
2002-01-17 04:59:42 +01:00
|
|
|
current += __n;
|
2001-06-23 02:08:47 +02:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/**
|
2012-01-14 18:47:18 +01:00
|
|
|
* @return The value at @c current - @a __n - 1
|
2002-02-08 08:34:54 +01:00
|
|
|
*
|
2012-01-14 18:47:18 +01:00
|
|
|
* The underlying iterator must be a Random Access Iterator.
|
2002-02-08 08:34:54 +01:00
|
|
|
*/
|
2004-02-08 05:46:42 +01:00
|
|
|
reference
|
2004-02-01 18:34:44 +01:00
|
|
|
operator[](difference_type __n) const
|
2004-02-08 05:46:42 +01:00
|
|
|
{ return *(*this + __n); }
|
|
|
|
};
|
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
//@{
|
|
|
|
/**
|
2011-08-07 09:27:06 +02:00
|
|
|
* @param __x A %reverse_iterator.
|
|
|
|
* @param __y A %reverse_iterator.
|
2002-02-08 08:34:54 +01:00
|
|
|
* @return A simple bool.
|
|
|
|
*
|
|
|
|
* Reverse iterators forward many operations to their underlying base()
|
|
|
|
* iterators. Others are implemented in terms of one another.
|
|
|
|
*
|
|
|
|
*/
|
2001-06-26 09:01:09 +02:00
|
|
|
template<typename _Iterator>
|
2004-02-08 05:46:42 +01:00
|
|
|
inline bool
|
|
|
|
operator==(const reverse_iterator<_Iterator>& __x,
|
|
|
|
const reverse_iterator<_Iterator>& __y)
|
2001-06-23 02:08:47 +02:00
|
|
|
{ return __x.base() == __y.base(); }
|
|
|
|
|
2001-06-26 09:01:09 +02:00
|
|
|
template<typename _Iterator>
|
2004-02-08 05:46:42 +01:00
|
|
|
inline bool
|
|
|
|
operator<(const reverse_iterator<_Iterator>& __x,
|
|
|
|
const reverse_iterator<_Iterator>& __y)
|
2001-06-23 02:08:47 +02:00
|
|
|
{ return __y.base() < __x.base(); }
|
|
|
|
|
2001-06-26 09:01:09 +02:00
|
|
|
template<typename _Iterator>
|
2004-02-08 05:46:42 +01:00
|
|
|
inline bool
|
|
|
|
operator!=(const reverse_iterator<_Iterator>& __x,
|
|
|
|
const reverse_iterator<_Iterator>& __y)
|
2001-06-23 02:08:47 +02:00
|
|
|
{ return !(__x == __y); }
|
|
|
|
|
2001-06-26 09:01:09 +02:00
|
|
|
template<typename _Iterator>
|
2004-02-08 05:46:42 +01:00
|
|
|
inline bool
|
|
|
|
operator>(const reverse_iterator<_Iterator>& __x,
|
|
|
|
const reverse_iterator<_Iterator>& __y)
|
2001-06-23 02:08:47 +02:00
|
|
|
{ return __y < __x; }
|
|
|
|
|
2001-06-26 09:01:09 +02:00
|
|
|
template<typename _Iterator>
|
2004-02-08 05:46:42 +01:00
|
|
|
inline bool
|
|
|
|
operator<=(const reverse_iterator<_Iterator>& __x,
|
2005-10-05 17:49:39 +02:00
|
|
|
const reverse_iterator<_Iterator>& __y)
|
2001-06-23 02:08:47 +02:00
|
|
|
{ return !(__y < __x); }
|
|
|
|
|
2001-06-26 09:01:09 +02:00
|
|
|
template<typename _Iterator>
|
2004-02-08 05:46:42 +01:00
|
|
|
inline bool
|
|
|
|
operator>=(const reverse_iterator<_Iterator>& __x,
|
|
|
|
const reverse_iterator<_Iterator>& __y)
|
2001-06-23 02:08:47 +02:00
|
|
|
{ return !(__x < __y); }
|
|
|
|
|
2001-06-26 09:01:09 +02:00
|
|
|
template<typename _Iterator>
|
2001-06-23 02:08:47 +02:00
|
|
|
inline typename reverse_iterator<_Iterator>::difference_type
|
2004-02-08 05:46:42 +01:00
|
|
|
operator-(const reverse_iterator<_Iterator>& __x,
|
|
|
|
const reverse_iterator<_Iterator>& __y)
|
2001-06-23 02:08:47 +02:00
|
|
|
{ return __y.base() - __x.base(); }
|
|
|
|
|
2001-06-26 09:01:09 +02:00
|
|
|
template<typename _Iterator>
|
2004-02-08 05:46:42 +01:00
|
|
|
inline reverse_iterator<_Iterator>
|
2001-06-23 02:08:47 +02:00
|
|
|
operator+(typename reverse_iterator<_Iterator>::difference_type __n,
|
2004-02-08 05:46:42 +01:00
|
|
|
const reverse_iterator<_Iterator>& __x)
|
2001-06-23 02:08:47 +02:00
|
|
|
{ return reverse_iterator<_Iterator>(__x.base() - __n); }
|
2005-10-05 17:49:39 +02:00
|
|
|
|
|
|
|
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
|
|
// DR 280. Comparison of reverse_iterator to const reverse_iterator.
|
|
|
|
template<typename _IteratorL, typename _IteratorR>
|
|
|
|
inline bool
|
|
|
|
operator==(const reverse_iterator<_IteratorL>& __x,
|
|
|
|
const reverse_iterator<_IteratorR>& __y)
|
|
|
|
{ return __x.base() == __y.base(); }
|
|
|
|
|
|
|
|
template<typename _IteratorL, typename _IteratorR>
|
|
|
|
inline bool
|
|
|
|
operator<(const reverse_iterator<_IteratorL>& __x,
|
|
|
|
const reverse_iterator<_IteratorR>& __y)
|
|
|
|
{ return __y.base() < __x.base(); }
|
|
|
|
|
|
|
|
template<typename _IteratorL, typename _IteratorR>
|
|
|
|
inline bool
|
|
|
|
operator!=(const reverse_iterator<_IteratorL>& __x,
|
|
|
|
const reverse_iterator<_IteratorR>& __y)
|
|
|
|
{ return !(__x == __y); }
|
|
|
|
|
|
|
|
template<typename _IteratorL, typename _IteratorR>
|
|
|
|
inline bool
|
|
|
|
operator>(const reverse_iterator<_IteratorL>& __x,
|
|
|
|
const reverse_iterator<_IteratorR>& __y)
|
|
|
|
{ return __y < __x; }
|
|
|
|
|
|
|
|
template<typename _IteratorL, typename _IteratorR>
|
|
|
|
inline bool
|
|
|
|
operator<=(const reverse_iterator<_IteratorL>& __x,
|
|
|
|
const reverse_iterator<_IteratorR>& __y)
|
|
|
|
{ return !(__y < __x); }
|
|
|
|
|
|
|
|
template<typename _IteratorL, typename _IteratorR>
|
|
|
|
inline bool
|
|
|
|
operator>=(const reverse_iterator<_IteratorL>& __x,
|
|
|
|
const reverse_iterator<_IteratorR>& __y)
|
|
|
|
{ return !(__x < __y); }
|
|
|
|
|
|
|
|
template<typename _IteratorL, typename _IteratorR>
|
2008-10-07 16:49:20 +02:00
|
|
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
|
|
|
// DR 685.
|
|
|
|
inline auto
|
|
|
|
operator-(const reverse_iterator<_IteratorL>& __x,
|
|
|
|
const reverse_iterator<_IteratorR>& __y)
|
|
|
|
-> decltype(__y.base() - __x.base())
|
|
|
|
#else
|
2005-10-05 17:49:39 +02:00
|
|
|
inline typename reverse_iterator<_IteratorL>::difference_type
|
|
|
|
operator-(const reverse_iterator<_IteratorL>& __x,
|
|
|
|
const reverse_iterator<_IteratorR>& __y)
|
2008-10-07 16:49:20 +02:00
|
|
|
#endif
|
2005-10-05 17:49:39 +02:00
|
|
|
{ return __y.base() - __x.base(); }
|
2002-02-08 08:34:54 +01:00
|
|
|
//@}
|
2001-06-23 02:08:47 +02:00
|
|
|
|
|
|
|
// 24.4.2.2.1 back_insert_iterator
|
2002-02-08 08:34:54 +01:00
|
|
|
/**
|
abi.txt: New file.
2002-07-20 Phil Edwards <pme@gcc.gnu.org>
* docs/html/abi.txt: New file.
* docs/html/23_containers/howto.html: Tweak vector-overhead text.
* docs/html/ext/lwg-active.html, docs/html/ext/lwg-defects.html:
Import from upstream, R22.
* include/bits/char_traits.h, include/bits/stl_iterator.h,
include/bits/stl_iterator_base_types.h, libsupc++/exception,
libsupc++/new, libsupc++/typeinfo: Use @brief markup.
* include/bits/deque.tcc, include/bits/stl_alloc.h,
include/bits/stl_deque.h, include/bits/stl_list.h: Postpone removal
of deprecated functions until 3.4. (Same timeframe, different text.)
* include/bits/stl_vector.h: Ditto. Also do the same cleanups that
the other sequence classes received.
From-SVN: r55602
2002-07-20 08:26:27 +02:00
|
|
|
* @brief Turns assignment into insertion.
|
|
|
|
*
|
2002-02-08 08:34:54 +01:00
|
|
|
* These are output iterators, constructed from a container-of-T.
|
|
|
|
* Assigning a T to the iterator appends it to the container using
|
|
|
|
* push_back.
|
|
|
|
*
|
|
|
|
* Tip: Using the back_inserter function to create these iterators can
|
|
|
|
* save typing.
|
|
|
|
*/
|
2001-06-26 09:01:09 +02:00
|
|
|
template<typename _Container>
|
2004-02-08 05:46:42 +01:00
|
|
|
class back_insert_iterator
|
2001-06-23 02:08:47 +02:00
|
|
|
: public iterator<output_iterator_tag, void, void, void, void>
|
|
|
|
{
|
|
|
|
protected:
|
2002-01-17 04:59:42 +01:00
|
|
|
_Container* container;
|
2001-06-23 02:08:47 +02:00
|
|
|
|
|
|
|
public:
|
2002-02-08 08:34:54 +01:00
|
|
|
/// A nested typedef for the type of whatever container you used.
|
2001-06-23 02:08:47 +02:00
|
|
|
typedef _Container container_type;
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/// The only way to create this %iterator is with a container.
|
2004-02-08 05:46:42 +01:00
|
|
|
explicit
|
2002-01-17 04:59:42 +01:00
|
|
|
back_insert_iterator(_Container& __x) : container(&__x) { }
|
2001-06-23 02:08:47 +02:00
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/**
|
2011-08-07 09:27:06 +02:00
|
|
|
* @param __value An instance of whatever type
|
2002-02-08 08:34:54 +01:00
|
|
|
* container_type::const_reference is; presumably a
|
|
|
|
* reference-to-const T for container<T>.
|
|
|
|
* @return This %iterator, for chained operations.
|
|
|
|
*
|
2010-02-04 19:20:34 +01:00
|
|
|
* This kind of %iterator doesn't really have a @a position in the
|
2002-02-08 08:34:54 +01:00
|
|
|
* container (you can think of the position as being permanently at
|
|
|
|
* the end, if you like). Assigning a value to the %iterator will
|
|
|
|
* always append the value to the end of the container.
|
|
|
|
*/
|
2010-08-08 16:54:51 +02:00
|
|
|
#ifndef __GXX_EXPERIMENTAL_CXX0X__
|
2001-06-26 23:22:57 +02:00
|
|
|
back_insert_iterator&
|
2004-02-08 05:46:42 +01:00
|
|
|
operator=(typename _Container::const_reference __value)
|
|
|
|
{
|
2002-01-17 04:59:42 +01:00
|
|
|
container->push_back(__value);
|
2001-06-23 02:08:47 +02:00
|
|
|
return *this;
|
|
|
|
}
|
2010-08-08 16:54:51 +02:00
|
|
|
#else
|
|
|
|
back_insert_iterator&
|
|
|
|
operator=(const typename _Container::value_type& __value)
|
|
|
|
{
|
|
|
|
container->push_back(__value);
|
|
|
|
return *this;
|
|
|
|
}
|
2001-06-23 02:08:47 +02:00
|
|
|
|
2007-10-17 19:44:09 +02:00
|
|
|
back_insert_iterator&
|
|
|
|
operator=(typename _Container::value_type&& __value)
|
|
|
|
{
|
|
|
|
container->push_back(std::move(__value));
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/// Simply returns *this.
|
2004-02-08 05:46:42 +01:00
|
|
|
back_insert_iterator&
|
2004-02-01 18:34:44 +01:00
|
|
|
operator*()
|
|
|
|
{ return *this; }
|
2001-06-23 02:08:47 +02:00
|
|
|
|
2010-02-04 19:20:34 +01:00
|
|
|
/// Simply returns *this. (This %iterator does not @a move.)
|
2004-02-08 05:46:42 +01:00
|
|
|
back_insert_iterator&
|
2004-02-01 18:34:44 +01:00
|
|
|
operator++()
|
|
|
|
{ return *this; }
|
2001-06-23 02:08:47 +02:00
|
|
|
|
2010-02-04 19:20:34 +01:00
|
|
|
/// Simply returns *this. (This %iterator does not @a move.)
|
2001-06-26 23:22:57 +02:00
|
|
|
back_insert_iterator
|
2004-02-01 18:34:44 +01:00
|
|
|
operator++(int)
|
|
|
|
{ return *this; }
|
2001-06-23 02:08:47 +02:00
|
|
|
};
|
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/**
|
2011-08-07 09:27:06 +02:00
|
|
|
* @param __x A container of arbitrary type.
|
|
|
|
* @return An instance of back_insert_iterator working on @p __x.
|
2002-02-08 08:34:54 +01:00
|
|
|
*
|
|
|
|
* This wrapper function helps in creating back_insert_iterator instances.
|
|
|
|
* Typing the name of the %iterator requires knowing the precise full
|
|
|
|
* type of the container, which can be tedious and impedes generic
|
|
|
|
* programming. Using this function lets you take advantage of automatic
|
|
|
|
* template parameter deduction, making the compiler match the correct
|
|
|
|
* types for you.
|
|
|
|
*/
|
2001-06-26 09:01:09 +02:00
|
|
|
template<typename _Container>
|
2004-02-08 05:46:42 +01:00
|
|
|
inline back_insert_iterator<_Container>
|
|
|
|
back_inserter(_Container& __x)
|
2001-06-23 02:08:47 +02:00
|
|
|
{ return back_insert_iterator<_Container>(__x); }
|
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/**
|
abi.txt: New file.
2002-07-20 Phil Edwards <pme@gcc.gnu.org>
* docs/html/abi.txt: New file.
* docs/html/23_containers/howto.html: Tweak vector-overhead text.
* docs/html/ext/lwg-active.html, docs/html/ext/lwg-defects.html:
Import from upstream, R22.
* include/bits/char_traits.h, include/bits/stl_iterator.h,
include/bits/stl_iterator_base_types.h, libsupc++/exception,
libsupc++/new, libsupc++/typeinfo: Use @brief markup.
* include/bits/deque.tcc, include/bits/stl_alloc.h,
include/bits/stl_deque.h, include/bits/stl_list.h: Postpone removal
of deprecated functions until 3.4. (Same timeframe, different text.)
* include/bits/stl_vector.h: Ditto. Also do the same cleanups that
the other sequence classes received.
From-SVN: r55602
2002-07-20 08:26:27 +02:00
|
|
|
* @brief Turns assignment into insertion.
|
|
|
|
*
|
2002-02-08 08:34:54 +01:00
|
|
|
* These are output iterators, constructed from a container-of-T.
|
|
|
|
* Assigning a T to the iterator prepends it to the container using
|
|
|
|
* push_front.
|
|
|
|
*
|
|
|
|
* Tip: Using the front_inserter function to create these iterators can
|
|
|
|
* save typing.
|
|
|
|
*/
|
2001-06-26 09:01:09 +02:00
|
|
|
template<typename _Container>
|
2004-02-08 05:46:42 +01:00
|
|
|
class front_insert_iterator
|
2001-12-26 22:56:17 +01:00
|
|
|
: public iterator<output_iterator_tag, void, void, void, void>
|
2001-06-23 02:08:47 +02:00
|
|
|
{
|
|
|
|
protected:
|
2002-01-17 04:59:42 +01:00
|
|
|
_Container* container;
|
2001-06-23 02:08:47 +02:00
|
|
|
|
|
|
|
public:
|
2002-02-08 08:34:54 +01:00
|
|
|
/// A nested typedef for the type of whatever container you used.
|
2001-06-23 02:08:47 +02:00
|
|
|
typedef _Container container_type;
|
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/// The only way to create this %iterator is with a container.
|
2002-01-17 04:59:42 +01:00
|
|
|
explicit front_insert_iterator(_Container& __x) : container(&__x) { }
|
2001-06-26 23:22:57 +02:00
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/**
|
2011-08-07 09:27:06 +02:00
|
|
|
* @param __value An instance of whatever type
|
2002-02-08 08:34:54 +01:00
|
|
|
* container_type::const_reference is; presumably a
|
|
|
|
* reference-to-const T for container<T>.
|
|
|
|
* @return This %iterator, for chained operations.
|
|
|
|
*
|
2010-02-04 19:20:34 +01:00
|
|
|
* This kind of %iterator doesn't really have a @a position in the
|
2002-02-08 08:34:54 +01:00
|
|
|
* container (you can think of the position as being permanently at
|
|
|
|
* the front, if you like). Assigning a value to the %iterator will
|
|
|
|
* always prepend the value to the front of the container.
|
|
|
|
*/
|
2010-08-08 16:54:51 +02:00
|
|
|
#ifndef __GXX_EXPERIMENTAL_CXX0X__
|
2001-06-26 23:22:57 +02:00
|
|
|
front_insert_iterator&
|
2004-02-08 05:46:42 +01:00
|
|
|
operator=(typename _Container::const_reference __value)
|
|
|
|
{
|
2002-01-17 04:59:42 +01:00
|
|
|
container->push_front(__value);
|
2001-06-23 02:08:47 +02:00
|
|
|
return *this;
|
|
|
|
}
|
2010-08-08 16:54:51 +02:00
|
|
|
#else
|
|
|
|
front_insert_iterator&
|
|
|
|
operator=(const typename _Container::value_type& __value)
|
|
|
|
{
|
|
|
|
container->push_front(__value);
|
|
|
|
return *this;
|
|
|
|
}
|
2001-06-26 23:22:57 +02:00
|
|
|
|
2007-10-17 19:44:09 +02:00
|
|
|
front_insert_iterator&
|
|
|
|
operator=(typename _Container::value_type&& __value)
|
|
|
|
{
|
|
|
|
container->push_front(std::move(__value));
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/// Simply returns *this.
|
2004-02-08 05:46:42 +01:00
|
|
|
front_insert_iterator&
|
2004-02-01 18:34:44 +01:00
|
|
|
operator*()
|
|
|
|
{ return *this; }
|
2001-06-26 23:22:57 +02:00
|
|
|
|
2010-02-04 19:20:34 +01:00
|
|
|
/// Simply returns *this. (This %iterator does not @a move.)
|
2004-02-08 05:46:42 +01:00
|
|
|
front_insert_iterator&
|
2004-02-01 18:34:44 +01:00
|
|
|
operator++()
|
|
|
|
{ return *this; }
|
2001-06-26 23:22:57 +02:00
|
|
|
|
2010-02-04 19:20:34 +01:00
|
|
|
/// Simply returns *this. (This %iterator does not @a move.)
|
2004-02-08 05:46:42 +01:00
|
|
|
front_insert_iterator
|
2004-02-01 18:34:44 +01:00
|
|
|
operator++(int)
|
|
|
|
{ return *this; }
|
2001-06-23 02:08:47 +02:00
|
|
|
};
|
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/**
|
2011-08-07 09:27:06 +02:00
|
|
|
* @param __x A container of arbitrary type.
|
2002-02-08 08:34:54 +01:00
|
|
|
* @return An instance of front_insert_iterator working on @p x.
|
|
|
|
*
|
|
|
|
* This wrapper function helps in creating front_insert_iterator instances.
|
|
|
|
* Typing the name of the %iterator requires knowing the precise full
|
|
|
|
* type of the container, which can be tedious and impedes generic
|
|
|
|
* programming. Using this function lets you take advantage of automatic
|
|
|
|
* template parameter deduction, making the compiler match the correct
|
|
|
|
* types for you.
|
|
|
|
*/
|
2001-06-26 09:01:09 +02:00
|
|
|
template<typename _Container>
|
2004-02-08 05:46:42 +01:00
|
|
|
inline front_insert_iterator<_Container>
|
|
|
|
front_inserter(_Container& __x)
|
2001-12-26 22:56:17 +01:00
|
|
|
{ return front_insert_iterator<_Container>(__x); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/**
|
abi.txt: New file.
2002-07-20 Phil Edwards <pme@gcc.gnu.org>
* docs/html/abi.txt: New file.
* docs/html/23_containers/howto.html: Tweak vector-overhead text.
* docs/html/ext/lwg-active.html, docs/html/ext/lwg-defects.html:
Import from upstream, R22.
* include/bits/char_traits.h, include/bits/stl_iterator.h,
include/bits/stl_iterator_base_types.h, libsupc++/exception,
libsupc++/new, libsupc++/typeinfo: Use @brief markup.
* include/bits/deque.tcc, include/bits/stl_alloc.h,
include/bits/stl_deque.h, include/bits/stl_list.h: Postpone removal
of deprecated functions until 3.4. (Same timeframe, different text.)
* include/bits/stl_vector.h: Ditto. Also do the same cleanups that
the other sequence classes received.
From-SVN: r55602
2002-07-20 08:26:27 +02:00
|
|
|
* @brief Turns assignment into insertion.
|
|
|
|
*
|
2002-02-08 08:34:54 +01:00
|
|
|
* These are output iterators, constructed from a container-of-T.
|
|
|
|
* Assigning a T to the iterator inserts it in the container at the
|
|
|
|
* %iterator's position, rather than overwriting the value at that
|
|
|
|
* position.
|
|
|
|
*
|
|
|
|
* (Sequences will actually insert a @e copy of the value before the
|
|
|
|
* %iterator's position.)
|
|
|
|
*
|
|
|
|
* Tip: Using the inserter function to create these iterators can
|
|
|
|
* save typing.
|
|
|
|
*/
|
2001-06-26 09:01:09 +02:00
|
|
|
template<typename _Container>
|
2004-02-08 05:46:42 +01:00
|
|
|
class insert_iterator
|
2001-12-26 22:56:17 +01:00
|
|
|
: public iterator<output_iterator_tag, void, void, void, void>
|
2001-06-23 02:08:47 +02:00
|
|
|
{
|
|
|
|
protected:
|
2002-01-17 04:59:42 +01:00
|
|
|
_Container* container;
|
2001-06-23 02:08:47 +02:00
|
|
|
typename _Container::iterator iter;
|
|
|
|
|
|
|
|
public:
|
2002-02-08 08:34:54 +01:00
|
|
|
/// A nested typedef for the type of whatever container you used.
|
2001-06-23 02:08:47 +02:00
|
|
|
typedef _Container container_type;
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/**
|
|
|
|
* The only way to create this %iterator is with a container and an
|
|
|
|
* initial position (a normal %iterator into the container).
|
|
|
|
*/
|
2004-02-08 05:46:42 +01:00
|
|
|
insert_iterator(_Container& __x, typename _Container::iterator __i)
|
2002-01-17 04:59:42 +01:00
|
|
|
: container(&__x), iter(__i) {}
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/**
|
2011-08-07 09:27:06 +02:00
|
|
|
* @param __value An instance of whatever type
|
2002-02-08 08:34:54 +01:00
|
|
|
* container_type::const_reference is; presumably a
|
|
|
|
* reference-to-const T for container<T>.
|
|
|
|
* @return This %iterator, for chained operations.
|
|
|
|
*
|
|
|
|
* This kind of %iterator maintains its own position in the
|
|
|
|
* container. Assigning a value to the %iterator will insert the
|
|
|
|
* value into the container at the place before the %iterator.
|
|
|
|
*
|
|
|
|
* The position is maintained such that subsequent assignments will
|
|
|
|
* insert values immediately after one another. For example,
|
|
|
|
* @code
|
|
|
|
* // vector v contains A and Z
|
|
|
|
*
|
|
|
|
* insert_iterator i (v, ++v.begin());
|
|
|
|
* i = 1;
|
|
|
|
* i = 2;
|
|
|
|
* i = 3;
|
|
|
|
*
|
|
|
|
* // vector v contains A, 1, 2, 3, and Z
|
|
|
|
* @endcode
|
|
|
|
*/
|
2010-08-08 16:54:51 +02:00
|
|
|
#ifndef __GXX_EXPERIMENTAL_CXX0X__
|
2001-06-26 23:22:57 +02:00
|
|
|
insert_iterator&
|
2007-10-17 19:44:09 +02:00
|
|
|
operator=(typename _Container::const_reference __value)
|
2004-02-08 05:46:42 +01:00
|
|
|
{
|
2002-01-17 04:59:42 +01:00
|
|
|
iter = container->insert(iter, __value);
|
2001-06-23 02:08:47 +02:00
|
|
|
++iter;
|
|
|
|
return *this;
|
|
|
|
}
|
2010-08-08 16:54:51 +02:00
|
|
|
#else
|
|
|
|
insert_iterator&
|
|
|
|
operator=(const typename _Container::value_type& __value)
|
|
|
|
{
|
|
|
|
iter = container->insert(iter, __value);
|
|
|
|
++iter;
|
|
|
|
return *this;
|
|
|
|
}
|
2001-06-26 23:22:57 +02:00
|
|
|
|
2007-10-17 19:44:09 +02:00
|
|
|
insert_iterator&
|
|
|
|
operator=(typename _Container::value_type&& __value)
|
|
|
|
{
|
|
|
|
iter = container->insert(iter, std::move(__value));
|
|
|
|
++iter;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/// Simply returns *this.
|
2004-02-08 05:46:42 +01:00
|
|
|
insert_iterator&
|
2004-02-01 18:34:44 +01:00
|
|
|
operator*()
|
|
|
|
{ return *this; }
|
2001-06-26 23:22:57 +02:00
|
|
|
|
2010-02-04 19:20:34 +01:00
|
|
|
/// Simply returns *this. (This %iterator does not @a move.)
|
2004-02-08 05:46:42 +01:00
|
|
|
insert_iterator&
|
2004-02-01 18:34:44 +01:00
|
|
|
operator++()
|
|
|
|
{ return *this; }
|
2001-06-26 23:22:57 +02:00
|
|
|
|
2010-02-04 19:20:34 +01:00
|
|
|
/// Simply returns *this. (This %iterator does not @a move.)
|
2004-02-08 05:46:42 +01:00
|
|
|
insert_iterator&
|
2004-02-01 18:34:44 +01:00
|
|
|
operator++(int)
|
|
|
|
{ return *this; }
|
2001-06-23 02:08:47 +02:00
|
|
|
};
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2002-02-08 08:34:54 +01:00
|
|
|
/**
|
2011-08-07 09:27:06 +02:00
|
|
|
* @param __x A container of arbitrary type.
|
|
|
|
* @return An instance of insert_iterator working on @p __x.
|
2002-02-08 08:34:54 +01:00
|
|
|
*
|
|
|
|
* This wrapper function helps in creating insert_iterator instances.
|
|
|
|
* Typing the name of the %iterator requires knowing the precise full
|
|
|
|
* type of the container, which can be tedious and impedes generic
|
|
|
|
* programming. Using this function lets you take advantage of automatic
|
|
|
|
* template parameter deduction, making the compiler match the correct
|
|
|
|
* types for you.
|
|
|
|
*/
|
2001-06-26 09:01:09 +02:00
|
|
|
template<typename _Container, typename _Iterator>
|
2004-02-08 05:46:42 +01:00
|
|
|
inline insert_iterator<_Container>
|
2001-12-26 22:56:17 +01:00
|
|
|
inserter(_Container& __x, _Iterator __i)
|
2001-06-26 09:01:09 +02:00
|
|
|
{
|
2004-02-08 05:46:42 +01:00
|
|
|
return insert_iterator<_Container>(__x,
|
2001-12-26 22:56:17 +01:00
|
|
|
typename _Container::iterator(__i));
|
2001-06-26 09:01:09 +02:00
|
|
|
}
|
2002-04-16 04:29:22 +02:00
|
|
|
|
2009-11-06 23:15:17 +01:00
|
|
|
// @} group iterators
|
|
|
|
|
PR libstdc++/36104 part four
2011-01-30 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/36104 part four
* include/bits/c++config (_GLIBCXX_STD): Remove.
(_GLIBCXX_STD_D, _GLIBCXX_PR): Now _GLIBCXX_STD_C.
(_GLIBCXX_P): Now _GLIBCXX_STD_A.
(_GLIBCXX_NAMESPACE_DEBUG, _GLIBCXX_NAMESPACE_PARALLEL,
_GLIBCXX_NAMESPACE_PROFILE, _GLIBCXX_NAMESPACE_VERSION): Remove.
(_GLIBCXX_INLINE_DEBUG, _GLIBCXX_INLINE_PARALLEL,
_GLIBCXX_INLINE_PROFILE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE(X)): Remove.
(_GLIBCXX_END_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NESTED_NAMESPACE(X, Y)): Remove.
(_GLIBCXX_END_NESTED_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE_ALGO): Add.
(_GLIBCXX_END_NAMESPACE_ALGO): Add.
(_GLIBCXX_BEGIN_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_END_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_BEGIN_NAMESPACE_VERSION): Add.
(_GLIBCXX_END_NAMESPACE_VERSION): Add.
(_GLIBCXX_BEGIN_LDBL_NAMESPACE): To _GLIBCXX_BEGIN_NAMESPACE_LDBL.
(_GLIBCXX_END_LDBL_NAMESPACE): To _GLIBCXX_END_NAMESPACE_LDBL.
(_GLIBCXX_VISIBILITY_ATTR): Revert to _GLIBCXX_VISIBILITY.
* include/*: Use new macros for namespace scope.
* config/*: Same.
* src/*: Same.
* src/Makefile.am (sources): Remove debug_list.cc, add
compatibility-debug_list-2.cc.
(parallel_sources): Remove parallel_list.cc, add
compatibility-parallel_list-2.cc.
(compatibility-parallel_list-2.[o,lo]): New rule.
* src/Makefile.in: Regenerate.
* src/debug_list.cc: Remove.
* src/parallel_list.cc: Remove.
* src/compatibility-list-2.cc: New.
* src/compatibility-debug_list-2.cc: New.
* src/compatibility-parallel_list-2.cc: New.
* doc/doxygen/user.cfg.in: Adjust macros.
* testsuite/20_util/auto_ptr/assign_neg.cc: Adjust line numbers, macros.
* testsuite/20_util/declval/requirements/1_neg.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg1.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg2.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg3.cc: Same.
* testsuite/20_util/forward/c_neg.cc: Same.
* testsuite/20_util/forward/f_neg.cc: Same.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Same.
* testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Same.
* testsuite/20_util/shared_ptr/cons/43820_neg.cc: Same.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/forward_list/capacity/1.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
assign_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
insert_neg.cc: Same.
* testsuite/23_containers/list/capacity/29134.cc: Same.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/vector/bool/capacity/29134.cc: Same.
* testsuite/23_containers/vector/bool/modifiers/insert/31370.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc: Same.
* testsuite/25_algorithms/sort/35588.cc: Same.
* testsuite/27_io/ios_base/cons/assign_neg.cc: Same.
* testsuite/27_io/ios_base/cons/copy_neg.cc: Same.
* testsuite/ext/profile/mutex_extensions_neg.cc: Same.
* testsuite/ext/profile/profiler_algos.cc: Same.
* testsuite/ext/type_traits/add_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/add_unsigned_integer_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_integer_neg.cc: Same.
* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc: Same.
From-SVN: r169421
2011-01-30 23:39:36 +01:00
|
|
|
_GLIBCXX_END_NAMESPACE_VERSION
|
|
|
|
} // namespace
|
2005-12-19 01:56:05 +01:00
|
|
|
|
PR libstdc++/36104 part four
2011-01-30 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/36104 part four
* include/bits/c++config (_GLIBCXX_STD): Remove.
(_GLIBCXX_STD_D, _GLIBCXX_PR): Now _GLIBCXX_STD_C.
(_GLIBCXX_P): Now _GLIBCXX_STD_A.
(_GLIBCXX_NAMESPACE_DEBUG, _GLIBCXX_NAMESPACE_PARALLEL,
_GLIBCXX_NAMESPACE_PROFILE, _GLIBCXX_NAMESPACE_VERSION): Remove.
(_GLIBCXX_INLINE_DEBUG, _GLIBCXX_INLINE_PARALLEL,
_GLIBCXX_INLINE_PROFILE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE(X)): Remove.
(_GLIBCXX_END_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NESTED_NAMESPACE(X, Y)): Remove.
(_GLIBCXX_END_NESTED_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE_ALGO): Add.
(_GLIBCXX_END_NAMESPACE_ALGO): Add.
(_GLIBCXX_BEGIN_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_END_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_BEGIN_NAMESPACE_VERSION): Add.
(_GLIBCXX_END_NAMESPACE_VERSION): Add.
(_GLIBCXX_BEGIN_LDBL_NAMESPACE): To _GLIBCXX_BEGIN_NAMESPACE_LDBL.
(_GLIBCXX_END_LDBL_NAMESPACE): To _GLIBCXX_END_NAMESPACE_LDBL.
(_GLIBCXX_VISIBILITY_ATTR): Revert to _GLIBCXX_VISIBILITY.
* include/*: Use new macros for namespace scope.
* config/*: Same.
* src/*: Same.
* src/Makefile.am (sources): Remove debug_list.cc, add
compatibility-debug_list-2.cc.
(parallel_sources): Remove parallel_list.cc, add
compatibility-parallel_list-2.cc.
(compatibility-parallel_list-2.[o,lo]): New rule.
* src/Makefile.in: Regenerate.
* src/debug_list.cc: Remove.
* src/parallel_list.cc: Remove.
* src/compatibility-list-2.cc: New.
* src/compatibility-debug_list-2.cc: New.
* src/compatibility-parallel_list-2.cc: New.
* doc/doxygen/user.cfg.in: Adjust macros.
* testsuite/20_util/auto_ptr/assign_neg.cc: Adjust line numbers, macros.
* testsuite/20_util/declval/requirements/1_neg.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg1.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg2.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg3.cc: Same.
* testsuite/20_util/forward/c_neg.cc: Same.
* testsuite/20_util/forward/f_neg.cc: Same.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Same.
* testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Same.
* testsuite/20_util/shared_ptr/cons/43820_neg.cc: Same.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/forward_list/capacity/1.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
assign_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
insert_neg.cc: Same.
* testsuite/23_containers/list/capacity/29134.cc: Same.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/vector/bool/capacity/29134.cc: Same.
* testsuite/23_containers/vector/bool/modifiers/insert/31370.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc: Same.
* testsuite/25_algorithms/sort/35588.cc: Same.
* testsuite/27_io/ios_base/cons/assign_neg.cc: Same.
* testsuite/27_io/ios_base/cons/copy_neg.cc: Same.
* testsuite/ext/profile/mutex_extensions_neg.cc: Same.
* testsuite/ext/profile/profiler_algos.cc: Same.
* testsuite/ext/type_traits/add_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/add_unsigned_integer_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_integer_neg.cc: Same.
* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc: Same.
From-SVN: r169421
2011-01-30 23:39:36 +01:00
|
|
|
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
|
|
|
|
{
|
|
|
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
2005-12-19 01:56:05 +01:00
|
|
|
|
2010-02-04 19:20:34 +01:00
|
|
|
// This iterator adapter is @a normal in the sense that it does not
|
2001-07-09 23:47:36 +02:00
|
|
|
// change the semantics of any of the operators of its iterator
|
2001-06-26 09:01:09 +02:00
|
|
|
// parameter. Its primary purpose is to convert an iterator that is
|
|
|
|
// not a class, e.g. a pointer, into an iterator that is a class.
|
|
|
|
// The _Container parameter exists solely so that different containers
|
|
|
|
// using this template can instantiate different types, even if the
|
|
|
|
// _Iterator parameter is the same.
|
2002-04-16 04:29:22 +02:00
|
|
|
using std::iterator_traits;
|
|
|
|
using std::iterator;
|
2001-06-26 09:01:09 +02:00
|
|
|
template<typename _Iterator, typename _Container>
|
|
|
|
class __normal_iterator
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
_Iterator _M_current;
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2009-11-06 23:15:17 +01:00
|
|
|
typedef iterator_traits<_Iterator> __traits_type;
|
|
|
|
|
2001-06-26 09:01:09 +02:00
|
|
|
public:
|
2009-11-06 23:15:17 +01:00
|
|
|
typedef _Iterator iterator_type;
|
|
|
|
typedef typename __traits_type::iterator_category iterator_category;
|
|
|
|
typedef typename __traits_type::value_type value_type;
|
|
|
|
typedef typename __traits_type::difference_type difference_type;
|
|
|
|
typedef typename __traits_type::reference reference;
|
|
|
|
typedef typename __traits_type::pointer pointer;
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2010-11-02 03:35:28 +01:00
|
|
|
_GLIBCXX_CONSTEXPR __normal_iterator() : _M_current(_Iterator()) { }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2004-02-08 05:46:42 +01:00
|
|
|
explicit
|
2001-06-26 09:01:09 +02:00
|
|
|
__normal_iterator(const _Iterator& __i) : _M_current(__i) { }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2001-06-26 09:01:09 +02:00
|
|
|
// Allow iterator to const_iterator conversion
|
|
|
|
template<typename _Iter>
|
2005-09-12 11:42:34 +02:00
|
|
|
__normal_iterator(const __normal_iterator<_Iter,
|
2006-09-18 15:30:56 +02:00
|
|
|
typename __enable_if<
|
|
|
|
(std::__are_same<_Iter, typename _Container::pointer>::__value),
|
|
|
|
_Container>::__type>& __i)
|
2005-09-12 11:42:34 +02:00
|
|
|
: _M_current(__i.base()) { }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2001-06-26 09:01:09 +02:00
|
|
|
// Forward iterator requirements
|
|
|
|
reference
|
2004-02-01 18:34:44 +01:00
|
|
|
operator*() const
|
|
|
|
{ return *_M_current; }
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2001-06-26 09:01:09 +02:00
|
|
|
pointer
|
2004-02-01 18:34:44 +01:00
|
|
|
operator->() const
|
|
|
|
{ return _M_current; }
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2001-06-26 09:01:09 +02:00
|
|
|
__normal_iterator&
|
2004-02-01 18:34:44 +01:00
|
|
|
operator++()
|
|
|
|
{
|
|
|
|
++_M_current;
|
|
|
|
return *this;
|
|
|
|
}
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2001-06-26 09:01:09 +02:00
|
|
|
__normal_iterator
|
2004-02-01 18:34:44 +01:00
|
|
|
operator++(int)
|
|
|
|
{ return __normal_iterator(_M_current++); }
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2001-06-26 09:01:09 +02:00
|
|
|
// Bidirectional iterator requirements
|
|
|
|
__normal_iterator&
|
2004-02-01 18:34:44 +01:00
|
|
|
operator--()
|
|
|
|
{
|
|
|
|
--_M_current;
|
|
|
|
return *this;
|
|
|
|
}
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2001-06-26 09:01:09 +02:00
|
|
|
__normal_iterator
|
2004-02-01 18:34:44 +01:00
|
|
|
operator--(int)
|
|
|
|
{ return __normal_iterator(_M_current--); }
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2001-06-26 09:01:09 +02:00
|
|
|
// Random access iterator requirements
|
|
|
|
reference
|
|
|
|
operator[](const difference_type& __n) const
|
|
|
|
{ return _M_current[__n]; }
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2001-06-26 09:01:09 +02:00
|
|
|
__normal_iterator&
|
|
|
|
operator+=(const difference_type& __n)
|
|
|
|
{ _M_current += __n; return *this; }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2001-06-26 09:01:09 +02:00
|
|
|
__normal_iterator
|
|
|
|
operator+(const difference_type& __n) const
|
|
|
|
{ return __normal_iterator(_M_current + __n); }
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2001-06-26 09:01:09 +02:00
|
|
|
__normal_iterator&
|
|
|
|
operator-=(const difference_type& __n)
|
|
|
|
{ _M_current -= __n; return *this; }
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2001-06-26 09:01:09 +02:00
|
|
|
__normal_iterator
|
|
|
|
operator-(const difference_type& __n) const
|
|
|
|
{ return __normal_iterator(_M_current - __n); }
|
2004-02-08 05:46:42 +01:00
|
|
|
|
|
|
|
const _Iterator&
|
2004-02-01 18:34:44 +01:00
|
|
|
base() const
|
|
|
|
{ return _M_current; }
|
2001-06-26 09:01:09 +02:00
|
|
|
};
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2002-04-16 04:29:22 +02:00
|
|
|
// Note: In what follows, the left- and right-hand-side iterators are
|
|
|
|
// allowed to vary in types (conceptually in cv-qualification) so that
|
2008-01-31 19:44:55 +01:00
|
|
|
// comparison between cv-qualified and non-cv-qualified iterators be
|
2002-04-16 04:29:22 +02:00
|
|
|
// valid. However, the greedy and unfriendly operators in std::rel_ops
|
|
|
|
// will make overload resolution ambiguous (when in scope) if we don't
|
|
|
|
// provide overloads whose operands are of the same type. Can someone
|
|
|
|
// remind me what generic programming is about? -- Gaby
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2001-06-26 09:01:09 +02:00
|
|
|
// Forward iterator requirements
|
|
|
|
template<typename _IteratorL, typename _IteratorR, typename _Container>
|
2004-02-01 18:34:44 +01:00
|
|
|
inline bool
|
|
|
|
operator==(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
|
|
|
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
|
|
|
{ return __lhs.base() == __rhs.base(); }
|
2001-06-26 09:01:09 +02:00
|
|
|
|
2002-04-16 04:29:22 +02:00
|
|
|
template<typename _Iterator, typename _Container>
|
2004-02-01 18:34:44 +01:00
|
|
|
inline bool
|
|
|
|
operator==(const __normal_iterator<_Iterator, _Container>& __lhs,
|
|
|
|
const __normal_iterator<_Iterator, _Container>& __rhs)
|
|
|
|
{ return __lhs.base() == __rhs.base(); }
|
2002-04-16 04:29:22 +02:00
|
|
|
|
2001-06-26 09:01:09 +02:00
|
|
|
template<typename _IteratorL, typename _IteratorR, typename _Container>
|
2004-02-01 18:34:44 +01:00
|
|
|
inline bool
|
|
|
|
operator!=(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
|
|
|
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
|
|
|
{ return __lhs.base() != __rhs.base(); }
|
2002-04-16 04:29:22 +02:00
|
|
|
|
|
|
|
template<typename _Iterator, typename _Container>
|
2004-02-01 18:34:44 +01:00
|
|
|
inline bool
|
|
|
|
operator!=(const __normal_iterator<_Iterator, _Container>& __lhs,
|
|
|
|
const __normal_iterator<_Iterator, _Container>& __rhs)
|
|
|
|
{ return __lhs.base() != __rhs.base(); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
|
|
|
// Random access iterator requirements
|
2001-06-26 09:01:09 +02:00
|
|
|
template<typename _IteratorL, typename _IteratorR, typename _Container>
|
2004-02-08 05:46:42 +01:00
|
|
|
inline bool
|
2004-02-01 18:34:44 +01:00
|
|
|
operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
|
|
|
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
|
|
|
{ return __lhs.base() < __rhs.base(); }
|
2001-06-26 09:01:09 +02:00
|
|
|
|
2002-04-16 04:29:22 +02:00
|
|
|
template<typename _Iterator, typename _Container>
|
2004-02-01 18:34:44 +01:00
|
|
|
inline bool
|
|
|
|
operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
|
|
|
|
const __normal_iterator<_Iterator, _Container>& __rhs)
|
|
|
|
{ return __lhs.base() < __rhs.base(); }
|
2002-04-16 04:29:22 +02:00
|
|
|
|
2001-06-26 09:01:09 +02:00
|
|
|
template<typename _IteratorL, typename _IteratorR, typename _Container>
|
2004-02-01 18:34:44 +01:00
|
|
|
inline bool
|
|
|
|
operator>(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
|
|
|
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
|
|
|
{ return __lhs.base() > __rhs.base(); }
|
2002-04-16 04:29:22 +02:00
|
|
|
|
|
|
|
template<typename _Iterator, typename _Container>
|
2004-02-01 18:34:44 +01:00
|
|
|
inline bool
|
|
|
|
operator>(const __normal_iterator<_Iterator, _Container>& __lhs,
|
|
|
|
const __normal_iterator<_Iterator, _Container>& __rhs)
|
|
|
|
{ return __lhs.base() > __rhs.base(); }
|
2001-06-26 09:01:09 +02:00
|
|
|
|
|
|
|
template<typename _IteratorL, typename _IteratorR, typename _Container>
|
2004-02-01 18:34:44 +01:00
|
|
|
inline bool
|
|
|
|
operator<=(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
|
|
|
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
|
|
|
{ return __lhs.base() <= __rhs.base(); }
|
2002-04-16 04:29:22 +02:00
|
|
|
|
|
|
|
template<typename _Iterator, typename _Container>
|
2004-02-01 18:34:44 +01:00
|
|
|
inline bool
|
|
|
|
operator<=(const __normal_iterator<_Iterator, _Container>& __lhs,
|
|
|
|
const __normal_iterator<_Iterator, _Container>& __rhs)
|
|
|
|
{ return __lhs.base() <= __rhs.base(); }
|
2001-06-26 09:01:09 +02:00
|
|
|
|
|
|
|
template<typename _IteratorL, typename _IteratorR, typename _Container>
|
2004-02-01 18:34:44 +01:00
|
|
|
inline bool
|
|
|
|
operator>=(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
|
|
|
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
|
|
|
{ return __lhs.base() >= __rhs.base(); }
|
2002-04-16 04:29:22 +02:00
|
|
|
|
|
|
|
template<typename _Iterator, typename _Container>
|
2004-02-01 18:34:44 +01:00
|
|
|
inline bool
|
|
|
|
operator>=(const __normal_iterator<_Iterator, _Container>& __lhs,
|
|
|
|
const __normal_iterator<_Iterator, _Container>& __rhs)
|
|
|
|
{ return __lhs.base() >= __rhs.base(); }
|
2001-06-26 09:01:09 +02:00
|
|
|
|
2003-07-05 06:05:45 +02:00
|
|
|
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
2002-07-02 20:42:58 +02:00
|
|
|
// According to the resolution of DR179 not only the various comparison
|
|
|
|
// operators but also operator- must accept mixed iterator/const_iterator
|
|
|
|
// parameters.
|
|
|
|
template<typename _IteratorL, typename _IteratorR, typename _Container>
|
2008-10-07 16:49:20 +02:00
|
|
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
|
|
|
// DR 685.
|
|
|
|
inline auto
|
|
|
|
operator-(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
|
|
|
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
|
|
|
-> decltype(__lhs.base() - __rhs.base())
|
|
|
|
#else
|
2004-02-01 18:34:44 +01:00
|
|
|
inline typename __normal_iterator<_IteratorL, _Container>::difference_type
|
|
|
|
operator-(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
|
|
|
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
2008-10-07 16:49:20 +02:00
|
|
|
#endif
|
2004-02-01 18:34:44 +01:00
|
|
|
{ return __lhs.base() - __rhs.base(); }
|
2002-07-02 20:42:58 +02:00
|
|
|
|
basic_string.h (insert(iterator, _CharT), [...]): Avoid troubles with ADL, user defined operators and __normal_iterator.
2005-12-06 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (insert(iterator, _CharT),
erase(iterator), erase(iterator, iterator)): Avoid troubles
with ADL, user defined operators and __normal_iterator.
* include/bits/stl_iterator.h (operator-(const __normal_iterator
<_Iterator, _Container>&, const __normal_iterator<_Iterator,
_Container>&)): Add overload for left and right iterators of
the same type.
* include/debug/safe_iterator.h (operator-(const _Safe_iterator
<_Iterator, _Sequence>&, const _Safe_iterator<_Iterator,
_Sequence>&)): Likewise.
* testsuite/21_strings/basic_string/types/1.cc: New.
From-SVN: r108123
2005-12-06 18:19:30 +01:00
|
|
|
template<typename _Iterator, typename _Container>
|
|
|
|
inline typename __normal_iterator<_Iterator, _Container>::difference_type
|
|
|
|
operator-(const __normal_iterator<_Iterator, _Container>& __lhs,
|
|
|
|
const __normal_iterator<_Iterator, _Container>& __rhs)
|
|
|
|
{ return __lhs.base() - __rhs.base(); }
|
|
|
|
|
2001-06-26 09:01:09 +02:00
|
|
|
template<typename _Iterator, typename _Container>
|
2004-02-01 18:34:44 +01:00
|
|
|
inline __normal_iterator<_Iterator, _Container>
|
|
|
|
operator+(typename __normal_iterator<_Iterator, _Container>::difference_type
|
|
|
|
__n, const __normal_iterator<_Iterator, _Container>& __i)
|
|
|
|
{ return __normal_iterator<_Iterator, _Container>(__i.base() + __n); }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
PR libstdc++/36104 part four
2011-01-30 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/36104 part four
* include/bits/c++config (_GLIBCXX_STD): Remove.
(_GLIBCXX_STD_D, _GLIBCXX_PR): Now _GLIBCXX_STD_C.
(_GLIBCXX_P): Now _GLIBCXX_STD_A.
(_GLIBCXX_NAMESPACE_DEBUG, _GLIBCXX_NAMESPACE_PARALLEL,
_GLIBCXX_NAMESPACE_PROFILE, _GLIBCXX_NAMESPACE_VERSION): Remove.
(_GLIBCXX_INLINE_DEBUG, _GLIBCXX_INLINE_PARALLEL,
_GLIBCXX_INLINE_PROFILE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE(X)): Remove.
(_GLIBCXX_END_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NESTED_NAMESPACE(X, Y)): Remove.
(_GLIBCXX_END_NESTED_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE_ALGO): Add.
(_GLIBCXX_END_NAMESPACE_ALGO): Add.
(_GLIBCXX_BEGIN_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_END_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_BEGIN_NAMESPACE_VERSION): Add.
(_GLIBCXX_END_NAMESPACE_VERSION): Add.
(_GLIBCXX_BEGIN_LDBL_NAMESPACE): To _GLIBCXX_BEGIN_NAMESPACE_LDBL.
(_GLIBCXX_END_LDBL_NAMESPACE): To _GLIBCXX_END_NAMESPACE_LDBL.
(_GLIBCXX_VISIBILITY_ATTR): Revert to _GLIBCXX_VISIBILITY.
* include/*: Use new macros for namespace scope.
* config/*: Same.
* src/*: Same.
* src/Makefile.am (sources): Remove debug_list.cc, add
compatibility-debug_list-2.cc.
(parallel_sources): Remove parallel_list.cc, add
compatibility-parallel_list-2.cc.
(compatibility-parallel_list-2.[o,lo]): New rule.
* src/Makefile.in: Regenerate.
* src/debug_list.cc: Remove.
* src/parallel_list.cc: Remove.
* src/compatibility-list-2.cc: New.
* src/compatibility-debug_list-2.cc: New.
* src/compatibility-parallel_list-2.cc: New.
* doc/doxygen/user.cfg.in: Adjust macros.
* testsuite/20_util/auto_ptr/assign_neg.cc: Adjust line numbers, macros.
* testsuite/20_util/declval/requirements/1_neg.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg1.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg2.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg3.cc: Same.
* testsuite/20_util/forward/c_neg.cc: Same.
* testsuite/20_util/forward/f_neg.cc: Same.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Same.
* testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Same.
* testsuite/20_util/shared_ptr/cons/43820_neg.cc: Same.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/forward_list/capacity/1.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
assign_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
insert_neg.cc: Same.
* testsuite/23_containers/list/capacity/29134.cc: Same.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/vector/bool/capacity/29134.cc: Same.
* testsuite/23_containers/vector/bool/modifiers/insert/31370.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc: Same.
* testsuite/25_algorithms/sort/35588.cc: Same.
* testsuite/27_io/ios_base/cons/assign_neg.cc: Same.
* testsuite/27_io/ios_base/cons/copy_neg.cc: Same.
* testsuite/ext/profile/mutex_extensions_neg.cc: Same.
* testsuite/ext/profile/profiler_algos.cc: Same.
* testsuite/ext/type_traits/add_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/add_unsigned_integer_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_integer_neg.cc: Same.
* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc: Same.
From-SVN: r169421
2011-01-30 23:39:36 +01:00
|
|
|
_GLIBCXX_END_NAMESPACE_VERSION
|
|
|
|
} // namespace
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2007-10-06 04:33:12 +02:00
|
|
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
|
|
|
|
PR libstdc++/36104 part four
2011-01-30 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/36104 part four
* include/bits/c++config (_GLIBCXX_STD): Remove.
(_GLIBCXX_STD_D, _GLIBCXX_PR): Now _GLIBCXX_STD_C.
(_GLIBCXX_P): Now _GLIBCXX_STD_A.
(_GLIBCXX_NAMESPACE_DEBUG, _GLIBCXX_NAMESPACE_PARALLEL,
_GLIBCXX_NAMESPACE_PROFILE, _GLIBCXX_NAMESPACE_VERSION): Remove.
(_GLIBCXX_INLINE_DEBUG, _GLIBCXX_INLINE_PARALLEL,
_GLIBCXX_INLINE_PROFILE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE(X)): Remove.
(_GLIBCXX_END_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NESTED_NAMESPACE(X, Y)): Remove.
(_GLIBCXX_END_NESTED_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE_ALGO): Add.
(_GLIBCXX_END_NAMESPACE_ALGO): Add.
(_GLIBCXX_BEGIN_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_END_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_BEGIN_NAMESPACE_VERSION): Add.
(_GLIBCXX_END_NAMESPACE_VERSION): Add.
(_GLIBCXX_BEGIN_LDBL_NAMESPACE): To _GLIBCXX_BEGIN_NAMESPACE_LDBL.
(_GLIBCXX_END_LDBL_NAMESPACE): To _GLIBCXX_END_NAMESPACE_LDBL.
(_GLIBCXX_VISIBILITY_ATTR): Revert to _GLIBCXX_VISIBILITY.
* include/*: Use new macros for namespace scope.
* config/*: Same.
* src/*: Same.
* src/Makefile.am (sources): Remove debug_list.cc, add
compatibility-debug_list-2.cc.
(parallel_sources): Remove parallel_list.cc, add
compatibility-parallel_list-2.cc.
(compatibility-parallel_list-2.[o,lo]): New rule.
* src/Makefile.in: Regenerate.
* src/debug_list.cc: Remove.
* src/parallel_list.cc: Remove.
* src/compatibility-list-2.cc: New.
* src/compatibility-debug_list-2.cc: New.
* src/compatibility-parallel_list-2.cc: New.
* doc/doxygen/user.cfg.in: Adjust macros.
* testsuite/20_util/auto_ptr/assign_neg.cc: Adjust line numbers, macros.
* testsuite/20_util/declval/requirements/1_neg.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg1.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg2.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg3.cc: Same.
* testsuite/20_util/forward/c_neg.cc: Same.
* testsuite/20_util/forward/f_neg.cc: Same.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Same.
* testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Same.
* testsuite/20_util/shared_ptr/cons/43820_neg.cc: Same.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/forward_list/capacity/1.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
assign_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
insert_neg.cc: Same.
* testsuite/23_containers/list/capacity/29134.cc: Same.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/vector/bool/capacity/29134.cc: Same.
* testsuite/23_containers/vector/bool/modifiers/insert/31370.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc: Same.
* testsuite/25_algorithms/sort/35588.cc: Same.
* testsuite/27_io/ios_base/cons/assign_neg.cc: Same.
* testsuite/27_io/ios_base/cons/copy_neg.cc: Same.
* testsuite/ext/profile/mutex_extensions_neg.cc: Same.
* testsuite/ext/profile/profiler_algos.cc: Same.
* testsuite/ext/type_traits/add_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/add_unsigned_integer_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_integer_neg.cc: Same.
* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc: Same.
From-SVN: r169421
2011-01-30 23:39:36 +01:00
|
|
|
namespace std _GLIBCXX_VISIBILITY(default)
|
|
|
|
{
|
|
|
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
2007-10-06 04:33:12 +02:00
|
|
|
|
2009-11-06 23:15:17 +01:00
|
|
|
/**
|
|
|
|
* @addtogroup iterators
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2007-10-06 04:33:12 +02:00
|
|
|
// 24.4.3 Move iterators
|
|
|
|
/**
|
|
|
|
* Class template move_iterator is an iterator adapter with the same
|
|
|
|
* behavior as the underlying iterator except that its dereference
|
|
|
|
* operator implicitly converts the value returned by the underlying
|
|
|
|
* iterator's dereference operator to an rvalue reference. Some
|
|
|
|
* generic algorithms can be called with move iterators to replace
|
|
|
|
* copying with moving.
|
|
|
|
*/
|
|
|
|
template<typename _Iterator>
|
|
|
|
class move_iterator
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
_Iterator _M_current;
|
|
|
|
|
2009-11-06 23:15:17 +01:00
|
|
|
typedef iterator_traits<_Iterator> __traits_type;
|
|
|
|
|
2007-10-06 04:33:12 +02:00
|
|
|
public:
|
2009-11-06 23:15:17 +01:00
|
|
|
typedef _Iterator iterator_type;
|
|
|
|
typedef typename __traits_type::iterator_category iterator_category;
|
|
|
|
typedef typename __traits_type::value_type value_type;
|
|
|
|
typedef typename __traits_type::difference_type difference_type;
|
2007-11-07 13:43:35 +01:00
|
|
|
// NB: DR 680.
|
2009-11-06 23:15:17 +01:00
|
|
|
typedef _Iterator pointer;
|
|
|
|
typedef value_type&& reference;
|
2007-10-06 04:33:12 +02:00
|
|
|
|
|
|
|
move_iterator()
|
|
|
|
: _M_current() { }
|
|
|
|
|
|
|
|
explicit
|
|
|
|
move_iterator(iterator_type __i)
|
|
|
|
: _M_current(__i) { }
|
|
|
|
|
|
|
|
template<typename _Iter>
|
|
|
|
move_iterator(const move_iterator<_Iter>& __i)
|
|
|
|
: _M_current(__i.base()) { }
|
|
|
|
|
|
|
|
iterator_type
|
|
|
|
base() const
|
|
|
|
{ return _M_current; }
|
|
|
|
|
|
|
|
reference
|
|
|
|
operator*() const
|
2009-08-01 04:26:32 +02:00
|
|
|
{ return std::move(*_M_current); }
|
2007-10-06 04:33:12 +02:00
|
|
|
|
|
|
|
pointer
|
|
|
|
operator->() const
|
|
|
|
{ return _M_current; }
|
|
|
|
|
|
|
|
move_iterator&
|
|
|
|
operator++()
|
|
|
|
{
|
|
|
|
++_M_current;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
move_iterator
|
|
|
|
operator++(int)
|
|
|
|
{
|
|
|
|
move_iterator __tmp = *this;
|
|
|
|
++_M_current;
|
|
|
|
return __tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
move_iterator&
|
|
|
|
operator--()
|
|
|
|
{
|
|
|
|
--_M_current;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
move_iterator
|
|
|
|
operator--(int)
|
|
|
|
{
|
|
|
|
move_iterator __tmp = *this;
|
|
|
|
--_M_current;
|
|
|
|
return __tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
move_iterator
|
|
|
|
operator+(difference_type __n) const
|
|
|
|
{ return move_iterator(_M_current + __n); }
|
|
|
|
|
|
|
|
move_iterator&
|
|
|
|
operator+=(difference_type __n)
|
|
|
|
{
|
|
|
|
_M_current += __n;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
move_iterator
|
|
|
|
operator-(difference_type __n) const
|
|
|
|
{ return move_iterator(_M_current - __n); }
|
|
|
|
|
|
|
|
move_iterator&
|
|
|
|
operator-=(difference_type __n)
|
|
|
|
{
|
|
|
|
_M_current -= __n;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
reference
|
|
|
|
operator[](difference_type __n) const
|
2009-08-01 04:26:32 +02:00
|
|
|
{ return std::move(_M_current[__n]); }
|
2007-10-06 04:33:12 +02:00
|
|
|
};
|
|
|
|
|
2010-12-08 02:23:41 +01:00
|
|
|
// Note: See __normal_iterator operators note from Gaby to understand
|
|
|
|
// why there are always 2 versions for most of the move_iterator
|
|
|
|
// operators.
|
2007-10-06 04:33:12 +02:00
|
|
|
template<typename _IteratorL, typename _IteratorR>
|
|
|
|
inline bool
|
|
|
|
operator==(const move_iterator<_IteratorL>& __x,
|
|
|
|
const move_iterator<_IteratorR>& __y)
|
|
|
|
{ return __x.base() == __y.base(); }
|
|
|
|
|
2010-12-08 02:23:41 +01:00
|
|
|
template<typename _Iterator>
|
|
|
|
inline bool
|
|
|
|
operator==(const move_iterator<_Iterator>& __x,
|
|
|
|
const move_iterator<_Iterator>& __y)
|
|
|
|
{ return __x.base() == __y.base(); }
|
|
|
|
|
2007-10-06 04:33:12 +02:00
|
|
|
template<typename _IteratorL, typename _IteratorR>
|
|
|
|
inline bool
|
|
|
|
operator!=(const move_iterator<_IteratorL>& __x,
|
|
|
|
const move_iterator<_IteratorR>& __y)
|
|
|
|
{ return !(__x == __y); }
|
|
|
|
|
2010-12-08 02:23:41 +01:00
|
|
|
template<typename _Iterator>
|
|
|
|
inline bool
|
|
|
|
operator!=(const move_iterator<_Iterator>& __x,
|
|
|
|
const move_iterator<_Iterator>& __y)
|
|
|
|
{ return !(__x == __y); }
|
|
|
|
|
2007-10-06 04:33:12 +02:00
|
|
|
template<typename _IteratorL, typename _IteratorR>
|
|
|
|
inline bool
|
|
|
|
operator<(const move_iterator<_IteratorL>& __x,
|
|
|
|
const move_iterator<_IteratorR>& __y)
|
|
|
|
{ return __x.base() < __y.base(); }
|
|
|
|
|
2010-12-08 02:23:41 +01:00
|
|
|
template<typename _Iterator>
|
|
|
|
inline bool
|
|
|
|
operator<(const move_iterator<_Iterator>& __x,
|
|
|
|
const move_iterator<_Iterator>& __y)
|
|
|
|
{ return __x.base() < __y.base(); }
|
|
|
|
|
2007-10-06 04:33:12 +02:00
|
|
|
template<typename _IteratorL, typename _IteratorR>
|
|
|
|
inline bool
|
|
|
|
operator<=(const move_iterator<_IteratorL>& __x,
|
|
|
|
const move_iterator<_IteratorR>& __y)
|
|
|
|
{ return !(__y < __x); }
|
|
|
|
|
2010-12-08 02:23:41 +01:00
|
|
|
template<typename _Iterator>
|
|
|
|
inline bool
|
|
|
|
operator<=(const move_iterator<_Iterator>& __x,
|
|
|
|
const move_iterator<_Iterator>& __y)
|
|
|
|
{ return !(__y < __x); }
|
|
|
|
|
2007-10-06 04:33:12 +02:00
|
|
|
template<typename _IteratorL, typename _IteratorR>
|
|
|
|
inline bool
|
|
|
|
operator>(const move_iterator<_IteratorL>& __x,
|
|
|
|
const move_iterator<_IteratorR>& __y)
|
|
|
|
{ return __y < __x; }
|
|
|
|
|
2010-12-08 02:23:41 +01:00
|
|
|
template<typename _Iterator>
|
|
|
|
inline bool
|
|
|
|
operator>(const move_iterator<_Iterator>& __x,
|
|
|
|
const move_iterator<_Iterator>& __y)
|
|
|
|
{ return __y < __x; }
|
|
|
|
|
2007-10-06 04:33:12 +02:00
|
|
|
template<typename _IteratorL, typename _IteratorR>
|
|
|
|
inline bool
|
|
|
|
operator>=(const move_iterator<_IteratorL>& __x,
|
|
|
|
const move_iterator<_IteratorR>& __y)
|
|
|
|
{ return !(__x < __y); }
|
|
|
|
|
2010-12-08 02:23:41 +01:00
|
|
|
template<typename _Iterator>
|
|
|
|
inline bool
|
|
|
|
operator>=(const move_iterator<_Iterator>& __x,
|
|
|
|
const move_iterator<_Iterator>& __y)
|
|
|
|
{ return !(__x < __y); }
|
|
|
|
|
2008-10-07 16:49:20 +02:00
|
|
|
// DR 685.
|
2007-10-06 04:33:12 +02:00
|
|
|
template<typename _IteratorL, typename _IteratorR>
|
2008-10-07 16:49:20 +02:00
|
|
|
inline auto
|
2007-10-06 04:33:12 +02:00
|
|
|
operator-(const move_iterator<_IteratorL>& __x,
|
|
|
|
const move_iterator<_IteratorR>& __y)
|
2008-10-07 16:49:20 +02:00
|
|
|
-> decltype(__x.base() - __y.base())
|
2007-10-06 04:33:12 +02:00
|
|
|
{ return __x.base() - __y.base(); }
|
|
|
|
|
2010-12-08 02:23:41 +01:00
|
|
|
template<typename _Iterator>
|
|
|
|
inline auto
|
|
|
|
operator-(const move_iterator<_Iterator>& __x,
|
|
|
|
const move_iterator<_Iterator>& __y)
|
|
|
|
-> decltype(__x.base() - __y.base())
|
|
|
|
{ return __x.base() - __y.base(); }
|
|
|
|
|
2007-10-06 04:33:12 +02:00
|
|
|
template<typename _Iterator>
|
|
|
|
inline move_iterator<_Iterator>
|
|
|
|
operator+(typename move_iterator<_Iterator>::difference_type __n,
|
|
|
|
const move_iterator<_Iterator>& __x)
|
|
|
|
{ return __x + __n; }
|
|
|
|
|
|
|
|
template<typename _Iterator>
|
|
|
|
inline move_iterator<_Iterator>
|
2011-08-30 17:34:50 +02:00
|
|
|
make_move_iterator(_Iterator __i)
|
2007-10-06 04:33:12 +02:00
|
|
|
{ return move_iterator<_Iterator>(__i); }
|
|
|
|
|
2011-06-07 18:11:36 +02:00
|
|
|
template<typename _Iterator, typename _ReturnType
|
|
|
|
= typename conditional<__move_if_noexcept_cond
|
|
|
|
<typename iterator_traits<_Iterator>::value_type>::value,
|
|
|
|
_Iterator, move_iterator<_Iterator>>::type>
|
|
|
|
inline _ReturnType
|
|
|
|
__make_move_if_noexcept_iterator(_Iterator __i)
|
|
|
|
{ return _ReturnType(__i); }
|
|
|
|
|
2009-11-06 23:15:17 +01:00
|
|
|
// @} group iterators
|
|
|
|
|
PR libstdc++/36104 part four
2011-01-30 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/36104 part four
* include/bits/c++config (_GLIBCXX_STD): Remove.
(_GLIBCXX_STD_D, _GLIBCXX_PR): Now _GLIBCXX_STD_C.
(_GLIBCXX_P): Now _GLIBCXX_STD_A.
(_GLIBCXX_NAMESPACE_DEBUG, _GLIBCXX_NAMESPACE_PARALLEL,
_GLIBCXX_NAMESPACE_PROFILE, _GLIBCXX_NAMESPACE_VERSION): Remove.
(_GLIBCXX_INLINE_DEBUG, _GLIBCXX_INLINE_PARALLEL,
_GLIBCXX_INLINE_PROFILE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE(X)): Remove.
(_GLIBCXX_END_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NESTED_NAMESPACE(X, Y)): Remove.
(_GLIBCXX_END_NESTED_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE_ALGO): Add.
(_GLIBCXX_END_NAMESPACE_ALGO): Add.
(_GLIBCXX_BEGIN_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_END_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_BEGIN_NAMESPACE_VERSION): Add.
(_GLIBCXX_END_NAMESPACE_VERSION): Add.
(_GLIBCXX_BEGIN_LDBL_NAMESPACE): To _GLIBCXX_BEGIN_NAMESPACE_LDBL.
(_GLIBCXX_END_LDBL_NAMESPACE): To _GLIBCXX_END_NAMESPACE_LDBL.
(_GLIBCXX_VISIBILITY_ATTR): Revert to _GLIBCXX_VISIBILITY.
* include/*: Use new macros for namespace scope.
* config/*: Same.
* src/*: Same.
* src/Makefile.am (sources): Remove debug_list.cc, add
compatibility-debug_list-2.cc.
(parallel_sources): Remove parallel_list.cc, add
compatibility-parallel_list-2.cc.
(compatibility-parallel_list-2.[o,lo]): New rule.
* src/Makefile.in: Regenerate.
* src/debug_list.cc: Remove.
* src/parallel_list.cc: Remove.
* src/compatibility-list-2.cc: New.
* src/compatibility-debug_list-2.cc: New.
* src/compatibility-parallel_list-2.cc: New.
* doc/doxygen/user.cfg.in: Adjust macros.
* testsuite/20_util/auto_ptr/assign_neg.cc: Adjust line numbers, macros.
* testsuite/20_util/declval/requirements/1_neg.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg1.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg2.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg3.cc: Same.
* testsuite/20_util/forward/c_neg.cc: Same.
* testsuite/20_util/forward/f_neg.cc: Same.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Same.
* testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Same.
* testsuite/20_util/shared_ptr/cons/43820_neg.cc: Same.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/forward_list/capacity/1.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
assign_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
insert_neg.cc: Same.
* testsuite/23_containers/list/capacity/29134.cc: Same.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/vector/bool/capacity/29134.cc: Same.
* testsuite/23_containers/vector/bool/modifiers/insert/31370.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc: Same.
* testsuite/25_algorithms/sort/35588.cc: Same.
* testsuite/27_io/ios_base/cons/assign_neg.cc: Same.
* testsuite/27_io/ios_base/cons/copy_neg.cc: Same.
* testsuite/ext/profile/mutex_extensions_neg.cc: Same.
* testsuite/ext/profile/profiler_algos.cc: Same.
* testsuite/ext/type_traits/add_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/add_unsigned_integer_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_integer_neg.cc: Same.
* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc: Same.
From-SVN: r169421
2011-01-30 23:39:36 +01:00
|
|
|
_GLIBCXX_END_NAMESPACE_VERSION
|
|
|
|
} // namespace
|
2007-10-06 04:33:12 +02:00
|
|
|
|
2007-10-29 02:59:49 +01:00
|
|
|
#define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) std::make_move_iterator(_Iter)
|
2011-06-07 18:11:36 +02:00
|
|
|
#define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) \
|
|
|
|
std::__make_move_if_noexcept_iterator(_Iter)
|
2007-10-29 02:59:49 +01:00
|
|
|
#else
|
|
|
|
#define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) (_Iter)
|
2011-06-07 18:11:36 +02:00
|
|
|
#define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) (_Iter)
|
2007-10-06 04:33:12 +02:00
|
|
|
#endif // __GXX_EXPERIMENTAL_CXX0X__
|
|
|
|
|
2005-12-19 01:56:05 +01:00
|
|
|
#endif
|