gcc/libstdc++-v3/include/debug/safe_iterator.h
Benjamin Kosnik 78a5388739 throw_allocator.h: Consistent @file markup.
2006-11-29  Benjamin Kosnik  <bkoz@redhat.com>

	* include/ext/throw_allocator.h: Consistent @file markup.
	* include/ext/type_traits.h: Same.
	* include/debug/hash_map: Same.
	* include/debug/hash_multimap.h: Same.
	* include/debug/set.h: Same.
	* include/debug/hash_set.h: Same.
	* include/debug/formatter.h: Same.
	* include/debug/bitset: Same.
	* include/debug/set: Same.
	* include/debug/multiset.h: Same.
	* include/debug/safe_sequence.h: Same.
	* include/debug/hash_set: Same.
	* include/debug/functions.h: Same.
	* include/debug/safe_base.h: Same.
	* include/debug/hash_multiset.h: Same.
	* include/debug/safe_iterator.tcc: Same.
	* include/debug/vector: Same.
	* include/debug/map.h: Same.
	* include/debug/deque: Same.
	* include/debug/hash_map.h: Same.
	* include/debug/string: Same.
	* include/debug/macros.h: Same.
	* include/debug/list: Same.
	* include/debug/debug.h: Same.
	* include/debug/map: Same. 
	* include/debug/safe_iterator.h: Same.
	* include/debug/multimap.h: Same.
	* config/cpu/generic/atomicity_mutex/atomicity.h: Same.
	* config/cpu/generic/atomicity_builtins/atomicity.h: Same.
	* config/cpu/generic/atomic_word.h: Same.
	* include/tr1/memory: Same.
	* include/tr1/random: Same.	
	* include/std/std_queue.h: Same.
	* include/std/std_iterator.h: Same.
	* include/std/std_bitset.h: Same.
	* include/std/std_set.h: Same.
	* include/std/std_vector.h: Same.
	* include/std/std_deque.h: Same.
	* include/std/std_utility.h: Same.
	* include/std/std_stack.h: Same.
	* include/std/std_string.h: Same.
	* include/std/std_list.h: Same.
	* include/std/std_map.h: Same.
	* libsupc++/typeinfo: Same.
	* libsupc++/exception: Same.
	* libsupc++/exception_defines.h: Same.
	* libsupc++/new: Same.
	
	* include/ext/bitmap_allocator.h: Change namespace __balloc to
	__detail.
	* src/bitmap_allocator.cc: Same.
	
	* include/bits/cpp_type_traits.h: Change __true_type and
	__false_type from global to namespace std scope.
	* include/ext/slist: Same.
	* include/ext/vstring.h: Same.
	* include/ext/vstring.tcc: Same.
	* include/ext/rc_string_base.h: Same.
	* include/ext/sso_string_base.h: Same.

	* include/bits/codecvt.h: Adjust markup so that correct namespace
	scope information is in all files.
	* include/bits/locale_facets.h: Same. Include ctype_base directly.
	* config/os/windiss/ctype_base.h: Add in namespace markup.
	* config/os/newlib/ctype_base.h: Same.
	* config/os/aix/ctype_base.h: Same.
	* config/os/vxworks/ctype_base.h: Same.
	* config/os/hpux/ctype_base.h: Same.
	* config/os/mingw32/ctype_base.h: Same.
	* config/os/gnu-linux/ctype_base.h: Same.
	* config/os/tpf/ctype_base.h: Same.
	* config/os/uclibc/ctype_base.h: Same.
	* config/os/djgpp/ctype_base.h: Same.
	* config/os/qnx/qnx6.1/ctype_base.h: Same.
	* config/os/bsd/netbsd/ctype_base.h: Same.
	* config/os/bsd/darwin/ctype_base.h: Same.
	* config/os/bsd/freebsd/ctype_base.h: Same.
	* config/os/irix/irix5.2/ctype_base.h: Same.
	* config/os/irix/irix6.5/ctype_base.h: Same.
	* config/os/solaris/solaris2.5/ctype_base.h: Same.
	* config/os/solaris/solaris2.6/ctype_base.h: Same.
	* config/os/solaris/solaris2.7/ctype_base.h: Same.
	* config/os/generic/ctype_base.h: Same.
	* include/tr1/mu_iterate.h: Same.
	* include/tr1/tuple: Same.
	* include/tr1/tuple_iterate.h: Same.
	* include/tr1/tuple_defs.h: Same.
	* include/tr1/random.tcc: Same.
	* include/tr1/functional: Same.
	* include/tr1/functional_iterate.h: Same.
	
	* testsuite/ext/type_traits/remove_unsigned_integer_neg.cc: Line
	number changes.	
	* testsuite/ext/type_traits/add_unsigned_floating_neg.cc: Same.
	* testsuite/ext/type_traits/remove_unsigned_floating_neg.cc: Same.
	* testsuite/ext/type_traits/add_unsigned_integer_neg.cc: Same.

	* docs/doxygen/user.cfg.in: Update to doxygen 1.5.1.
	* docs/html/17_intro/license.html: Updated info for generated docs.
	* docs/doxygen/guide.html: Adjust.
	* docs/doxygen/run_doxygen: Adjust.
	* docs/doxygen/mainpage.html: Same.
	* docs/doxygen/doxygroups.cc: Same.
	* docs/doxygen/Intro.3: Same.
	* docs/doxygen/tables.html: Same.

