mirror of
https://github.com/boostorg/iterator.git
synced 2025-06-26 04:21:36 +02:00
Compare commits
18 Commits
boost-1.26
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
abffbb8300 | |||
34c159dd8d | |||
b22a3adc02 | |||
4a24e0f401 | |||
3844edc4bf | |||
fdd1601ba4 | |||
e9b33b336c | |||
2574365b5c | |||
12b9366f33 | |||
4772bb099e | |||
2be5179020 | |||
8cb49713b4 | |||
bd666dc0e9 | |||
57251d58cc | |||
ebcb4d861a | |||
15a7a839f9 | |||
76a307d31e | |||
37aee7c13b |
@ -1,159 +0,0 @@
|
||||
#ifndef BOOST_ITERATOR_CATEGORIES_HPP
|
||||
#define BOOST_ITERATOR_CATEGORIES_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/type_traits/conversion_traits.hpp>
|
||||
#include <boost/type_traits/cv_traits.hpp>
|
||||
#include <boost/pending/ct_if.hpp>
|
||||
#include <boost/detail/iterator.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
// Return Type Categories
|
||||
struct readable_iterator_tag { };
|
||||
struct writable_iterator_tag { };
|
||||
struct swappable_iterator_tag { };
|
||||
struct mutable_lvalue_iterator_tag :
|
||||
virtual public writable_iterator_tag,
|
||||
virtual public readable_iterator_tag { };
|
||||
struct constant_lvalue_iterator_tag :
|
||||
virtual public readable_iterator_tag { };
|
||||
|
||||
// Traversal Categories
|
||||
struct forward_traversal_tag { };
|
||||
struct bidirectional_traversal_tag : public forward_traversal_tag { };
|
||||
struct random_access_traversal_tag : public bidirectional_traversal_tag { };
|
||||
|
||||
struct error_iterator_tag { };
|
||||
|
||||
// Inherit from iterator_base if your iterator defines its own
|
||||
// return_category and traversal_category. Otherwise, the "old style"
|
||||
// iterator category will be mapped to the return_category and
|
||||
// traversal_category.
|
||||
struct new_iterator_base { };
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct return_category_from_nested_type {
|
||||
template <typename Iterator> struct bind {
|
||||
typedef typename Iterator::return_category type;
|
||||
};
|
||||
};
|
||||
|
||||
struct traversal_category_from_nested_type {
|
||||
template <typename Iterator> struct bind {
|
||||
typedef typename Iterator::traversal_category type;
|
||||
};
|
||||
};
|
||||
|
||||
template <typename ValueType>
|
||||
struct choose_lvalue_return {
|
||||
typedef typename ct_if<is_const<ValueType>::value,
|
||||
boost::constant_lvalue_iterator_tag,
|
||||
boost::mutable_lvalue_iterator_tag>::type type;
|
||||
};
|
||||
|
||||
|
||||
template <typename Category, typename ValueType>
|
||||
struct iter_category_to_return {
|
||||
typedef typename ct_if<
|
||||
is_convertible<Category*, std::forward_iterator_tag*>::value,
|
||||
typename choose_lvalue_return<ValueType>::type,
|
||||
typename ct_if<
|
||||
is_convertible<Category*, std::input_iterator_tag*>::value,
|
||||
boost::readable_iterator_tag,
|
||||
typename ct_if<
|
||||
is_convertible<Category*, std::output_iterator_tag*>::value,
|
||||
boost::writable_iterator_tag,
|
||||
boost::error_iterator_tag
|
||||
>::type
|
||||
>::type
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <typename Category>
|
||||
struct iter_category_to_traversal {
|
||||
typedef typename ct_if<
|
||||
is_convertible<Category*, std::random_access_iterator_tag*>::value,
|
||||
random_access_traversal_tag,
|
||||
typename ct_if<
|
||||
is_convertible<Category*, std::bidirectional_iterator_tag*>::value,
|
||||
bidirectional_traversal_tag,
|
||||
forward_traversal_tag
|
||||
>::type
|
||||
>::type type;
|
||||
};
|
||||
|
||||
struct return_category_from_old_traits {
|
||||
template <typename Iterator> class bind {
|
||||
typedef boost::detail::iterator_traits<Iterator> OldTraits;
|
||||
typedef typename OldTraits::iterator_category Cat;
|
||||
typedef typename OldTraits::value_type value_type;
|
||||
public:
|
||||
typedef iter_category_to_return<Cat, value_type>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
struct traversal_category_from_old_traits {
|
||||
template <typename Iterator> class bind {
|
||||
typedef boost::detail::iterator_traits<Iterator> OldTraits;
|
||||
typedef typename OldTraits::iterator_category Cat;
|
||||
public:
|
||||
typedef iter_category_to_traversal<Cat>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
class choose_return_category {
|
||||
typedef typename ct_if<is_convertible<Iterator*,
|
||||
new_iterator_base*>::value,
|
||||
return_category_from_nested_type,
|
||||
return_category_from_old_traits>::type Choice;
|
||||
public:
|
||||
typedef typename Choice:: template bind<Iterator>::type type;
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
class choose_traversal_category {
|
||||
typedef typename ct_if<is_convertible<Iterator*,
|
||||
new_iterator_base*>::value,
|
||||
traversal_category_from_nested_type,
|
||||
traversal_category_from_old_traits>::type Choice;
|
||||
public:
|
||||
typedef typename Choice:: template bind<Iterator>::type type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <class Iterator>
|
||||
struct return_category {
|
||||
typedef typename detail::choose_return_category<Iterator>::type type;
|
||||
};
|
||||
|
||||
|
||||
template <class Iterator>
|
||||
struct traversal_category {
|
||||
typedef typename detail::choose_traversal_category<Iterator>::type type;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
|
||||
template <typename T>
|
||||
struct return_category<T*>
|
||||
{
|
||||
typedef typename ct_if<is_const<T>::value,
|
||||
constant_lvalue_iterator_tag,
|
||||
mutable_lvalue_iterator_tag>::type type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct traversal_category<T*>
|
||||
{
|
||||
typedef random_access_traversal_tag type;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ITERATOR_CATEGORIES_HPP
|
@ -1,172 +0,0 @@
|
||||
#ifndef BOOST_ITERATOR_CONCEPTS_HPP
|
||||
#define BOOST_ITERATOR_CONCEPTS_HPP
|
||||
|
||||
#include <boost/concept_check.hpp>
|
||||
#include <boost/iterator_categories.hpp>
|
||||
#include <boost/type_traits/conversion_traits.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
namespace boost_concepts {
|
||||
// Used a different namespace here (instead of "boost") so that the
|
||||
// concept descriptions do not take for granted the names in
|
||||
// namespace boost.
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// Iterator Access Concepts
|
||||
|
||||
template <typename Iterator>
|
||||
class ReadableIteratorConcept {
|
||||
public:
|
||||
typedef typename std::iterator_traits<Iterator>::value_type value_type;
|
||||
typedef typename std::iterator_traits<Iterator>::reference reference;
|
||||
typedef typename boost::return_category<Iterator>::type return_category;
|
||||
|
||||
void constraints() {
|
||||
boost::function_requires< boost::SGIAssignableConcept<Iterator> >();
|
||||
boost::function_requires< boost::EqualityComparableConcept<Iterator> >();
|
||||
boost::function_requires<
|
||||
boost::DefaultConstructibleConcept<Iterator> >();
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_convertible<return_category*,
|
||||
boost::readable_iterator_tag*>::value));
|
||||
|
||||
reference r = *i; // or perhaps read(x)
|
||||
value_type v(r);
|
||||
boost::ignore_unused_variable_warning(v);
|
||||
}
|
||||
Iterator i;
|
||||
};
|
||||
|
||||
template <typename Iterator, typename ValueType>
|
||||
class WritableIteratorConcept {
|
||||
public:
|
||||
typedef typename boost::return_category<Iterator>::type return_category;
|
||||
|
||||
void constraints() {
|
||||
boost::function_requires< boost::SGIAssignableConcept<Iterator> >();
|
||||
boost::function_requires< boost::EqualityComparableConcept<Iterator> >();
|
||||
boost::function_requires<
|
||||
boost::DefaultConstructibleConcept<Iterator> >();
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_convertible<return_category*,
|
||||
boost::writable_iterator_tag*>::value));
|
||||
|
||||
*i = v; // a good alternative could be something like write(x, v)
|
||||
}
|
||||
ValueType v;
|
||||
Iterator i;
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
class ConstantLvalueIteratorConcept {
|
||||
public:
|
||||
typedef typename std::iterator_traits<Iterator>::value_type value_type;
|
||||
typedef typename std::iterator_traits<Iterator>::reference reference;
|
||||
typedef typename boost::return_category<Iterator>::type return_category;
|
||||
|
||||
void constraints() {
|
||||
boost::function_requires< ReadableIteratorConcept<Iterator> >();
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_convertible<return_category*,
|
||||
boost::constant_lvalue_iterator_tag*>::value));
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<reference,
|
||||
const value_type&>::value));
|
||||
|
||||
reference v = *i;
|
||||
boost::ignore_unused_variable_warning(v);
|
||||
}
|
||||
Iterator i;
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
class MutableLvalueIteratorConcept {
|
||||
public:
|
||||
typedef typename std::iterator_traits<Iterator>::value_type value_type;
|
||||
typedef typename std::iterator_traits<Iterator>::reference reference;
|
||||
typedef typename boost::return_category<Iterator>::type return_category;
|
||||
|
||||
void constraints() {
|
||||
boost::function_requires< ReadableIteratorConcept<Iterator> >();
|
||||
boost::function_requires<
|
||||
WritableIteratorConcept<Iterator, value_type> >();
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_convertible<return_category*,
|
||||
boost::mutable_lvalue_iterator_tag*>::value));
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<reference, value_type&>::value));
|
||||
|
||||
reference v = *i;
|
||||
boost::ignore_unused_variable_warning(v);
|
||||
}
|
||||
Iterator i;
|
||||
};
|
||||
|
||||
//===========================================================================
|
||||
// Iterator Traversal Concepts
|
||||
|
||||
template <typename Iterator>
|
||||
class ForwardIteratorConcept {
|
||||
public:
|
||||
typedef typename boost::traversal_category<Iterator>::type traversal_category;
|
||||
|
||||
void constraints() {
|
||||
boost::function_requires< boost::SGIAssignableConcept<Iterator> >();
|
||||
boost::function_requires< boost::EqualityComparableConcept<Iterator> >();
|
||||
boost::function_requires<
|
||||
boost::DefaultConstructibleConcept<Iterator> >();
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_convertible<traversal_category*,
|
||||
boost::forward_traversal_tag*>::value));
|
||||
++i;
|
||||
(void)i++;
|
||||
}
|
||||
Iterator i;
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
class BidirectionalIteratorConcept {
|
||||
public:
|
||||
typedef typename boost::traversal_category<Iterator>::type traversal_category;
|
||||
|
||||
void constraints() {
|
||||
boost::function_requires< ForwardIteratorConcept<Iterator> >();
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_convertible<traversal_category*,
|
||||
boost::bidirectional_traversal_tag*>::value));
|
||||
|
||||
--i;
|
||||
(void)i--;
|
||||
}
|
||||
Iterator i;
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
class RandomAccessIteratorConcept {
|
||||
public:
|
||||
typedef typename boost::traversal_category<Iterator>::type traversal_category;
|
||||
typedef typename std::iterator_traits<Iterator>::difference_type
|
||||
difference_type;
|
||||
|
||||
void constraints() {
|
||||
boost::function_requires< BidirectionalIteratorConcept<Iterator> >();
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_convertible<traversal_category*,
|
||||
boost::random_access_traversal_tag*>::value));
|
||||
|
||||
i += n;
|
||||
i = i + n;
|
||||
i = n + i;
|
||||
i -= n;
|
||||
i = i - n;
|
||||
n = i - j;
|
||||
}
|
||||
difference_type n;
|
||||
Iterator i, j;
|
||||
};
|
||||
|
||||
} // namespace boost_concepts
|
||||
|
||||
|
||||
#endif // BOOST_ITERATOR_CONCEPTS_HPP
|
@ -1,73 +0,0 @@
|
||||
#include <boost/iterator_concepts.hpp>
|
||||
#include <boost/operators.hpp>
|
||||
|
||||
struct new_iterator
|
||||
: public boost::iterator<std::random_access_iterator_tag, int>,
|
||||
public boost::new_iterator_base
|
||||
{
|
||||
typedef boost::random_access_traversal_tag traversal_category;
|
||||
typedef boost::mutable_lvalue_iterator_tag return_category;
|
||||
|
||||
int& operator*() const { return *m_x; }
|
||||
new_iterator& operator++() { return *this; }
|
||||
new_iterator operator++(int) { return *this; }
|
||||
new_iterator& operator--() { return *this; }
|
||||
new_iterator operator--(int) { return *this; }
|
||||
new_iterator& operator+=(std::ptrdiff_t) { return *this; }
|
||||
new_iterator operator+(std::ptrdiff_t) { return *this; }
|
||||
new_iterator& operator-=(std::ptrdiff_t) { return *this; }
|
||||
std::ptrdiff_t operator-(const new_iterator&) const { return 0; }
|
||||
new_iterator operator-(std::ptrdiff_t) const { return *this; }
|
||||
bool operator==(const new_iterator&) const { return false; }
|
||||
bool operator!=(const new_iterator&) const { return false; }
|
||||
bool operator<(const new_iterator&) const { return false; }
|
||||
int* m_x;
|
||||
};
|
||||
new_iterator operator+(std::ptrdiff_t, new_iterator x) { return x; }
|
||||
|
||||
struct old_iterator
|
||||
: public boost::iterator<std::random_access_iterator_tag, int>
|
||||
{
|
||||
int& operator*() const { return *m_x; }
|
||||
old_iterator& operator++() { return *this; }
|
||||
old_iterator operator++(int) { return *this; }
|
||||
old_iterator& operator--() { return *this; }
|
||||
old_iterator operator--(int) { return *this; }
|
||||
old_iterator& operator+=(std::ptrdiff_t) { return *this; }
|
||||
old_iterator operator+(std::ptrdiff_t) { return *this; }
|
||||
old_iterator& operator-=(std::ptrdiff_t) { return *this; }
|
||||
old_iterator operator-(std::ptrdiff_t) const { return *this; }
|
||||
std::ptrdiff_t operator-(const old_iterator&) const { return 0; }
|
||||
bool operator==(const old_iterator&) const { return false; }
|
||||
bool operator!=(const old_iterator&) const { return false; }
|
||||
bool operator<(const old_iterator&) const { return false; }
|
||||
int* m_x;
|
||||
};
|
||||
old_iterator operator+(std::ptrdiff_t, old_iterator x) { return x; }
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
boost::function_requires<
|
||||
boost_concepts::MutableLvalueIteratorConcept<int*> >();
|
||||
boost::function_requires<
|
||||
boost_concepts::RandomAccessIteratorConcept<int*> >();
|
||||
|
||||
boost::function_requires<
|
||||
boost_concepts::ConstantLvalueIteratorConcept<const int*> >();
|
||||
boost::function_requires<
|
||||
boost_concepts::RandomAccessIteratorConcept<const int*> >();
|
||||
#endif
|
||||
|
||||
boost::function_requires<
|
||||
boost_concepts::MutableLvalueIteratorConcept<new_iterator> >();
|
||||
boost::function_requires<
|
||||
boost_concepts::RandomAccessIteratorConcept<new_iterator> >();
|
||||
|
||||
boost::function_requires<
|
||||
boost_concepts::MutableLvalueIteratorConcept<old_iterator> >();
|
||||
boost::function_requires<
|
||||
boost_concepts::RandomAccessIteratorConcept<old_iterator> >();
|
||||
return 0;
|
||||
}
|
@ -1,160 +0,0 @@
|
||||
<html>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2000,2001
|
||||
--
|
||||
-- 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 appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. I make no representations about the
|
||||
-- suitability of this software for any purpose. It is provided "as is"
|
||||
-- without express or implied warranty.
|
||||
-->
|
||||
<head>
|
||||
<title>Boost Iterator Traits</title>
|
||||
</head>
|
||||
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
<BR Clear>
|
||||
|
||||
<h1>Boost Iterator Category Traits</h1>
|
||||
Header <tt><a href="../../boost/iterator_categories.hpp">boost/iterator_categories.hpp</a></tt>
|
||||
|
||||
<p>
|
||||
The <tt>boost::traversal_category</tt> and
|
||||
<tt>boost::return_category</tt> traits classes provides access to the
|
||||
category tags for iterators that model the Boost <a
|
||||
href="./iterator_concepts.htm">Iterator Concepts</a>, which are a
|
||||
replacement for the iterator requirements in the C++ standard. The
|
||||
other associated types of the Boost iterator concepts are accessed
|
||||
through the <tt>std::iterator_traits</tt> class.
|
||||
|
||||
<ul>
|
||||
<li><tt>traversal_category<Iter>::type</tt> Can the iterator go forward, backward, etc.?
|
||||
<li><tt>return_category<Iter>::type</tt> Is the iterator read or write only?
|
||||
Is the dereferenced type an lvalue?
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
An important feature of the <tt>boost::traversal_category</tt> and
|
||||
<tt>boost::return_category</tt> classes is that they are <b>backwards
|
||||
compatible</b>, i.e., they automatically work for iterators for which
|
||||
there are valid definitions of <tt>std::iterator_traits</tt>. The old
|
||||
<tt>iterator_category</tt> is mapped to the appropriate traversal and
|
||||
return categories.
|
||||
|
||||
<p>
|
||||
When creating a new iterator type that is meant to work with
|
||||
<tt>boost::traversal_category</tt> and
|
||||
<tt>boost::return_category</tt>, you can either create a
|
||||
specialization of these classes for your iterator type, or you can
|
||||
provide all the necessary associated types as nested typedefs. In
|
||||
this case, your iterator class will need to inherit from
|
||||
<tt>new_iterator_base</tt> to let the category traits know
|
||||
that it will be able to find typedefs for <tt>traversal_category</tt>
|
||||
and <tt>return_category</tt> in you iterator class.
|
||||
|
||||
|
||||
Each of the new iterator requirements will need a category tag.
|
||||
|
||||
<pre>
|
||||
namespace boost {
|
||||
|
||||
// Return Type Categories
|
||||
struct readable_iterator_tag { };
|
||||
struct writable_iterator_tag { };
|
||||
struct swappable_iterator_tag { };
|
||||
struct mutable_lvalue_iterator_tag : virtual public writable_iterator_tag,
|
||||
virtual public readable_iterator_tag { };
|
||||
struct constant_lvalue_iterator_tag : public readable_iterator_tag { };
|
||||
|
||||
// Traversal Categories
|
||||
struct forward_traversal_tag { };
|
||||
struct bidirectional_traversal_tag : public forward_traversal_tag { };
|
||||
struct random_access_traversal_tag : public bidirectional_traversal_tag { };
|
||||
|
||||
}
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
The following is pseudo-code for the iterator category traits classes.
|
||||
|
||||
<pre>
|
||||
namespace boost {
|
||||
|
||||
<i>// Inherit from iterator_base if your iterator defines its own
|
||||
// return_category and traversal_category. Otherwise, the "old style"
|
||||
// iterator category will be mapped to the return_category and
|
||||
// traversal_category.</i>
|
||||
struct new_iterator_base { };
|
||||
|
||||
template <typename Iterator>
|
||||
struct return_category
|
||||
{
|
||||
<b><i>// Pseudo-code</i></b>
|
||||
if (Iterator inherits from new_iterator_base) {
|
||||
typedef typename Iterator::return_category type;
|
||||
} else {
|
||||
typedef std::iterator_traits<Iterator> OldTraits;
|
||||
typedef typename OldTraits::iterator_category Cat;
|
||||
if (Cat inherits from std::forward_iterator_tag)
|
||||
if (is-const(T))
|
||||
typedef boost::constant_lvalue_iterator_tag type;
|
||||
else
|
||||
typedef boost::mutable_lvalue_iterator_tag type;
|
||||
else if (Cat inherits from std::input_iterator_tag)
|
||||
typedef boost::readable_iterator_tag type;
|
||||
else if (Cat inherits from std::output_iterator_tag)
|
||||
typedef boost::writable_iterator_tag type;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct return_category<T*>
|
||||
{
|
||||
<b><i>// Pseudo-code</i></b>
|
||||
if (is-const(T))
|
||||
typedef boost::constant_lvalue_iterator_tag type;
|
||||
else
|
||||
typedef boost::mutable_lvalue_iterator_tag type;
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
struct traversal_category
|
||||
{
|
||||
<b><i>// Pseudo-code</i></b>
|
||||
if (Iterator inherits from new_iterator_base) {
|
||||
typedef typename Iterator::traversal_category type;
|
||||
} else {
|
||||
typedef std::iterator_traits<Iterator> OldTraits;
|
||||
typedef typename OldTraits::iterator_category Cat;
|
||||
|
||||
if (Cat inherits from std::random_access_iterator_tag)
|
||||
typedef boost::random_access_traversal_tag type;
|
||||
else if (Cat inherits from std::bidirectional_iterator_tag)
|
||||
typedef boost::bidirectional_traversal_tag type;
|
||||
else if (Cat inherits from std::forward_iterator_tag)
|
||||
typedef boost::forward_traversal_tag type;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct traversal_category<T*>
|
||||
{
|
||||
typedef boost::random_access_traversal_tag type;
|
||||
};
|
||||
|
||||
}
|
||||
</pre>
|
||||
|
||||
<hr>
|
||||
<address><a href="mailto:jsiek@lsc.nd.edu">jeremy siek</a></address>
|
||||
<!-- Created: Sun Mar 18 14:06:57 EST 2001 -->
|
||||
<!-- hhmts start -->
|
||||
Last modified: Mon Mar 19 12:59:30 EST 2001
|
||||
<!-- hhmts end -->
|
||||
</body>
|
||||
</html>
|
@ -1,37 +0,0 @@
|
||||
#FIG 3.2
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
1200 2
|
||||
6 150 2325 4275 4350
|
||||
2 1 0 1 0 7 100 0 -1 4.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
1725 4050 1725 3450
|
||||
2 1 0 1 0 7 100 0 -1 4.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
1725 3150 1725 2550
|
||||
4 0 0 100 0 19 18 0.0000 4 210 3180 375 2550 ForwardTraversalIterator\001
|
||||
4 0 0 100 0 19 18 0.0000 4 210 3765 225 3450 BidirectionalTraversalIterator\001
|
||||
4 0 0 100 0 19 18 0.0000 4 210 4125 150 4350 RandomAccessTraversalIterator\001
|
||||
-6
|
||||
2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
4800 3600 4800 2400
|
||||
2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
6900 3000 5400 2400
|
||||
2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
6900 3000 7500 2400
|
||||
2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
6900 3000 9075 2475
|
||||
4 0 0 100 0 19 18 0.0000 4 210 2040 6600 2400 WritableIterator\001
|
||||
4 0 0 100 0 19 18 0.0000 4 210 2145 3900 2400 ReadableIterator\001
|
||||
4 0 0 50 0 19 18 0.0000 4 210 2835 5700 3300 MutableLvalueIterator\001
|
||||
4 0 0 50 0 19 18 0.0000 4 270 2355 9075 2400 SwappableIterator\001
|
||||
4 0 0 50 0 19 18 0.0000 4 210 2970 3825 3900 ConstantLvalueIterator\001
|
Binary file not shown.
Before Width: | Height: | Size: 3.2 KiB |
@ -1,663 +0,0 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2000
|
||||
--
|
||||
-- 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 appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. I make no representations about the
|
||||
-- suitability of this software for any purpose. It is provided "as is"
|
||||
-- without express or implied warranty.
|
||||
-->
|
||||
<!--
|
||||
-- Copyright (c) 1996-1999
|
||||
-- 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 appears 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.
|
||||
--
|
||||
-- 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 appears 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.
|
||||
--
|
||||
-->
|
||||
<Head>
|
||||
<Title>Iterator Concepts</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<h1>Iterator Concepts</h1>
|
||||
|
||||
<p>The standard iterator categories and requirements are flawed because
|
||||
they use a single hierarchy of requirements to address two orthogonal
|
||||
issues: <b><i>iterator traversal</i></b> and <b><i>dereference return
|
||||
type</i></b>. The current iterator requirement hierarchy is mainly
|
||||
geared towards iterator traversal (hence the category names), while
|
||||
requirements that address dereference return type sneak in at various
|
||||
places.
|
||||
|
||||
<p>
|
||||
The iterator requirements should be separated into two hierarchies.
|
||||
One set of concepts handles the return type semantics:
|
||||
<ul>
|
||||
<li><a href="#concept:ReadableIterator">Readable Iterator</a></li>
|
||||
<li><a href="#concept:WritableIterator">Writable Iterator</a></li>
|
||||
<li><a href="#concept:SwappableIterator">Swappable Iterator</a></li>
|
||||
<li><a href="#concept:ConstantLvalueIterator">Constant Lvalue Iterator</a></li>
|
||||
<li><a href="#concept:MutableLvalueIterator">Mutable Lvalue Iterator</a></li>
|
||||
</ul>
|
||||
|
||||
The other set of concepts handles iterator traversal:
|
||||
|
||||
<ul>
|
||||
<li><a href="#concept:ForwardTraversalIterator">Forward Traversal Iterator</a></li>
|
||||
<li><a href="#concept:BidirectionalTraversalIterator">Bidirectional Traversal Iterator</a></li>
|
||||
<li><a href="#concept:RandomAccessTraversalIterator">Random Access Traversal Iterator</a></li>
|
||||
</ul>
|
||||
|
||||
The current Input Iterator and Output Iterator requirements will
|
||||
continue to be used as is. Note that Input Iterator implies Readable
|
||||
Iterator and Output Iterator implies Writable Iterator.
|
||||
|
||||
<p>
|
||||
Note: we considered defining a Single-Pass Iterator, which could be
|
||||
combined with Readable or Writable Iterator to replace the Input and
|
||||
Output Iterator requirements. We rejected this idea because there are
|
||||
some differences between Input and Output Iterators that make it hard
|
||||
to merge them: for example Input Iterator requires Equality Comparable
|
||||
while Output Iterator does not.
|
||||
|
||||
|
||||
<p></p>
|
||||
<DIV ALIGN="CENTER"><A NAME="fig:graph-concepts"></A></A>
|
||||
<TABLE>
|
||||
<CAPTION ALIGN="TOP"><STRONG>Figure 1:</STRONG>
|
||||
The iterator concepts and refinement relationships.
|
||||
</CAPTION>
|
||||
<TR><TD><IMG SRC="./iterator_concepts.gif" ></TD></TR>
|
||||
</TABLE>
|
||||
</DIV>
|
||||
<p></p>
|
||||
|
||||
|
||||
<h2>Relationship with the standard iterator concepts</h2>
|
||||
|
||||
<p>
|
||||
std::Input Iterator implies boost::ReadableIterator.
|
||||
|
||||
<p>
|
||||
std::Output Iterator implies boost::Writable Iterator.
|
||||
|
||||
<p>
|
||||
std::Forward Iterator refines boost::Forward Iterator and
|
||||
boost::Constant Lvalue Iterator or boost::Mutable Lvalue Iterator.
|
||||
|
||||
<p>
|
||||
std::Bidirectional Iterator refines boost::Bidirectional Iterator and
|
||||
boost::Constant Lvalue Iterator or boost::Mutable Lvalue Iterator.
|
||||
|
||||
<p>
|
||||
std::Random Access Iterator refines boost::Random Access Iterator and
|
||||
boost::Constant Lvalue Iterator or boost::Mutable Lvalue Iterator.
|
||||
|
||||
|
||||
<h3>Notation</h3>
|
||||
<Table>
|
||||
<tr>
|
||||
<td><tt>X</tt></td>
|
||||
<td>The iterator type.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>T</tt></td>
|
||||
<td>The value type of <tt>X</tt>, i.e., <tt>std::iterator_traits<X>::value_type</tt>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>x</tt>, <tt>y</tt></td>
|
||||
<td>An object of type <tt>X</tt>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>t</tt></td>
|
||||
<td>An object of type <tt>T</tt>.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
|
||||
<hr>
|
||||
<!--------------------------------------------------------------------------->
|
||||
|
||||
<H3><A NAME="concept:ReadableIterator"></A>
|
||||
Readable Iterator
|
||||
</H3>
|
||||
|
||||
A Readable Iterator is an iterator that dereferences to produce an
|
||||
rvalue that is convertible to the <tt>value_type</tt> of the
|
||||
iterator.
|
||||
|
||||
<h3>Associated Types</h3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<tr>
|
||||
<td>Value type</td>
|
||||
<td><tt>std::iterator_traits<X>::value_type</tt></td>
|
||||
<td>The type of the objects pointed to by the iterator.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Reference type</td>
|
||||
<td><tt>std::iterator_traits<X>::reference</tt></td>
|
||||
<td>
|
||||
The return type of dereferencing the iterator. This
|
||||
type must be convertible to <tt>T</tt>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Return Category</td>
|
||||
<td><tt>std::return_category<X>::type</tt></td>
|
||||
<td>
|
||||
A type convertible to <tt>std::readable_iterator_tag</tt>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</Table>
|
||||
|
||||
<h3>Refinement of</h3>
|
||||
|
||||
<A href="http://www.boost.org/libs/utility/CopyConstructible.html">Copy Constructible</A>
|
||||
|
||||
<h3>Valid expressions</h3>
|
||||
|
||||
<Table border>
|
||||
<tr><TH>Name</TH><TH>Expression</TH><TH>Type requirements</TH><TH>Return type</TH></tr>
|
||||
<tr>
|
||||
<td>Dereference</td>
|
||||
<td><tt>*x</tt></td>
|
||||
<td> </td>
|
||||
<td><tt>std::iterator_traits<X>::reference</tt></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Member access</td>
|
||||
<td><tt>x->m</tt></td>
|
||||
<td><tt>T</tt> is a type with a member named <tt>m</tt>.</td>
|
||||
<td>
|
||||
If <tt>m</tt> is a data member, the type of <tt>m</tt>.
|
||||
If <tt>m</tt> is a member function, the return type of <tt>m</tt>.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
|
||||
<hr>
|
||||
<!--------------------------------------------------------------------------->
|
||||
|
||||
<H3><A NAME="concept:WritableIterator"></A>
|
||||
Writable Iterator
|
||||
</H3>
|
||||
|
||||
A Writable Iterator is an iterator that can be used to store a value
|
||||
using the dereference-assignment expression.
|
||||
|
||||
<h3>Definitions</h3>
|
||||
|
||||
If <tt>x</tt> is an Writable Iterator of type <tt>X</tt>, then the
|
||||
expression <tt>*x = a;</tt> stores the value <tt>a</tt> into
|
||||
<tt>x</tt>. Note that <tt>operator=</tt>, like other C++ functions,
|
||||
may be overloaded; it may, in fact, even be a template function. In
|
||||
general, then, <tt>a</tt> may be any of several different types. A
|
||||
type <tt>A</tt> belongs to the <i>set of value types</i> of <tt>X</tt>
|
||||
if, for an object <tt>a</tt> of type <tt>A</tt>, <tt>*x = a;</tt> is
|
||||
well-defined and does not require performing any non-trivial
|
||||
conversions on <tt>a</tt>.
|
||||
|
||||
<h3>Associated Types</h3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<tr>
|
||||
<td>Return Category</td>
|
||||
<td><tt>std::return_category<X>::type</tt></td>
|
||||
<td>
|
||||
A type convertible to <tt>std::writable_iterator_tag</tt>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</Table>
|
||||
|
||||
|
||||
|
||||
<h3>Refinement of</h3>
|
||||
|
||||
<A href="http://www.boost.org/libs/utility/CopyConstructible.html">Copy Constructible</A>
|
||||
|
||||
<h3>Valid expressions</h3>
|
||||
|
||||
<Table border>
|
||||
<tr>
|
||||
<TH>Name</TH><TH>Expression</TH><TH>Return type</TH>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Dereference assignment</td>
|
||||
<td><tt>*x = a</tt></td>
|
||||
<td>unspecified</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
|
||||
|
||||
<hr>
|
||||
<!--------------------------------------------------------------------------->
|
||||
|
||||
<H3><A NAME="concept:SwappableIterator"></A>
|
||||
Swappable Iterator
|
||||
</H3>
|
||||
|
||||
A Swappable Iterator is an iterator whose dereferenced values can be
|
||||
swapped.
|
||||
|
||||
<p>
|
||||
Note: the requirements for Swappable Iterator are dependent on the
|
||||
issues surrounding <tt>std::swap()</tt> being resolved. Here we assume
|
||||
that the issue will be resolved by allowing the overload of
|
||||
<tt>std::swap()</tt> for user-defined types.
|
||||
|
||||
<p>
|
||||
Note: Readable Iterator and Writable Iterator combined implies
|
||||
Swappable Iterator because of the fully templated
|
||||
<tt>std::swap()</tt>. However, Swappable Iterator does not imply
|
||||
Readable Iterator nor Writable Iterator.
|
||||
|
||||
<h3>Associated Types</h3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<tr>
|
||||
<td>Return Category</td>
|
||||
<td><tt>std::return_category<X>::type</tt></td>
|
||||
<td>
|
||||
A type convertible to <tt>std::swappable_iterator_tag</tt>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</Table>
|
||||
|
||||
|
||||
<h3>Valid expressions</h3>
|
||||
|
||||
Of the two valid expressions listed below, only one <b>OR</b> the
|
||||
other is required. If <tt>std::iter_swap()</tt> is overloaded for
|
||||
<tt>X</tt> then <tt>std::swap()</tt> is not required. If
|
||||
<tt>std::iter_swap()</tt> is not overloaded for <tt>X</tt> then the
|
||||
default (fully templated) version is used, which will call
|
||||
<tt>std::swap()</tt> (this means changing the current requirements for
|
||||
<tt>std::iter_swap()</tt>).
|
||||
|
||||
<p>
|
||||
<Table border>
|
||||
<tr>
|
||||
<TH>Name</TH><TH>Expression</TH><TH>Return type</TH>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Iterator Swap</td>
|
||||
<td><tt>std::iter_swap(x, y)</tt></td>
|
||||
<td>void</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Dereference and Swap</td>
|
||||
<td><tt>std::swap(*x, *y)</tt></td>
|
||||
<td>void</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<p>
|
||||
|
||||
|
||||
<hr>
|
||||
<!--------------------------------------------------------------------------->
|
||||
|
||||
<H3><A NAME="concept:ConstantLvalueIterator"></A>
|
||||
Constant Lvalue Iterator
|
||||
</H3>
|
||||
|
||||
A Constant Lvalue Iterator is an iterator that dereferences to produce a
|
||||
const reference to the pointed-to object, i.e., the associated
|
||||
<tt>reference</tt> type is <tt>const T&</tt>. Changing the value
|
||||
of or destroying an iterator that models Constant Lvalue Iterator does
|
||||
not invalidate pointers and references previously obtained from that
|
||||
iterator.
|
||||
|
||||
|
||||
<h3>Refinement of</h3>
|
||||
|
||||
<a href="#concept:ReadableIterator">Readable Iterator</a>
|
||||
|
||||
<h3>Associated Types</h3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<tr>
|
||||
<td>Reference type</td>
|
||||
<td><tt>std::iterator_traits<X>::reference</tt></td>
|
||||
<td>
|
||||
The return type of dereferencing the iterator, which must be
|
||||
<tt>const T&</tt>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- I don't think this is needed
|
||||
<tr>
|
||||
<td>Pointer type</td>
|
||||
<td><tt>std::iterator_traits<X>::pointer</tt></td>
|
||||
<td>
|
||||
The pointer to the value type, which must be <tt>const T*</tt>.
|
||||
</td>
|
||||
</tr>
|
||||
-->
|
||||
|
||||
<tr>
|
||||
<td>Return Category</td>
|
||||
<td><tt>std::return_category<X>::type</tt></td>
|
||||
<td>
|
||||
A type convertible to <tt>std::constant_lvalue_iterator_tag</tt>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<!-- these are not necessary now that we use reference as operator* return type
|
||||
<h3>Valid expressions</h3>
|
||||
|
||||
<Table border>
|
||||
<tr><TH>Name</TH><TH>Expression</TH><TH>Type requirements</TH><TH>Return type</TH></tr>
|
||||
<tr>
|
||||
<td>Dereference</td>
|
||||
<td><tt>*x</tt></td>
|
||||
<td> </td>
|
||||
<td><tt>std::iterator_traits<X>::reference</tt></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Member access</td>
|
||||
<td><tt>x->m</tt></td>
|
||||
<td><tt>T</tt> is a type with a member named <tt>m</tt>.</td>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
-->
|
||||
|
||||
<p>
|
||||
|
||||
<hr>
|
||||
<!--------------------------------------------------------------------------->
|
||||
|
||||
<H3><A NAME="concept:MutableLvalueIterator"></A>
|
||||
Mutable Lvalue Iterator
|
||||
</H3>
|
||||
|
||||
A Mutable Lvalue Iterator is an iterator that dereferences to produce a
|
||||
reference to the pointed-to object. The associated <tt>reference</tt>
|
||||
type is <tt>T&</tt>. Changing the value of or destroying an
|
||||
iterator that models Mutable Lvalue Iterator does not invalidate
|
||||
pointers and references previously obtained from that iterator.
|
||||
|
||||
<h3>Refinement of</h3>
|
||||
|
||||
<a href="#concept:ReadableIterator">Readable Iterator</a>,
|
||||
<a href="#concept:WritableIterator">Writable Iterator</a>,
|
||||
and <a href="#concept:SwappableIterator">Swappable Iterator</a>.
|
||||
|
||||
|
||||
|
||||
<h3>Associated Types</h3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<tr>
|
||||
<td>Reference type</td>
|
||||
<td><tt>std::iterator_traits<X>::reference</tt></td>
|
||||
<td>The return type of dereferencing the iterator, which must be
|
||||
<tt>T&</tt>.</td>
|
||||
</tr>
|
||||
|
||||
<!-- I don't think this is necessary
|
||||
<tr>
|
||||
<td>Pointer type</td>
|
||||
<td><tt>std::iterator_traits<X>::pointer</tt></td>
|
||||
<td>
|
||||
The pointer to the value type, which is <tt>T*</tt>.
|
||||
</td>
|
||||
</tr>
|
||||
-->
|
||||
|
||||
<tr>
|
||||
<td>Return Category</td>
|
||||
<td><tt>std::return_category<X>::type</tt></td>
|
||||
<td>
|
||||
A type convertible to <tt>std::mutable_lvalue_iterator_tag</tt>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<!-- no longer needed since the return type is specified as reference in the readable iterator
|
||||
<h3>Valid expressions</h3>
|
||||
|
||||
<Table border>
|
||||
<tr><TH>Name</TH><TH>Expression</TH><TH>Type requirements</TH><TH>Return type</TH></tr>
|
||||
<tr>
|
||||
<td>Dereference</td>
|
||||
<td><tt>*x</tt></td>
|
||||
<td> </td>
|
||||
<td><tt>std::iterator_traits<X>::reference</tt></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Member access</td>
|
||||
<td><tt>x->m</tt></td>
|
||||
<td><tt>T</tt> is a type with a member named <tt>m</tt>.</td>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
-->
|
||||
|
||||
<p>
|
||||
<hr>
|
||||
<!--------------------------------------------------------------------------->
|
||||
|
||||
<H3><A NAME="concept:ForwardTraversalIterator"></A>
|
||||
Forward Traversal Iterator
|
||||
</H3>
|
||||
|
||||
The Forward Iterator is an iterator that can be incremented. Also, it
|
||||
is permissible to make multiple passes through the iterator's range.
|
||||
|
||||
<h3>Refinement of</h3>
|
||||
|
||||
<A href="http://www.boost.org/libs/utility/CopyConstructible.html">Copy Constructible</A>,
|
||||
<A href="http://www.boost.org/libs/utility/Assignable.html">Assignable</A>,
|
||||
<A href="http://www.sgi.com/tech/stl/DefaultConstructible.html">Default Constructible</A>, and
|
||||
<A href="http://www.sgi.com/tech/stl/EqualityComparable.html">Equality Comparable</A>
|
||||
|
||||
|
||||
<h3>Associated types</h3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<tr>
|
||||
<td>Difference Type</td>
|
||||
<td><tt>std::iterator_traits<X>::difference_type</tt></td>
|
||||
<td>
|
||||
A signed integral type used for representing distances
|
||||
between iterators that point into the same range.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Traversal Category</td>
|
||||
<td><tt>std::traversal_category<X>::type</tt></td>
|
||||
<td>
|
||||
A type convertible to <tt>std::forward_traversal_tag</tt>
|
||||
</td>
|
||||
</tr>
|
||||
</Table>
|
||||
|
||||
<h3>Valid expressions</h3>
|
||||
|
||||
<Table border>
|
||||
<tr>
|
||||
<TH>Name</TH><TH>Expression</TH><TH>Type requirements</TH>
|
||||
<TH>Return type</TH>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Preincrement</td>
|
||||
<td><tt>++i</tt></td><td> </td><td><tt>X&</tt></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Postincrement</td>
|
||||
<td><tt>i++</tt></td><td> </td><td>convertible to <tt>const X&</tt></td>
|
||||
</tr>
|
||||
</Table>
|
||||
|
||||
<p>
|
||||
<hr>
|
||||
<!--------------------------------------------------------------------------->
|
||||
|
||||
<H3><A NAME="concept:BidirectionalTraversalIterator"></A>
|
||||
Bidirectional Traversal Iterator
|
||||
</H3>
|
||||
|
||||
An iterator that can be incremented and decremented.
|
||||
|
||||
<h3>Refinement of</h3>
|
||||
|
||||
<a href="#concept:ForwardTraversalIterator">Forward Traversal Iterator</a>
|
||||
|
||||
<h3>Associated types</h3>
|
||||
|
||||
<Table border>
|
||||
<tr>
|
||||
<td>Traversal Category</td>
|
||||
<td><tt>std::traversal_category<X>::type</tt></td>
|
||||
<td>
|
||||
A type convertible to <tt>std::bidirectional_traversal_tag</tt>
|
||||
</td>
|
||||
</tr>
|
||||
</Table>
|
||||
|
||||
<h3>Valid expressions</h3>
|
||||
|
||||
<Table border>
|
||||
<tr>
|
||||
<TH>Name</TH><TH>Expression</TH><TH>Type requirements</TH>
|
||||
<TH>Return type</TH>
|
||||
</tr>
|
||||
<tr><td>Predecrement</td>
|
||||
<td><tt>--i</tt></td><td> </td><td><tt>X&</tt></td>
|
||||
</tr>
|
||||
<tr><td>Postdecrement</td>
|
||||
<td><tt>i--</tt></td><td> </td><td>convertible to <tt>const X&</tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
<hr>
|
||||
<!--------------------------------------------------------------------------->
|
||||
|
||||
<H3><A NAME="concept:RandomAccessTraversalIterator"></A>
|
||||
Random Access Traversal Iterator
|
||||
</H3>
|
||||
|
||||
An iterator that provides constant-time methods for moving forward and
|
||||
backward in arbitrary-sized steps.
|
||||
|
||||
<h3>Refinement of</h3>
|
||||
|
||||
<a href="#concept:BidirectionalTraversalIterator">Bidirectional Traversal Iterator</a> and
|
||||
<A href="http://www.sgi.com/tech/stl/LessThanComparable.html">Less Than Comparable</A> where <tt><</tt> is a total ordering
|
||||
|
||||
<h3>Associated types</h3>
|
||||
|
||||
<Table border>
|
||||
<tr>
|
||||
<td>Traversal Category</td>
|
||||
<td><tt>std::traversal_category<X>::type</tt></td>
|
||||
<td>
|
||||
A type convertible to <tt>std::random_access_traversal_tag</tt>
|
||||
</td>
|
||||
</tr>
|
||||
</Table>
|
||||
|
||||
<h3>Valid expressions</h3>
|
||||
|
||||
<Table border>
|
||||
<tr><TH>Name</TH><TH>Expression</TH><TH>Type requirements</TH>
|
||||
<TH>Return type</TH>
|
||||
</tr>
|
||||
<tr><td>Iterator addition</td>
|
||||
<td><tt>i += n</tt></td><td> </td><td><tt>X&</tt></td>
|
||||
</tr>
|
||||
<tr><td>Iterator addition</td>
|
||||
<td><tt>i + n</tt> or <tt>n + i</tt></td><td> </td><td><tt>X</tt></td>
|
||||
</tr>
|
||||
<tr><td>Iterator subtraction</td>
|
||||
<td><tt>i -= n</tt></td><td> </td><td><tt>X&</tt></td>
|
||||
</tr>
|
||||
<tr><td>Iterator subtraction</td>
|
||||
<td><tt>i - n</tt></td><td> </td><td><tt>X</tt></td>
|
||||
</tr>
|
||||
<tr><td>Difference</td>
|
||||
<td><tt>i - j</tt></td><td> </td><td><tt>std::iterator_traits<X>::difference_type</tt></td>
|
||||
</tr>
|
||||
<tr><td>Element operator</td>
|
||||
<td><tt>i[n]</tt></td>
|
||||
<td><tt>X</tt> must also be a model of
|
||||
<a href="#concept:ReadableIterator">Readable Iterator</a>. </td>
|
||||
<td><tt>std::iterator_traits<X>::reference</tt></td>
|
||||
</tr>
|
||||
<tr><td>Element assignment</td>
|
||||
<td><tt>i[n] = t</tt></td>
|
||||
<td><tt>X</tt> must also be a model of
|
||||
<a href="#concept:WritableIterator">Writable Iterator</a>.</td>
|
||||
<td>unspecified</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../../people/jeremy_siek.htm">Jeremy Siek</A>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -56,9 +56,7 @@
|
||||
# include <boost/type_traits.hpp>
|
||||
# include <boost/detail/numeric_traits.hpp>
|
||||
# include <boost/static_assert.hpp>
|
||||
# ifndef BOOST_NO_LIMITS
|
||||
# include <limits>
|
||||
# endif
|
||||
# include <boost/limits.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
@ -135,7 +133,7 @@ namespace detail {
|
||||
// For a while, this wasn't true, but we rely on it below. This is a regression assert.
|
||||
BOOST_STATIC_ASSERT(::boost::is_integral<char>::value);
|
||||
# ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
|
||||
# if defined(ULLONG_MAX) || defined(ULONG_LONG_MAX)
|
||||
# if defined(BOOST_HAS_LONG_LONG)
|
||||
BOOST_STATIC_CONSTANT(bool,
|
||||
value = (
|
||||
std::numeric_limits<T>::is_specialized
|
||||
@ -199,15 +197,20 @@ struct counting_iterator_policies : public default_iterator_policies
|
||||
template <class Incrementable>
|
||||
struct counting_iterator_generator
|
||||
{
|
||||
typedef counting_iterator_traits<Incrementable> traits;
|
||||
typedef typename boost::remove_const<
|
||||
Incrementable
|
||||
>::type value_type;
|
||||
|
||||
typedef iterator_adaptor<Incrementable,
|
||||
counting_iterator_policies<Incrementable>,
|
||||
Incrementable,
|
||||
const Incrementable&,
|
||||
const Incrementable*,
|
||||
typename traits::iterator_category,
|
||||
typename traits::difference_type
|
||||
typedef counting_iterator_traits<value_type> traits;
|
||||
|
||||
typedef iterator_adaptor<
|
||||
value_type
|
||||
, counting_iterator_policies<value_type>
|
||||
, value_type
|
||||
, value_type const&
|
||||
, value_type const*
|
||||
, typename traits::iterator_category
|
||||
, typename traits::difference_type
|
||||
> type;
|
||||
};
|
||||
|
||||
|
@ -99,17 +99,17 @@ struct half_open_range
|
||||
|
||||
public:
|
||||
typedef iter_t const_iterator;
|
||||
typedef typename counting_iterator_traits<Incrementable>::value_type value_type;
|
||||
typedef typename counting_iterator_traits<Incrementable>::difference_type difference_type;
|
||||
typedef typename counting_iterator_traits<Incrementable>::reference reference;
|
||||
typedef typename counting_iterator_traits<Incrementable>::reference const_reference;
|
||||
typedef typename counting_iterator_traits<Incrementable>::pointer pointer;
|
||||
typedef typename counting_iterator_traits<Incrementable>::pointer const_pointer;
|
||||
typedef typename iterator::value_type value_type;
|
||||
typedef typename iterator::difference_type difference_type;
|
||||
typedef typename iterator::reference reference;
|
||||
typedef typename iterator::reference const_reference;
|
||||
typedef typename iterator::pointer pointer;
|
||||
typedef typename iterator::pointer const_pointer;
|
||||
|
||||
// It would be nice to select an unsigned type, but this is appropriate
|
||||
// since the library makes an attempt to select a difference_type which can
|
||||
// hold the difference between any two iterators.
|
||||
typedef typename counting_iterator_traits<Incrementable>::difference_type size_type;
|
||||
typedef typename iterator::difference_type size_type;
|
||||
|
||||
half_open_range(Incrementable start, Incrementable finish)
|
||||
: m_start(start),
|
||||
|
@ -12,6 +12,16 @@
|
||||
//
|
||||
// Revision History:
|
||||
|
||||
// 01 Feb 2002 Jeremy Siek
|
||||
// Added more comments in default_iterator_policies.
|
||||
// 08 Jan 2001 David Abrahams
|
||||
// Moved concept checks into a separate class, which makes MSVC
|
||||
// better at dealing with them.
|
||||
// 07 Jan 2001 David Abrahams
|
||||
// Choose proxy for operator->() only if the reference type is not a reference.
|
||||
// Updated workarounds for __MWERKS__ == 0x2406
|
||||
// 20 Dec 2001 David Abrahams
|
||||
// Adjusted is_convertible workarounds for __MWERKS__ == 0x2406
|
||||
// 03 Nov 2001 Jeremy Siek
|
||||
// Changed the named template parameter interface and internal.
|
||||
// 04 Oct 2001 Jeremy Siek
|
||||
@ -119,7 +129,7 @@
|
||||
|
||||
// I was having some problems with VC6. I couldn't tell whether our hack for
|
||||
// stock GCC was causing problems so I needed an easy way to turn it on and
|
||||
// off. Now we can test the hack with various compilers and still have an
|
||||
// off. Now we can test the hack with various compilers and still have an
|
||||
// "out" if it doesn't work. -dwa 7/31/00
|
||||
# if __GNUC__ == 2 && __GNUC_MINOR__ <= 96 && !defined(__STL_USE_NAMESPACES)
|
||||
# define BOOST_RELOPS_AMBIGUITY_BUG 1
|
||||
@ -137,7 +147,7 @@ namespace boost {
|
||||
template <class Policies, class Adapted, class Traits>
|
||||
struct TrivialIteratorPoliciesConcept
|
||||
{
|
||||
typedef typename Traits::reference Reference;
|
||||
typedef typename Traits::reference reference;
|
||||
void constraints() {
|
||||
function_requires< AssignableConcept<Policies> >();
|
||||
function_requires< DefaultConstructibleConcept<Policies> >();
|
||||
@ -147,7 +157,7 @@ struct TrivialIteratorPoliciesConcept
|
||||
const_constraints();
|
||||
}
|
||||
void const_constraints() const {
|
||||
Reference r = p.dereference(x);
|
||||
reference r = p.dereference(x);
|
||||
b = p.equal(x, x);
|
||||
ignore_unused_variable_warning(r);
|
||||
}
|
||||
@ -163,7 +173,7 @@ struct ForwardIteratorPoliciesConcept
|
||||
{
|
||||
typedef typename Traits::iterator_category iterator_category;
|
||||
void constraints() {
|
||||
function_requires<
|
||||
function_requires<
|
||||
TrivialIteratorPoliciesConcept<Policies, Adapted, Traits>
|
||||
>();
|
||||
|
||||
@ -181,7 +191,7 @@ struct BidirectionalIteratorPoliciesConcept
|
||||
{
|
||||
typedef typename Traits::iterator_category iterator_category;
|
||||
void constraints() {
|
||||
function_requires<
|
||||
function_requires<
|
||||
ForwardIteratorPoliciesConcept<Policies, Adapted, Traits>
|
||||
>();
|
||||
|
||||
@ -199,7 +209,7 @@ struct RandomAccessIteratorPoliciesConcept
|
||||
typedef typename Traits::difference_type DifferenceType;
|
||||
typedef typename Traits::iterator_category iterator_category;
|
||||
void constraints() {
|
||||
function_requires<
|
||||
function_requires<
|
||||
BidirectionalIteratorPoliciesConcept<Policies, Adapted, Traits>
|
||||
>();
|
||||
|
||||
@ -223,9 +233,15 @@ struct RandomAccessIteratorPoliciesConcept
|
||||
// class if you want to customize particular policies.
|
||||
struct default_iterator_policies
|
||||
{
|
||||
// Some of these members were defined static, but Borland got confused
|
||||
// and thought they were non-const. Also, Sun C++ does not like static
|
||||
// function templates.
|
||||
// Some of the member functions were defined static, but Borland
|
||||
// got confused and thought they were non-const. Also, Sun C++
|
||||
// does not like static function templates.
|
||||
//
|
||||
// The reason some members were defined static is because there is
|
||||
// not state (data members) needed by those members of the
|
||||
// default_iterator_policies class. If your policies class member
|
||||
// functions need to access state stored in the policies object,
|
||||
// then the member functions should not be static (they can't be).
|
||||
|
||||
template <class Base>
|
||||
void initialize(Base&)
|
||||
@ -257,7 +273,7 @@ struct default_iterator_policies
|
||||
{ return x.base() == y.base(); }
|
||||
};
|
||||
|
||||
// putting the comparisons in a base class avoids the g++
|
||||
// putting the comparisons in a base class avoids the g++
|
||||
// ambiguous overload bug due to the relops operators
|
||||
|
||||
#ifdef BOOST_RELOPS_AMBIGUITY_BUG
|
||||
@ -265,7 +281,7 @@ template <class Derived, class Base>
|
||||
struct iterator_comparisons : Base { };
|
||||
|
||||
template <class D1, class D2, class Base1, class Base2>
|
||||
inline bool operator==(const iterator_comparisons<D1,Base1>& xb,
|
||||
inline bool operator==(const iterator_comparisons<D1,Base1>& xb,
|
||||
const iterator_comparisons<D2,Base2>& yb)
|
||||
{
|
||||
const D1& x = static_cast<const D1&>(xb);
|
||||
@ -274,7 +290,7 @@ inline bool operator==(const iterator_comparisons<D1,Base1>& xb,
|
||||
}
|
||||
|
||||
template <class D1, class D2, class Base1, class Base2>
|
||||
inline bool operator!=(const iterator_comparisons<D1,Base1>& xb,
|
||||
inline bool operator!=(const iterator_comparisons<D1,Base1>& xb,
|
||||
const iterator_comparisons<D2,Base2>& yb)
|
||||
{
|
||||
const D1& x = static_cast<const D1&>(xb);
|
||||
@ -283,7 +299,7 @@ inline bool operator!=(const iterator_comparisons<D1,Base1>& xb,
|
||||
}
|
||||
|
||||
template <class D1, class D2, class Base1, class Base2>
|
||||
inline bool operator<(const iterator_comparisons<D1,Base1>& xb,
|
||||
inline bool operator<(const iterator_comparisons<D1,Base1>& xb,
|
||||
const iterator_comparisons<D2,Base2>& yb)
|
||||
{
|
||||
const D1& x = static_cast<const D1&>(xb);
|
||||
@ -292,16 +308,16 @@ inline bool operator<(const iterator_comparisons<D1,Base1>& xb,
|
||||
}
|
||||
|
||||
template <class D1, class D2, class Base1, class Base2>
|
||||
inline bool operator>(const iterator_comparisons<D1,Base1>& xb,
|
||||
inline bool operator>(const iterator_comparisons<D1,Base1>& xb,
|
||||
const iterator_comparisons<D2,Base2>& yb)
|
||||
{
|
||||
{
|
||||
const D1& x = static_cast<const D1&>(xb);
|
||||
const D2& y = static_cast<const D2&>(yb);
|
||||
return x.policies().distance(y, x) > 0;
|
||||
}
|
||||
|
||||
template <class D1, class D2, class Base1, class Base2>
|
||||
inline bool operator>=(const iterator_comparisons<D1,Base1>& xb,
|
||||
inline bool operator>=(const iterator_comparisons<D1,Base1>& xb,
|
||||
const iterator_comparisons<D2,Base2>& yb)
|
||||
{
|
||||
const D1& x = static_cast<const D1&>(xb);
|
||||
@ -310,7 +326,7 @@ inline bool operator>=(const iterator_comparisons<D1,Base1>& xb,
|
||||
}
|
||||
|
||||
template <class D1, class D2, class Base1, class Base2>
|
||||
inline bool operator<=(const iterator_comparisons<D1,Base1>& xb,
|
||||
inline bool operator<=(const iterator_comparisons<D1,Base1>& xb,
|
||||
const iterator_comparisons<D2,Base2>& yb)
|
||||
{
|
||||
const D1& x = static_cast<const D1&>(xb);
|
||||
@ -350,17 +366,14 @@ namespace detail {
|
||||
return &(*i);
|
||||
}
|
||||
|
||||
template <class Category, class Value, class Pointer>
|
||||
template <class Value, class Reference, class Pointer>
|
||||
struct operator_arrow_result_generator
|
||||
{
|
||||
typedef operator_arrow_proxy<Value> proxy;
|
||||
// Borland chokes unless it's an actual enum (!)
|
||||
enum { is_input_iter
|
||||
= (boost::is_convertible<Category*,std::input_iterator_tag*>::value
|
||||
& !boost::is_convertible<Category*,std::forward_iterator_tag*>::value)
|
||||
};
|
||||
|
||||
typedef typename boost::detail::if_true<(is_input_iter)>::template
|
||||
enum { use_proxy = !boost::is_reference<Reference>::value };
|
||||
|
||||
typedef typename boost::detail::if_true<(use_proxy)>::template
|
||||
then<
|
||||
proxy,
|
||||
// else
|
||||
@ -369,7 +382,7 @@ namespace detail {
|
||||
};
|
||||
|
||||
|
||||
# ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || defined(BOOST_NO_STD_ITERATOR_TRAITS)
|
||||
|
||||
// Select default pointer and reference types for adapted non-pointer
|
||||
// iterators based on the iterator and the value_type. Poor man's partial
|
||||
@ -422,14 +435,14 @@ namespace detail {
|
||||
typename iterator_traits<Iterator>::pointer,
|
||||
Value*
|
||||
>::type pointer;
|
||||
|
||||
|
||||
typedef typename if_true<(
|
||||
::boost::is_same<Value,typename iterator_traits<Iterator>::value_type>::value
|
||||
)>::template then<
|
||||
typename iterator_traits<Iterator>::reference,
|
||||
Value&
|
||||
>::type reference;
|
||||
|
||||
|
||||
};
|
||||
# endif
|
||||
|
||||
@ -478,8 +491,8 @@ namespace detail {
|
||||
template <class Base, class Traits>
|
||||
struct select {
|
||||
typedef typename Traits::value_type Value;
|
||||
typedef typename boost::detail::iterator_defaults<Base,Value>::pointer
|
||||
type;
|
||||
typedef typename boost::detail::iterator_defaults<Base,Value>::pointer
|
||||
type;
|
||||
};
|
||||
};
|
||||
template <> struct default_generator<default_pointer>
|
||||
@ -489,8 +502,8 @@ namespace detail {
|
||||
template <class Base, class Traits>
|
||||
struct select {
|
||||
typedef typename Traits::value_type Value;
|
||||
typedef typename boost::detail::iterator_defaults<Base,Value>::reference
|
||||
type;
|
||||
typedef typename boost::detail::iterator_defaults<Base,Value>::reference
|
||||
type;
|
||||
};
|
||||
};
|
||||
template <> struct default_generator<default_reference>
|
||||
@ -538,7 +551,7 @@ template <class Difference> struct difference_type_is
|
||||
{
|
||||
typedef detail::cons_type<detail::difference_type_tag, Difference> type;
|
||||
};
|
||||
template <class IteratorCategory> struct iterator_category_is
|
||||
template <class IteratorCategory> struct iterator_category_is
|
||||
: public named_template_param_base
|
||||
{
|
||||
typedef detail::cons_type<detail::iterator_category_tag, IteratorCategory> type;
|
||||
@ -552,7 +565,7 @@ namespace detail {
|
||||
// An associative list is a list of key-value pairs. The list is
|
||||
// built out of cons_type's and is terminated by end_of_list.
|
||||
|
||||
#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || defined(__BORLANDC__)
|
||||
# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || defined(__BORLANDC__)
|
||||
template <class AssocList, class Key>
|
||||
struct find_param;
|
||||
|
||||
@ -562,7 +575,7 @@ namespace detail {
|
||||
typedef typename Head::first_type Key1;
|
||||
typedef typename Head::second_type Value;
|
||||
typedef typename if_true<(is_same<Key1, Key2>::value)>::template
|
||||
then<Value,
|
||||
then<Value,
|
||||
typename find_param<typename AssocList::second_type, Key2>::type
|
||||
>::type type;
|
||||
};
|
||||
@ -581,7 +594,7 @@ namespace detail {
|
||||
typedef typename find_param_helper1<AssocList>::type select1;
|
||||
typedef typename select1::template select<AssocList, Key>::type type;
|
||||
};
|
||||
#else
|
||||
# else
|
||||
template <class AssocList, class Key> struct find_param;
|
||||
|
||||
template <class Key>
|
||||
@ -598,7 +611,7 @@ namespace detail {
|
||||
struct find_param<detail::cons_type< detail::cons_type<Key1, Value>, Rest>, Key2> {
|
||||
typedef typename find_param<Rest, Key2>::type type;
|
||||
};
|
||||
#endif
|
||||
# endif
|
||||
|
||||
struct make_named_arg {
|
||||
template <class Key, class Value>
|
||||
@ -612,29 +625,29 @@ namespace detail {
|
||||
template <class Value>
|
||||
struct is_named_parameter
|
||||
{
|
||||
enum { value = is_convertible<Value, named_template_param_base>::value };
|
||||
enum { value = is_convertible< typename add_reference< Value >::type, add_reference< named_template_param_base >::type >::value };
|
||||
};
|
||||
|
||||
#if defined(__MWERKS__) && __MWERKS__ <= 0x2405 // workaround for broken is_convertible implementation
|
||||
# if defined(__MWERKS__) && __MWERKS__ <= 0x2406 // workaround for broken is_convertible implementation
|
||||
template <class T> struct is_named_parameter<value_type_is<T> > { enum { value = true }; };
|
||||
template <class T> struct is_named_parameter<reference_is<T> > { enum { value = true }; };
|
||||
template <class T> struct is_named_parameter<pointer_is<T> > { enum { value = true }; };
|
||||
template <class T> struct is_named_parameter<difference_type_is<T> > { enum { value = true }; };
|
||||
template <class T> struct is_named_parameter<iterator_category_is<T> > { enum { value = true }; };
|
||||
#endif
|
||||
# endif
|
||||
|
||||
template <class Key, class Value>
|
||||
struct make_arg {
|
||||
#ifdef __BORLANDC__
|
||||
# ifdef __BORLANDC__
|
||||
// Borland C++ doesn't like the extra indirection of is_named_parameter
|
||||
typedef typename
|
||||
typedef typename
|
||||
if_true<(is_convertible<Value,named_template_param_base>::value)>::
|
||||
template then<make_named_arg, make_key_value>::type Make;
|
||||
#else
|
||||
# else
|
||||
enum { is_named = is_named_parameter<Value>::value };
|
||||
typedef typename if_true<(is_named)>::template
|
||||
then<make_named_arg, make_key_value>::type Make;
|
||||
#endif
|
||||
# endif
|
||||
typedef typename Make::template select<Key, Value>::type type;
|
||||
};
|
||||
|
||||
@ -678,7 +691,7 @@ namespace detail {
|
||||
class iterator_adaptor_traits_gen
|
||||
{
|
||||
// Form an associative list out of the template parameters
|
||||
// If the argument is a normal parameter (not named) then make_arg
|
||||
// If the argument is a normal parameter (not named) then make_arg
|
||||
// creates a key-value pair. If the argument is a named parameter,
|
||||
// then make_arg extracts the key-value pair defined inside the
|
||||
// named parameter.
|
||||
@ -703,9 +716,9 @@ namespace detail {
|
||||
typedef typename resolve_default<Val, default_value_type, Base, Traits0>::type
|
||||
value_type;
|
||||
// if getting default value type from iterator_traits, then it won't be const
|
||||
typedef typename resolve_default<Diff, default_difference_type, Base,
|
||||
typedef typename resolve_default<Diff, default_difference_type, Base,
|
||||
Traits0>::type difference_type;
|
||||
typedef typename resolve_default<Cat, default_iterator_category, Base,
|
||||
typedef typename resolve_default<Cat, default_iterator_category, Base,
|
||||
Traits0>::type iterator_category;
|
||||
|
||||
typedef boost::iterator<iterator_category, value_type, difference_type,
|
||||
@ -718,26 +731,47 @@ namespace detail {
|
||||
pointer;
|
||||
typedef typename resolve_default<Ref, default_reference, Base, Traits1>::type
|
||||
reference;
|
||||
|
||||
|
||||
public:
|
||||
typedef boost::iterator<iterator_category,
|
||||
typename remove_const<value_type>::type,
|
||||
typename remove_const<value_type>::type,
|
||||
difference_type, pointer, reference> type;
|
||||
};
|
||||
|
||||
// This is really a partial concept check for iterators. Should it
|
||||
// be moved or done differently?
|
||||
template <class Category, class Value, class Difference, class Pointer, class Reference>
|
||||
struct validator
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(
|
||||
bool, is_input_or_output_iter
|
||||
= (boost::is_convertible<Category*,std::input_iterator_tag*>::value
|
||||
| boost::is_convertible<Category*,std::output_iterator_tag*>::value));
|
||||
|
||||
// Iterators should satisfy one of the known categories
|
||||
BOOST_STATIC_ASSERT(is_input_or_output_iter);
|
||||
|
||||
// Iterators >= ForwardIterator must produce real references
|
||||
// as required by the C++ standard requirements in Table 74.
|
||||
BOOST_STATIC_CONSTANT(
|
||||
bool, forward_iter_with_real_reference
|
||||
= ((!boost::is_convertible<Category*,std::forward_iterator_tag*>::value)
|
||||
| boost::is_same<Reference,Value&>::value
|
||||
| boost::is_same<Reference,typename add_const<Value>::type&>::value));
|
||||
|
||||
BOOST_STATIC_ASSERT(forward_iter_with_real_reference);
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
|
||||
|
||||
// This macro definition is only temporary in this file
|
||||
# if !defined(BOOST_MSVC)
|
||||
# if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
||||
# define BOOST_ARG_DEPENDENT_TYPENAME typename
|
||||
# else
|
||||
# define BOOST_ARG_DEPENDENT_TYPENAME
|
||||
# endif
|
||||
|
||||
template <class T> struct undefined;
|
||||
|
||||
//============================================================================
|
||||
//iterator_adaptor - Adapts a generic piece of data as an iterator. Adaptation
|
||||
// is especially easy if the data being adapted is itself an iterator
|
||||
@ -766,12 +800,12 @@ template <class T> struct undefined;
|
||||
//
|
||||
// Distance - the difference_type of the resulting iterator. If not
|
||||
// supplied, iterator_traits<Base>::difference_type is used.
|
||||
template <class Base, class Policies,
|
||||
class Value = detail::default_argument,
|
||||
class Reference = detail::default_argument,
|
||||
class Pointer = detail::default_argument,
|
||||
class Category = detail::default_argument,
|
||||
class Distance = detail::default_argument
|
||||
template <class Base, class Policies,
|
||||
class Value = ::boost::detail::default_argument,
|
||||
class Reference = ::boost::detail::default_argument,
|
||||
class Pointer = ::boost::detail::default_argument,
|
||||
class Category = ::boost::detail::default_argument,
|
||||
class Distance = ::boost::detail::default_argument
|
||||
>
|
||||
struct iterator_adaptor :
|
||||
#ifdef BOOST_RELOPS_AMBIGUITY_BUG
|
||||
@ -798,32 +832,19 @@ struct iterator_adaptor :
|
||||
typedef Policies policies_type;
|
||||
|
||||
private:
|
||||
BOOST_STATIC_CONSTANT(bool, is_input_or_output_iter
|
||||
= (boost::is_convertible<iterator_category*,std::input_iterator_tag*>::value
|
||||
|| boost::is_convertible<iterator_category*,std::output_iterator_tag*>::value));
|
||||
|
||||
// Iterators should satisfy one of the known categories
|
||||
BOOST_STATIC_ASSERT(is_input_or_output_iter);
|
||||
|
||||
#if !defined(BOOST_MSVC)
|
||||
// Iterators >= ForwardIterator must produce real references
|
||||
// as required by the C++ standard requirements in Table 74.
|
||||
BOOST_STATIC_CONSTANT(bool, forward_iter_with_real_reference =
|
||||
(!boost::is_convertible<iterator_category*,std::forward_iterator_tag*>::value
|
||||
|| boost::is_same<reference,value_type&>::value
|
||||
|| boost::is_same<reference,const value_type&>::value));
|
||||
|
||||
// This check gives incorrect results in iter_traits_gen_test.cpp
|
||||
BOOST_STATIC_ASSERT(forward_iter_with_real_reference);
|
||||
#endif
|
||||
typedef detail::validator<
|
||||
iterator_category,value_type,difference_type,pointer,reference
|
||||
> concept_check;
|
||||
|
||||
public:
|
||||
iterator_adaptor() { }
|
||||
iterator_adaptor()
|
||||
{
|
||||
}
|
||||
|
||||
explicit
|
||||
iterator_adaptor(const Base& it, const Policies& p = Policies())
|
||||
: m_iter_p(it, p) {
|
||||
policies().initialize(base());
|
||||
policies().initialize(base());
|
||||
}
|
||||
|
||||
template <class Iter2, class Value2, class Pointer2, class Reference2>
|
||||
@ -834,9 +855,9 @@ struct iterator_adaptor :
|
||||
policies().initialize(base());
|
||||
}
|
||||
|
||||
#if defined(BOOST_MSVC) || defined(__BORLANDC__)
|
||||
#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 || defined(__BORLANDC__)
|
||||
// This is required to prevent a bug in how VC++ generates
|
||||
// the assignment operator for compressed_pairv
|
||||
// the assignment operator for compressed_pair
|
||||
iterator_adaptor& operator= (const iterator_adaptor& x) {
|
||||
m_iter_p = x.m_iter_p;
|
||||
return *this;
|
||||
@ -851,7 +872,7 @@ struct iterator_adaptor :
|
||||
# pragma warning( disable : 4284 )
|
||||
#endif
|
||||
|
||||
typename boost::detail::operator_arrow_result_generator<iterator_category,value_type,pointer>::type
|
||||
typename boost::detail::operator_arrow_result_generator<value_type,reference,pointer>::type
|
||||
operator->() const
|
||||
{ return detail::operator_arrow(*this, iterator_category()); }
|
||||
|
||||
@ -861,7 +882,7 @@ struct iterator_adaptor :
|
||||
|
||||
value_type operator[](difference_type n) const
|
||||
{ return *(*this + n); }
|
||||
|
||||
|
||||
self& operator++() {
|
||||
#if !defined(__MWERKS__) || __MWERKS__ >= 0x2405
|
||||
policies().increment(*this);
|
||||
@ -874,7 +895,7 @@ struct iterator_adaptor :
|
||||
}
|
||||
|
||||
self operator++(int) { self tmp(*this); ++*this; return tmp; }
|
||||
|
||||
|
||||
self& operator--() {
|
||||
#if !defined(__MWERKS__) || __MWERKS__ >= 0x2405
|
||||
policies().decrement(*this);
|
||||
@ -883,14 +904,14 @@ struct iterator_adaptor :
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
self operator--(int) { self tmp(*this); --*this; return tmp; }
|
||||
|
||||
self& operator+=(difference_type n) {
|
||||
policies().advance(*this, n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
self& operator-=(difference_type n) {
|
||||
policies().advance(*this, -n);
|
||||
return *this;
|
||||
@ -948,7 +969,7 @@ operator-(
|
||||
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
|
||||
class Reference1, class Reference2, class Pointer1, class Pointer2,
|
||||
class Category, class Distance>
|
||||
inline bool
|
||||
inline bool
|
||||
operator==(
|
||||
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
|
||||
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
|
||||
@ -959,7 +980,7 @@ operator==(
|
||||
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
|
||||
class Reference1, class Reference2, class Pointer1, class Pointer2,
|
||||
class Category, class Distance>
|
||||
inline bool
|
||||
inline bool
|
||||
operator<(
|
||||
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
|
||||
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
|
||||
@ -970,18 +991,18 @@ operator<(
|
||||
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
|
||||
class Reference1, class Reference2, class Pointer1, class Pointer2,
|
||||
class Category, class Distance>
|
||||
inline bool
|
||||
inline bool
|
||||
operator>(
|
||||
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
|
||||
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
|
||||
{
|
||||
{
|
||||
return x.policies().distance(y, x) > 0;
|
||||
}
|
||||
|
||||
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
|
||||
class Reference1, class Reference2, class Pointer1, class Pointer2,
|
||||
class Category, class Distance>
|
||||
inline bool
|
||||
inline bool
|
||||
operator>=(
|
||||
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
|
||||
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
|
||||
@ -992,7 +1013,7 @@ operator>=(
|
||||
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
|
||||
class Reference1, class Reference2, class Pointer1, class Pointer2,
|
||||
class Category, class Distance>
|
||||
inline bool
|
||||
inline bool
|
||||
operator<=(
|
||||
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
|
||||
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
|
||||
@ -1003,9 +1024,9 @@ operator<=(
|
||||
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
|
||||
class Reference1, class Reference2, class Pointer1, class Pointer2,
|
||||
class Category, class Distance>
|
||||
inline bool
|
||||
inline bool
|
||||
operator!=(
|
||||
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
|
||||
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
|
||||
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
|
||||
{
|
||||
return !x.policies().equal(x, y);
|
||||
@ -1023,7 +1044,7 @@ struct transform_iterator_policies : public default_iterator_policies
|
||||
{
|
||||
transform_iterator_policies() { }
|
||||
transform_iterator_policies(const AdaptableUnaryFunction& f) : m_f(f) { }
|
||||
|
||||
|
||||
template <class IteratorAdaptor>
|
||||
typename IteratorAdaptor::reference
|
||||
dereference(const IteratorAdaptor& iter) const
|
||||
@ -1037,7 +1058,7 @@ class transform_iterator_generator
|
||||
{
|
||||
typedef typename AdaptableUnaryFunction::result_type value_type;
|
||||
public:
|
||||
typedef iterator_adaptor<Iterator,
|
||||
typedef iterator_adaptor<Iterator,
|
||||
transform_iterator_policies<AdaptableUnaryFunction>,
|
||||
value_type, value_type, value_type*, std::input_iterator_tag>
|
||||
type;
|
||||
@ -1076,7 +1097,7 @@ struct indirect_iterator_policies : public default_iterator_policies
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
# if !defined(BOOST_MSVC) // stragely instantiated even when unused! Maybe try a recursive template someday ;-)
|
||||
# if !defined(BOOST_MSVC) || BOOST_MSVC > 1300 // strangely instantiated even when unused! Maybe try a recursive template someday ;-)
|
||||
template <class T>
|
||||
struct traits_of_value_type {
|
||||
typedef typename boost::detail::iterator_traits<T>::value_type outer_value;
|
||||
@ -1089,12 +1110,12 @@ namespace detail {
|
||||
|
||||
template <class OuterIterator, // Mutable or Immutable, does not matter
|
||||
class Value
|
||||
#if !defined(BOOST_MSVC)
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
||||
= BOOST_ARG_DEPENDENT_TYPENAME detail::traits_of_value_type<
|
||||
OuterIterator>::value_type
|
||||
#endif
|
||||
, class Reference
|
||||
#if !defined(BOOST_MSVC)
|
||||
, class Reference
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
||||
= BOOST_ARG_DEPENDENT_TYPENAME detail::traits_of_value_type<
|
||||
OuterIterator>::reference
|
||||
#else
|
||||
@ -1102,8 +1123,8 @@ template <class OuterIterator, // Mutable or Immutable, does not matter
|
||||
#endif
|
||||
, class Category = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_traits<
|
||||
OuterIterator>::iterator_category
|
||||
, class Pointer
|
||||
#if !defined(BOOST_MSVC)
|
||||
, class Pointer
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
||||
= BOOST_ARG_DEPENDENT_TYPENAME detail::traits_of_value_type<
|
||||
OuterIterator>::pointer
|
||||
#else
|
||||
@ -1118,28 +1139,28 @@ struct indirect_iterator_generator
|
||||
|
||||
template <class OuterIterator, // Mutable or Immutable, does not matter
|
||||
class Value
|
||||
#if !defined(BOOST_MSVC)
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
||||
= BOOST_ARG_DEPENDENT_TYPENAME detail::traits_of_value_type<
|
||||
OuterIterator>::value_type
|
||||
#endif
|
||||
, class Reference
|
||||
#if !defined(BOOST_MSVC)
|
||||
, class Reference
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
||||
= BOOST_ARG_DEPENDENT_TYPENAME detail::traits_of_value_type<
|
||||
OuterIterator>::reference
|
||||
#else
|
||||
= Value &
|
||||
#endif
|
||||
, class ConstReference = const Value&
|
||||
, class ConstReference = Value const&
|
||||
, class Category = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_traits<
|
||||
OuterIterator>::iterator_category
|
||||
, class Pointer
|
||||
#if !defined(BOOST_MSVC)
|
||||
, class Pointer
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
||||
= BOOST_ARG_DEPENDENT_TYPENAME detail::traits_of_value_type<
|
||||
OuterIterator>::pointer
|
||||
#else
|
||||
= Value*
|
||||
#endif
|
||||
, class ConstPointer = const Value*
|
||||
, class ConstPointer = Value const*
|
||||
>
|
||||
struct indirect_iterator_pair_generator
|
||||
{
|
||||
@ -1149,7 +1170,7 @@ struct indirect_iterator_pair_generator
|
||||
Value, ConstReference,Category,ConstPointer>::type const_iterator;
|
||||
};
|
||||
|
||||
#ifndef BOOST_MSVC
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
||||
template <class OuterIterator>
|
||||
inline typename indirect_iterator_generator<OuterIterator>::type
|
||||
make_indirect_iterator(OuterIterator base)
|
||||
@ -1168,29 +1189,29 @@ struct reverse_iterator_policies : public default_iterator_policies
|
||||
template <class IteratorAdaptor>
|
||||
typename IteratorAdaptor::reference dereference(const IteratorAdaptor& x) const
|
||||
{ return *boost::prior(x.base()); }
|
||||
|
||||
|
||||
template <class BidirectionalIterator>
|
||||
void increment(BidirectionalIterator& x) const
|
||||
{ --x.base(); }
|
||||
|
||||
|
||||
template <class BidirectionalIterator>
|
||||
void decrement(BidirectionalIterator& x) const
|
||||
{ ++x.base(); }
|
||||
|
||||
|
||||
template <class BidirectionalIterator, class DifferenceType>
|
||||
void advance(BidirectionalIterator& x, DifferenceType n) const
|
||||
{ x.base() -= n; }
|
||||
|
||||
|
||||
template <class Iterator1, class Iterator2>
|
||||
typename Iterator1::difference_type distance(
|
||||
const Iterator1& x, const Iterator2& y) const
|
||||
{ return x.base() - y.base(); }
|
||||
|
||||
|
||||
template <class Iterator1, class Iterator2>
|
||||
bool equal(const Iterator1& x, const Iterator2& y) const
|
||||
{ return x.base() == y.base(); }
|
||||
};
|
||||
|
||||
|
||||
template <class BidirectionalIterator,
|
||||
class Value = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_traits<BidirectionalIterator>::value_type,
|
||||
class Reference = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_defaults<BidirectionalIterator,Value>::reference,
|
||||
@ -1226,7 +1247,7 @@ struct projection_iterator_policies : public default_iterator_policies
|
||||
return m_f(*iter.base());
|
||||
}
|
||||
|
||||
AdaptableUnaryFunction m_f;
|
||||
AdaptableUnaryFunction m_f;
|
||||
};
|
||||
|
||||
template <class AdaptableUnaryFunction, class Iterator>
|
||||
@ -1255,7 +1276,7 @@ struct projection_iterator_pair_generator {
|
||||
template <class AdaptableUnaryFunction, class Iterator>
|
||||
inline typename projection_iterator_generator<AdaptableUnaryFunction, Iterator>::type
|
||||
make_projection_iterator(
|
||||
Iterator iter,
|
||||
Iterator iter,
|
||||
const AdaptableUnaryFunction& f = AdaptableUnaryFunction())
|
||||
{
|
||||
typedef typename projection_iterator_generator<AdaptableUnaryFunction, Iterator>::type result_t;
|
||||
@ -1265,7 +1286,7 @@ make_projection_iterator(
|
||||
template <class AdaptableUnaryFunction, class Iterator>
|
||||
inline typename const_projection_iterator_generator<AdaptableUnaryFunction, Iterator>::type
|
||||
make_const_projection_iterator(
|
||||
Iterator iter,
|
||||
Iterator iter,
|
||||
const AdaptableUnaryFunction& f = AdaptableUnaryFunction())
|
||||
{
|
||||
typedef typename const_projection_iterator_generator<AdaptableUnaryFunction, Iterator>::type result_t;
|
||||
@ -1281,7 +1302,7 @@ class filter_iterator_policies
|
||||
public:
|
||||
filter_iterator_policies() { }
|
||||
|
||||
filter_iterator_policies(const Predicate& p, const Iterator& end)
|
||||
filter_iterator_policies(const Predicate& p, const Iterator& end)
|
||||
: m_predicate(p), m_end(end) { }
|
||||
|
||||
void initialize(Iterator& x) {
|
||||
@ -1335,7 +1356,7 @@ namespace detail {
|
||||
template <class Iterator>
|
||||
struct non_bidirectional_category
|
||||
{
|
||||
# if !defined(__MWERKS__) || __MWERKS__ > 0x2405
|
||||
# if !defined(__MWERKS__) || __MWERKS__ > 0x2406
|
||||
typedef typename reduce_to_base_class<
|
||||
std::forward_iterator_tag,
|
||||
typename iterator_traits<Iterator>::iterator_category
|
||||
@ -1361,7 +1382,7 @@ namespace detail {
|
||||
};
|
||||
}
|
||||
|
||||
template <class Predicate, class Iterator,
|
||||
template <class Predicate, class Iterator,
|
||||
class Value = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_traits<Iterator>::value_type,
|
||||
class Reference = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_defaults<Iterator,Value>::reference,
|
||||
class Pointer = BOOST_ARG_DEPENDENT_TYPENAME boost::detail::iterator_defaults<Iterator,Value>::pointer,
|
||||
@ -1371,7 +1392,7 @@ template <class Predicate, class Iterator,
|
||||
class filter_iterator_generator {
|
||||
BOOST_STATIC_CONSTANT(bool, is_bidirectional
|
||||
= (boost::is_convertible<Category*, std::bidirectional_iterator_tag*>::value));
|
||||
#ifndef BOOST_MSVC // I don't have any idea why this occurs, but it doesn't seem to hurt too badly.
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300 // I don't have any idea why this occurs, but it doesn't seem to hurt too badly.
|
||||
BOOST_STATIC_ASSERT(!is_bidirectional);
|
||||
#endif
|
||||
typedef filter_iterator_policies<Predicate,Iterator> policies_type;
|
||||
|
@ -5,6 +5,10 @@
|
||||
// test suite for STL concepts such as iterators and containers.
|
||||
//
|
||||
// Revision History:
|
||||
// 28 Apr 2002 Fixed input iterator requirements.
|
||||
// For a == b a++ == b++ is no longer required.
|
||||
// See 24.1.1/3 for details.
|
||||
// (Thomas Witt)
|
||||
// 08 Feb 2001 Fixed bidirectional iterator test so that
|
||||
// --i is no longer a precondition.
|
||||
// (Jeremy Siek)
|
||||
@ -74,22 +78,40 @@ void mutable_trivial_iterator_test(const Iterator i, const Iterator j, T val)
|
||||
template <class Iterator, class T>
|
||||
void input_iterator_test(Iterator i, T v1, T v2)
|
||||
{
|
||||
Iterator i1 = i, i2 = i;
|
||||
Iterator i1(i);
|
||||
|
||||
assert(i == i1++);
|
||||
assert(i != ++i2);
|
||||
|
||||
trivial_iterator_test(i, i1, v1);
|
||||
trivial_iterator_test(i, i2, v1);
|
||||
|
||||
++i;
|
||||
assert(i == i1);
|
||||
assert(i == i2);
|
||||
++i1;
|
||||
++i2;
|
||||
assert(!(i != i1));
|
||||
|
||||
trivial_iterator_test(i, i1, v2);
|
||||
trivial_iterator_test(i, i2, v2);
|
||||
// I can see no generic way to create an input iterator
|
||||
// that is in the domain of== of i and != i.
|
||||
// The following works for istream_iterator but is not
|
||||
// guaranteed to work for arbitrary input iterators.
|
||||
//
|
||||
// Iterator i2;
|
||||
//
|
||||
// assert(i != i2);
|
||||
// assert(!(i == i2));
|
||||
|
||||
assert(*i1 == v1);
|
||||
assert(*i == v1);
|
||||
|
||||
// we cannot test for equivalence of (void)++i & (void)i++
|
||||
// as i is only guaranteed to be single pass.
|
||||
assert(*i++ == v1);
|
||||
|
||||
i1 = i;
|
||||
|
||||
assert(i == i1);
|
||||
assert(!(i != i1));
|
||||
|
||||
assert(*i1 == v2);
|
||||
assert(*i == v2);
|
||||
|
||||
// i is dereferencable, so it must be incrementable.
|
||||
++i;
|
||||
|
||||
// how to test for operator-> ?
|
||||
}
|
||||
|
||||
// how to test output iterator?
|
||||
@ -124,6 +146,23 @@ void forward_iterator_test(Iterator i, T v1, T v2)
|
||||
{
|
||||
input_iterator_test(i, v1, v2);
|
||||
|
||||
Iterator i1 = i, i2 = i;
|
||||
|
||||
assert(i == i1++);
|
||||
assert(i != ++i2);
|
||||
|
||||
trivial_iterator_test(i, i1, v1);
|
||||
trivial_iterator_test(i, i2, v1);
|
||||
|
||||
++i;
|
||||
assert(i == i1);
|
||||
assert(i == i2);
|
||||
++i1;
|
||||
++i2;
|
||||
|
||||
trivial_iterator_test(i, i1, v2);
|
||||
trivial_iterator_test(i, i2, v2);
|
||||
|
||||
// borland doesn't allow non-type template parameters
|
||||
# if !defined(__BORLANDC__) || (__BORLANDC__ > 0x551)
|
||||
lvalue_test<(boost::is_pointer<Iterator>::value)>::check(i);
|
||||
|
@ -5,6 +5,9 @@
|
||||
// to its suitability for any purpose.
|
||||
//
|
||||
|
||||
#ifndef boost_permutation_iterator_hpp
|
||||
#define boost_permutation_iterator_hpp
|
||||
|
||||
#include <boost/iterator_adaptors.hpp>
|
||||
|
||||
namespace boost {
|
||||
@ -64,3 +67,6 @@ namespace boost {
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // boost_permutation_iterator_hpp
|
||||
|
||||
|
Reference in New Issue
Block a user