From-SVN: r119334
2006-11-29 20:59:22 +00:00

649 lines
21 KiB
C++

// Safe iterator implementation -*- C++ -*-
// Copyright (C) 2003, 2004, 2005, 2006
// 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 2, 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.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
/** @file debug/safe_iterator.h
* This file is a GNU debug extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_DEBUG_SAFE_ITERATOR_H
#define _GLIBCXX_DEBUG_SAFE_ITERATOR_H 1
#include <debug/debug.h>
#include <debug/macros.h>
#include <debug/functions.h>
#include <debug/formatter.h>
#include <debug/safe_base.h>
#include <bits/stl_pair.h>
#include <ext/type_traits.h>
namespace __gnu_debug
{
/** Iterators that derive from _Safe_iterator_base but that aren't
* _Safe_iterators can be determined singular or non-singular via
* _Safe_iterator_base.
*/
inline bool
__check_singular_aux(const _Safe_iterator_base* __x)
{ return __x->_M_singular(); }
/** \brief Safe iterator wrapper.
*
* The class template %_Safe_iterator is a wrapper around an
* iterator that tracks the iterator's movement among sequences and
* checks that operations performed on the "safe" iterator are
* legal. In additional to the basic iterator operations (which are
* validated, and then passed to the underlying iterator),
* %_Safe_iterator has member functions for iterator invalidation,
* attaching/detaching the iterator from sequences, and querying
* the iterator's state.
*/
template<typename _Iterator, typename _Sequence>
class _Safe_iterator : public _Safe_iterator_base
{
typedef _Safe_iterator _Self;
/** The precision to which we can calculate the distance between
* two iterators.
*/
enum _Distance_precision
{
__dp_equality, //< Can compare iterator equality, only
__dp_sign, //< Can determine equality and ordering
__dp_exact //< Can determine distance precisely
};
/// The underlying iterator
_Iterator _M_current;
/// Determine if this is a constant iterator.
bool
_M_constant() const
{
typedef typename _Sequence::const_iterator const_iterator;
return __is_same<const_iterator, _Safe_iterator>::value;
}
typedef std::iterator_traits<_Iterator> _Traits;
public:
typedef _Iterator _Base_iterator;
typedef typename _Traits::iterator_category iterator_category;
typedef typename _Traits::value_type value_type;
typedef typename _Traits::difference_type difference_type;
typedef typename _Traits::reference reference;
typedef typename _Traits::pointer pointer;
/// @post the iterator is singular and unattached
_Safe_iterator() : _M_current() { }
/**
* @brief Safe iterator construction from an unsafe iterator and
* its sequence.
*
* @pre @p seq is not NULL
* @post this is not singular
*/
_Safe_iterator(const _Iterator& __i, const _Sequence* __seq)
: _Safe_iterator_base(__seq, _M_constant()), _M_current(__i)
{
_GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
_M_message(__msg_init_singular)
._M_iterator(*this, "this"));
}
/**
* @brief Copy construction.
* @pre @p x is not singular
*/
_Safe_iterator(const _Safe_iterator& __x)
: _Safe_iterator_base(__x, _M_constant()), _M_current(__x._M_current)
{
_GLIBCXX_DEBUG_VERIFY(!__x._M_singular(),
_M_message(__msg_init_copy_singular)
._M_iterator(*this, "this")
._M_iterator(__x, "other"));
}
/**
* @brief Converting constructor from a mutable iterator to a
* constant iterator.
*
* @pre @p x is not singular
*/
template<typename _MutableIterator>
_Safe_iterator(
const _Safe_iterator<_MutableIterator,
typename __gnu_cxx::__enable_if<(std::__are_same<_MutableIterator,
typename _Sequence::iterator::_Base_iterator>::__value),
_Sequence>::__type>& __x)
: _Safe_iterator_base(__x, _M_constant()), _M_current(__x.base())
{
_GLIBCXX_DEBUG_VERIFY(!__x._M_singular(),
_M_message(__msg_init_const_singular)
._M_iterator(*this, "this")
._M_iterator(__x, "other"));
}
/**
* @brief Copy assignment.
* @pre @p x is not singular
*/
_Safe_iterator&
operator=(const _Safe_iterator& __x)
{
_GLIBCXX_DEBUG_VERIFY(!__x._M_singular(),
_M_message(__msg_copy_singular)
._M_iterator(*this, "this")
._M_iterator(__x, "other"));
_M_current = __x._M_current;
this->_M_attach(static_cast<_Sequence*>(__x._M_sequence));
return *this;
}
/**
* @brief Iterator dereference.
* @pre iterator is dereferenceable
*/
reference
operator*() const
{
_GLIBCXX_DEBUG_VERIFY(this->_M_dereferenceable(),
_M_message(__msg_bad_deref)
._M_iterator(*this, "this"));
return *_M_current;
}
/**
* @brief Iterator dereference.
* @pre iterator is dereferenceable
* @todo Make this correct w.r.t. iterators that return proxies
* @todo Use addressof() instead of & operator
*/
pointer
operator->() const
{
_GLIBCXX_DEBUG_VERIFY(this->_M_dereferenceable(),
_M_message(__msg_bad_deref)
._M_iterator(*this, "this"));
return &*_M_current;
}
// ------ Input iterator requirements ------
/**
* @brief Iterator preincrement
* @pre iterator is incrementable
*/
_Safe_iterator&
operator++()
{
_GLIBCXX_DEBUG_VERIFY(this->_M_incrementable(),
_M_message(__msg_bad_inc)
._M_iterator(*this, "this"));
++_M_current;
return *this;
}
/**
* @brief Iterator postincrement
* @pre iterator is incrementable
*/
_Safe_iterator
operator++(int)
{
_GLIBCXX_DEBUG_VERIFY(this->_M_incrementable(),
_M_message(__msg_bad_inc)
._M_iterator(*this, "this"));
_Safe_iterator __tmp(*this);
++_M_current;
return __tmp;
}
// ------ Bidirectional iterator requirements ------
/**
* @brief Iterator predecrement
* @pre iterator is decrementable
*/
_Safe_iterator&
operator--()
{
_GLIBCXX_DEBUG_VERIFY(this->_M_decrementable(),
_M_message(__msg_bad_dec)
._M_iterator(*this, "this"));
--_M_current;
return *this;
}
/**
* @brief Iterator postdecrement
* @pre iterator is decrementable
*/
_Safe_iterator
operator--(int)
{
_GLIBCXX_DEBUG_VERIFY(this->_M_decrementable(),
_M_message(__msg_bad_dec)
._M_iterator(*this, "this"));
_Safe_iterator __tmp(*this);
--_M_current;
return __tmp;
}
// ------ Random access iterator requirements ------
reference
operator[](const difference_type& __n) const
{
_GLIBCXX_DEBUG_VERIFY(this->_M_can_advance(__n)
&& this->_M_can_advance(__n+1),
_M_message(__msg_iter_subscript_oob)
._M_iterator(*this)._M_integer(__n));
return _M_current[__n];
}
_Safe_iterator&
operator+=(const difference_type& __n)
{
_GLIBCXX_DEBUG_VERIFY(this->_M_can_advance(__n),
_M_message(__msg_advance_oob)
._M_iterator(*this)._M_integer(__n));
_M_current += __n;
return *this;
}
_Safe_iterator
operator+(const difference_type& __n) const
{
_Safe_iterator __tmp(*this);
__tmp += __n;
return __tmp;
}
_Safe_iterator&
operator-=(const difference_type& __n)
{
_GLIBCXX_DEBUG_VERIFY(this->_M_can_advance(-__n),
_M_message(__msg_retreat_oob)
._M_iterator(*this)._M_integer(__n));
_M_current += -__n;
return *this;
}
_Safe_iterator
operator-(const difference_type& __n) const
{
_Safe_iterator __tmp(*this);
__tmp -= __n;
return __tmp;
}
// ------ Utilities ------
/**
* @brief Return the underlying iterator
*/
_Iterator
base() const { return _M_current; }
/**
* @brief Conversion to underlying non-debug iterator to allow
* better interaction with non-debug containers.
*/
operator _Iterator() const { return _M_current; }
/** Attach iterator to the given sequence. */
void
_M_attach(const _Sequence* __seq)
{
_Safe_iterator_base::_M_attach(const_cast<_Sequence*>(__seq),
_M_constant());
}
/** Likewise, but not thread-safe. */
void
_M_attach_single(const _Sequence* __seq)
{
_Safe_iterator_base::_M_attach_single(const_cast<_Sequence*>(__seq),
_M_constant());
}
/** Invalidate the iterator, making it singular. */
void
_M_invalidate();
/** Likewise, but not thread-safe. */
void
_M_invalidate_single();
/// Is the iterator dereferenceable?
bool
_M_dereferenceable() const
{ return !this->_M_singular() && !_M_is_end(); }
/// Is the iterator incrementable?
bool
_M_incrementable() const { return this->_M_dereferenceable(); }
// Is the iterator decrementable?
bool
_M_decrementable() const { return !_M_singular() && !_M_is_begin(); }
// Can we advance the iterator @p __n steps (@p __n may be negative)
bool
_M_can_advance(const difference_type& __n) const;
// Is the iterator range [*this, __rhs) valid?
template<typename _Other>
bool
_M_valid_range(const _Safe_iterator<_Other, _Sequence>& __rhs) const;
// The sequence this iterator references.
const _Sequence*
_M_get_sequence() const
{ return static_cast<const _Sequence*>(_M_sequence); }
/** Determine the distance between two iterators with some known
* precision.
*/
template<typename _Iterator1, typename _Iterator2>
static std::pair<difference_type, _Distance_precision>
_M_get_distance(const _Iterator1& __lhs, const _Iterator2& __rhs)
{
typedef typename std::iterator_traits<_Iterator1>::iterator_category
_Category;
return _M_get_distance(__lhs, __rhs, _Category());
}
template<typename _Iterator1, typename _Iterator2>
static std::pair<difference_type, _Distance_precision>
_M_get_distance(const _Iterator1& __lhs, const _Iterator2& __rhs,
std::random_access_iterator_tag)
{
return std::make_pair(__rhs.base() - __lhs.base(), __dp_exact);
}
template<typename _Iterator1, typename _Iterator2>
static std::pair<difference_type, _Distance_precision>
_M_get_distance(const _Iterator1& __lhs, const _Iterator2& __rhs,
std::forward_iterator_tag)
{
return std::make_pair(__lhs.base() == __rhs.base()? 0 : 1,
__dp_equality);
}
/// Is this iterator equal to the sequence's begin() iterator?
bool _M_is_begin() const
{ return *this == static_cast<const _Sequence*>(_M_sequence)->begin(); }
/// Is this iterator equal to the sequence's end() iterator?
bool _M_is_end() const
{ return *this == static_cast<const _Sequence*>(_M_sequence)->end(); }
};
template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool
operator==(const _Safe_iterator<_IteratorL, _Sequence>& __lhs,
const _Safe_iterator<_IteratorR, _Sequence>& __rhs)
{
_GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
_M_message(__msg_iter_compare_bad)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
_GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
_M_message(__msg_compare_different)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
return __lhs.base() == __rhs.base();
}
template<typename _Iterator, typename _Sequence>
inline bool
operator==(const _Safe_iterator<_Iterator, _Sequence>& __lhs,
const _Safe_iterator<_Iterator, _Sequence>& __rhs)
{
_GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
_M_message(__msg_iter_compare_bad)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
_GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
_M_message(__msg_compare_different)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
return __lhs.base() == __rhs.base();
}
template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool
operator!=(const _Safe_iterator<_IteratorL, _Sequence>& __lhs,
const _Safe_iterator<_IteratorR, _Sequence>& __rhs)
{
_GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
_M_message(__msg_iter_compare_bad)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
_GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
_M_message(__msg_compare_different)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
return __lhs.base() != __rhs.base();
}
template<typename _Iterator, typename _Sequence>
inline bool
operator!=(const _Safe_iterator<_Iterator, _Sequence>& __lhs,
const _Safe_iterator<_Iterator, _Sequence>& __rhs)
{
_GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
_M_message(__msg_iter_compare_bad)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
_GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
_M_message(__msg_compare_different)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
return __lhs.base() != __rhs.base();
}
template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool
operator<(const _Safe_iterator<_IteratorL, _Sequence>& __lhs,
const _Safe_iterator<_IteratorR, _Sequence>& __rhs)
{
_GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
_M_message(__msg_iter_order_bad)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
_GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
_M_message(__msg_order_different)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
return __lhs.base() < __rhs.base();
}
template<typename _Iterator, typename _Sequence>
inline bool
operator<(const _Safe_iterator<_Iterator, _Sequence>& __lhs,
const _Safe_iterator<_Iterator, _Sequence>& __rhs)
{
_GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
_M_message(__msg_iter_order_bad)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
_GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
_M_message(__msg_order_different)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
return __lhs.base() < __rhs.base();
}
template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool
operator<=(const _Safe_iterator<_IteratorL, _Sequence>& __lhs,
const _Safe_iterator<_IteratorR, _Sequence>& __rhs)
{
_GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
_M_message(__msg_iter_order_bad)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
_GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
_M_message(__msg_order_different)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
return __lhs.base() <= __rhs.base();
}
template<typename _Iterator, typename _Sequence>
inline bool
operator<=(const _Safe_iterator<_Iterator, _Sequence>& __lhs,
const _Safe_iterator<_Iterator, _Sequence>& __rhs)
{
_GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
_M_message(__msg_iter_order_bad)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
_GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
_M_message(__msg_order_different)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
return __lhs.base() <= __rhs.base();
}
template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool
operator>(const _Safe_iterator<_IteratorL, _Sequence>& __lhs,
const _Safe_iterator<_IteratorR, _Sequence>& __rhs)
{
_GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
_M_message(__msg_iter_order_bad)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
_GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
_M_message(__msg_order_different)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
return __lhs.base() > __rhs.base();
}
template<typename _Iterator, typename _Sequence>
inline bool
operator>(const _Safe_iterator<_Iterator, _Sequence>& __lhs,
const _Safe_iterator<_Iterator, _Sequence>& __rhs)
{
_GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
_M_message(__msg_iter_order_bad)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
_GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
_M_message(__msg_order_different)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
return __lhs.base() > __rhs.base();
}
template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool
operator>=(const _Safe_iterator<_IteratorL, _Sequence>& __lhs,
const _Safe_iterator<_IteratorR, _Sequence>& __rhs)
{
_GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
_M_message(__msg_iter_order_bad)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
_GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
_M_message(__msg_order_different)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
return __lhs.base() >= __rhs.base();
}
template<typename _Iterator, typename _Sequence>
inline bool
operator>=(const _Safe_iterator<_Iterator, _Sequence>& __lhs,
const _Safe_iterator<_Iterator, _Sequence>& __rhs)
{
_GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
_M_message(__msg_iter_order_bad)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
_GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
_M_message(__msg_order_different)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
return __lhs.base() >= __rhs.base();
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 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 _Sequence>
inline typename _Safe_iterator<_IteratorL, _Sequence>::difference_type
operator-(const _Safe_iterator<_IteratorL, _Sequence>& __lhs,
const _Safe_iterator<_IteratorR, _Sequence>& __rhs)
{
_GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
_M_message(__msg_distance_bad)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
_GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
_M_message(__msg_distance_different)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
return __lhs.base() - __rhs.base();
}
template<typename _Iterator, typename _Sequence>
inline typename _Safe_iterator<_Iterator, _Sequence>::difference_type
operator-(const _Safe_iterator<_Iterator, _Sequence>& __lhs,
const _Safe_iterator<_Iterator, _Sequence>& __rhs)
{
_GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
_M_message(__msg_distance_bad)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
_GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
_M_message(__msg_distance_different)
._M_iterator(__lhs, "lhs")
._M_iterator(__rhs, "rhs"));
return __lhs.base() - __rhs.base();
}
template<typename _Iterator, typename _Sequence>
inline _Safe_iterator<_Iterator, _Sequence>
operator+(typename _Safe_iterator<_Iterator,_Sequence>::difference_type __n,
const _Safe_iterator<_Iterator, _Sequence>& __i)
{ return __i + __n; }
} // namespace __gnu_debug
#ifndef _GLIBCXX_EXPORT_TEMPLATE
# include <debug/safe_iterator.tcc>
#endif
#endif