diff --git a/development/boost/iterator_categories.hpp b/development/boost/iterator_categories.hpp deleted file mode 100644 index 138a5be..0000000 --- a/development/boost/iterator_categories.hpp +++ /dev/null @@ -1,159 +0,0 @@ -#ifndef BOOST_ITERATOR_CATEGORIES_HPP -#define BOOST_ITERATOR_CATEGORIES_HPP - -#include -#include -#include -#include -#include - -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 struct bind { - typedef typename Iterator::return_category type; - }; - }; - - struct traversal_category_from_nested_type { - template struct bind { - typedef typename Iterator::traversal_category type; - }; - }; - - template - struct choose_lvalue_return { - typedef typename ct_if::value, - boost::constant_lvalue_iterator_tag, - boost::mutable_lvalue_iterator_tag>::type type; - }; - - - template - struct iter_category_to_return { - typedef typename ct_if< - is_convertible::value, - typename choose_lvalue_return::type, - typename ct_if< - is_convertible::value, - boost::readable_iterator_tag, - typename ct_if< - is_convertible::value, - boost::writable_iterator_tag, - boost::error_iterator_tag - >::type - >::type - >::type type; - }; - - template - struct iter_category_to_traversal { - typedef typename ct_if< - is_convertible::value, - random_access_traversal_tag, - typename ct_if< - is_convertible::value, - bidirectional_traversal_tag, - forward_traversal_tag - >::type - >::type type; - }; - - struct return_category_from_old_traits { - template class bind { - typedef boost::detail::iterator_traits OldTraits; - typedef typename OldTraits::iterator_category Cat; - typedef typename OldTraits::value_type value_type; - public: - typedef iter_category_to_return::type type; - }; - }; - - struct traversal_category_from_old_traits { - template class bind { - typedef boost::detail::iterator_traits OldTraits; - typedef typename OldTraits::iterator_category Cat; - public: - typedef iter_category_to_traversal::type type; - }; - }; - - template - class choose_return_category { - typedef typename ct_if::value, - return_category_from_nested_type, - return_category_from_old_traits>::type Choice; - public: - typedef typename Choice:: template bind::type type; - }; - - template - class choose_traversal_category { - typedef typename ct_if::value, - traversal_category_from_nested_type, - traversal_category_from_old_traits>::type Choice; - public: - typedef typename Choice:: template bind::type type; - }; - - } // namespace detail - - template - struct return_category { - typedef typename detail::choose_return_category::type type; - }; - - - template - struct traversal_category { - typedef typename detail::choose_traversal_category::type type; - }; - -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) - - template - struct return_category - { - typedef typename ct_if::value, - constant_lvalue_iterator_tag, - mutable_lvalue_iterator_tag>::type type; - }; - - template - struct traversal_category - { - typedef random_access_traversal_tag type; - }; - -#endif - -} // namespace boost - -#endif // BOOST_ITERATOR_CATEGORIES_HPP diff --git a/development/boost/iterator_concepts.hpp b/development/boost/iterator_concepts.hpp deleted file mode 100644 index a30ff17..0000000 --- a/development/boost/iterator_concepts.hpp +++ /dev/null @@ -1,172 +0,0 @@ -#ifndef BOOST_ITERATOR_CONCEPTS_HPP -#define BOOST_ITERATOR_CONCEPTS_HPP - -#include -#include -#include -#include - -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 - class ReadableIteratorConcept { - public: - typedef typename std::iterator_traits::value_type value_type; - typedef typename std::iterator_traits::reference reference; - typedef typename boost::return_category::type return_category; - - void constraints() { - boost::function_requires< boost::SGIAssignableConcept >(); - boost::function_requires< boost::EqualityComparableConcept >(); - boost::function_requires< - boost::DefaultConstructibleConcept >(); - - BOOST_STATIC_ASSERT((boost::is_convertible::value)); - - reference r = *i; // or perhaps read(x) - value_type v(r); - boost::ignore_unused_variable_warning(v); - } - Iterator i; - }; - - template - class WritableIteratorConcept { - public: - typedef typename boost::return_category::type return_category; - - void constraints() { - boost::function_requires< boost::SGIAssignableConcept >(); - boost::function_requires< boost::EqualityComparableConcept >(); - boost::function_requires< - boost::DefaultConstructibleConcept >(); - - BOOST_STATIC_ASSERT((boost::is_convertible::value)); - - *i = v; // a good alternative could be something like write(x, v) - } - ValueType v; - Iterator i; - }; - - template - class ConstantLvalueIteratorConcept { - public: - typedef typename std::iterator_traits::value_type value_type; - typedef typename std::iterator_traits::reference reference; - typedef typename boost::return_category::type return_category; - - void constraints() { - boost::function_requires< ReadableIteratorConcept >(); - - BOOST_STATIC_ASSERT((boost::is_convertible::value)); - - BOOST_STATIC_ASSERT((boost::is_same::value)); - - reference v = *i; - boost::ignore_unused_variable_warning(v); - } - Iterator i; - }; - - template - class MutableLvalueIteratorConcept { - public: - typedef typename std::iterator_traits::value_type value_type; - typedef typename std::iterator_traits::reference reference; - typedef typename boost::return_category::type return_category; - - void constraints() { - boost::function_requires< ReadableIteratorConcept >(); - boost::function_requires< - WritableIteratorConcept >(); - - BOOST_STATIC_ASSERT((boost::is_convertible::value)); - - BOOST_STATIC_ASSERT((boost::is_same::value)); - - reference v = *i; - boost::ignore_unused_variable_warning(v); - } - Iterator i; - }; - - //=========================================================================== - // Iterator Traversal Concepts - - template - class ForwardIteratorConcept { - public: - typedef typename boost::traversal_category::type traversal_category; - - void constraints() { - boost::function_requires< boost::SGIAssignableConcept >(); - boost::function_requires< boost::EqualityComparableConcept >(); - boost::function_requires< - boost::DefaultConstructibleConcept >(); - - BOOST_STATIC_ASSERT((boost::is_convertible::value)); - ++i; - (void)i++; - } - Iterator i; - }; - - template - class BidirectionalIteratorConcept { - public: - typedef typename boost::traversal_category::type traversal_category; - - void constraints() { - boost::function_requires< ForwardIteratorConcept >(); - - BOOST_STATIC_ASSERT((boost::is_convertible::value)); - - --i; - (void)i--; - } - Iterator i; - }; - - template - class RandomAccessIteratorConcept { - public: - typedef typename boost::traversal_category::type traversal_category; - typedef typename std::iterator_traits::difference_type - difference_type; - - void constraints() { - boost::function_requires< BidirectionalIteratorConcept >(); - - BOOST_STATIC_ASSERT((boost::is_convertible::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 diff --git a/development/libs/iterator/concept_tests.cpp b/development/libs/iterator/concept_tests.cpp deleted file mode 100644 index f75f311..0000000 --- a/development/libs/iterator/concept_tests.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include -#include - -struct new_iterator - : public boost::iterator, - 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 -{ - 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 >(); - boost::function_requires< - boost_concepts::RandomAccessIteratorConcept >(); - - boost::function_requires< - boost_concepts::ConstantLvalueIteratorConcept >(); - boost::function_requires< - boost_concepts::RandomAccessIteratorConcept >(); -#endif - - boost::function_requires< - boost_concepts::MutableLvalueIteratorConcept >(); - boost::function_requires< - boost_concepts::RandomAccessIteratorConcept >(); - - boost::function_requires< - boost_concepts::MutableLvalueIteratorConcept >(); - boost::function_requires< - boost_concepts::RandomAccessIteratorConcept >(); - return 0; -} diff --git a/development/libs/iterator/iterator_categories.htm b/development/libs/iterator/iterator_categories.htm deleted file mode 100644 index 83c29e5..0000000 --- a/development/libs/iterator/iterator_categories.htm +++ /dev/null @@ -1,160 +0,0 @@ - - - - Boost Iterator Traits - - - -C++ Boost -
- -

Boost Iterator Category Traits

-Header boost/iterator_categories.hpp - -

-The boost::traversal_category and -boost::return_category traits classes provides access to the -category tags for iterators that model the Boost Iterator Concepts, 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 std::iterator_traits class. - -

    -
  • traversal_category<Iter>::type   Can the iterator go forward, backward, etc.? -
  • return_category<Iter>::type   Is the iterator read or write only? - Is the dereferenced type an lvalue? -
- -

-An important feature of the boost::traversal_category and -boost::return_category classes is that they are backwards -compatible, i.e., they automatically work for iterators for which -there are valid definitions of std::iterator_traits. The old -iterator_category is mapped to the appropriate traversal and -return categories. - -

-When creating a new iterator type that is meant to work with -boost::traversal_category and -boost::return_category, 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 -new_iterator_base to let the category traits know -that it will be able to find typedefs for traversal_category -and return_category in you iterator class. - - -Each of the new iterator requirements will need a category tag. - -

-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 { };
-
-}
-
- -

-The following is pseudo-code for the iterator category traits classes. - -

-namespace boost {
-
-  // 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 { };
-
-  template <typename Iterator>
-  struct return_category
-  {
-    // Pseudo-code
-    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*>
-  {
-    // Pseudo-code
-    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
-  {
-    // Pseudo-code
-    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;
-  };
-
-}
-
- -
-
jeremy siek
- - -Last modified: Mon Mar 19 12:59:30 EST 2001 - - - diff --git a/development/libs/iterator/iterator_concepts.fig b/development/libs/iterator/iterator_concepts.fig deleted file mode 100644 index 198205e..0000000 --- a/development/libs/iterator/iterator_concepts.fig +++ /dev/null @@ -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 diff --git a/development/libs/iterator/iterator_concepts.gif b/development/libs/iterator/iterator_concepts.gif deleted file mode 100644 index bac35c7..0000000 Binary files a/development/libs/iterator/iterator_concepts.gif and /dev/null differ diff --git a/development/libs/iterator/iterator_concepts.htm b/development/libs/iterator/iterator_concepts.htm deleted file mode 100644 index f2f8dcd..0000000 --- a/development/libs/iterator/iterator_concepts.htm +++ /dev/null @@ -1,663 +0,0 @@ - - - - -Iterator Concepts - -C++ Boost - -
- - -

Iterator Concepts

- -

The standard iterator categories and requirements are flawed because -they use a single hierarchy of requirements to address two orthogonal -issues: iterator traversal and dereference return -type. 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. - -

-The iterator requirements should be separated into two hierarchies. -One set of concepts handles the return type semantics: -

- -The other set of concepts handles iterator traversal: - - - -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. - -

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

-
- - - -
Figure 1: -The iterator concepts and refinement relationships. -
-
-

- - -

Relationship with the standard iterator concepts

- -

-std::Input Iterator implies boost::ReadableIterator. - -

-std::Output Iterator implies boost::Writable Iterator. - -

-std::Forward Iterator refines boost::Forward Iterator and -boost::Constant Lvalue Iterator or boost::Mutable Lvalue Iterator. - -

-std::Bidirectional Iterator refines boost::Bidirectional Iterator and -boost::Constant Lvalue Iterator or boost::Mutable Lvalue Iterator. - -

-std::Random Access Iterator refines boost::Random Access Iterator and -boost::Constant Lvalue Iterator or boost::Mutable Lvalue Iterator. - - -

Notation

- - - - - - - - - - - - - - - - - -
XThe iterator type.
TThe value type of X, i.e., std::iterator_traits<X>::value_type.
x, yAn object of type X.
tAn object of type T.
- -

- -


- - -

-Readable Iterator -

- -A Readable Iterator is an iterator that dereferences to produce an -rvalue that is convertible to the value_type of the -iterator. - -

Associated Types

- - - - - - - - - - - - - - - - - - - - - -
Value typestd::iterator_traits<X>::value_typeThe type of the objects pointed to by the iterator.
Reference typestd::iterator_traits<X>::reference - The return type of dereferencing the iterator. This - type must be convertible to T. -
Return Categorystd::return_category<X>::type - A type convertible to std::readable_iterator_tag -
- -

Refinement of

- -Copy Constructible - -

Valid expressions

- - - - - - - - - - - - - - - -
NameExpressionType requirementsReturn type
Dereference*x std::iterator_traits<X>::reference
Member accessx->mT is a type with a member named m. -If m is a data member, the type of m. -If m is a member function, the return type of m. -
- -

- -


- - -

-Writable Iterator -

- -A Writable Iterator is an iterator that can be used to store a value -using the dereference-assignment expression. - -

Definitions

- -If x is an Writable Iterator of type X, then the -expression *x = a; stores the value a into -x. Note that operator=, like other C++ functions, -may be overloaded; it may, in fact, even be a template function. In -general, then, a may be any of several different types. A -type A belongs to the set of value types of X -if, for an object a of type A, *x = a; is -well-defined and does not require performing any non-trivial -conversions on a. - -

Associated Types

- - - - - - - - - -
Return Categorystd::return_category<X>::type - A type convertible to std::writable_iterator_tag -
- - - -

Refinement of

- -Copy Constructible - -

Valid expressions

- - - - - - - - - - -
NameExpressionReturn type
Dereference assignment*x = aunspecified
- -

- - -


- - -

-Swappable Iterator -

- -A Swappable Iterator is an iterator whose dereferenced values can be -swapped. - -

-Note: the requirements for Swappable Iterator are dependent on the -issues surrounding std::swap() being resolved. Here we assume -that the issue will be resolved by allowing the overload of -std::swap() for user-defined types. - -

-Note: Readable Iterator and Writable Iterator combined implies -Swappable Iterator because of the fully templated -std::swap(). However, Swappable Iterator does not imply -Readable Iterator nor Writable Iterator. - -

Associated Types

- - - - - - - - - -
Return Categorystd::return_category<X>::type - A type convertible to std::swappable_iterator_tag -
- - -

Valid expressions

- -Of the two valid expressions listed below, only one OR the -other is required. If std::iter_swap() is overloaded for -X then std::swap() is not required. If -std::iter_swap() is not overloaded for X then the -default (fully templated) version is used, which will call -std::swap() (this means changing the current requirements for -std::iter_swap()). - -

- - - - - - - - - - - - - - - - - -
NameExpressionReturn type
Iterator Swapstd::iter_swap(x, y)void
Dereference and Swapstd::swap(*x, *y)void
- -

- - -


- - -

-Constant Lvalue Iterator -

- -A Constant Lvalue Iterator is an iterator that dereferences to produce a -const reference to the pointed-to object, i.e., the associated -reference type is const T&. Changing the value -of or destroying an iterator that models Constant Lvalue Iterator does -not invalidate pointers and references previously obtained from that -iterator. - - -

Refinement of

- -Readable Iterator - -

Associated Types

- - - - - - - - - - - - - - - - - -
Reference typestd::iterator_traits<X>::reference - The return type of dereferencing the iterator, which must be - const T&. -
Return Categorystd::return_category<X>::type - A type convertible to std::constant_lvalue_iterator_tag -
- - - -

- -


- - -

-Mutable Lvalue Iterator -

- -A Mutable Lvalue Iterator is an iterator that dereferences to produce a -reference to the pointed-to object. The associated reference -type is T&. Changing the value of or destroying an -iterator that models Mutable Lvalue Iterator does not invalidate -pointers and references previously obtained from that iterator. - -

Refinement of

- -Readable Iterator, -Writable Iterator, -and Swappable Iterator. - - - -

Associated Types

- - - - - - - - - - - - - - - - - -
Reference typestd::iterator_traits<X>::referenceThe return type of dereferencing the iterator, which must be - T&.
Return Categorystd::return_category<X>::type - A type convertible to std::mutable_lvalue_iterator_tag -
- - - -

-


- - -

-Forward Traversal Iterator -

- -The Forward Iterator is an iterator that can be incremented. Also, it -is permissible to make multiple passes through the iterator's range. - -

Refinement of

- -Copy Constructible, -Assignable, -Default Constructible, and -Equality Comparable - - -

Associated types

- - - - - - - - - - - - - - -
Difference Typestd::iterator_traits<X>::difference_type - A signed integral type used for representing distances - between iterators that point into the same range. -
Traversal Categorystd::traversal_category<X>::type - A type convertible to std::forward_traversal_tag -
- -

Valid expressions

- - - - - - - - - - - - - - -
NameExpressionType requirementsReturn type
Preincrement++i X&
Postincrementi++ convertible to const X&
- -

-


- - -

-Bidirectional Traversal Iterator -

- -An iterator that can be incremented and decremented. - -

Refinement of

- -Forward Traversal Iterator - -

Associated types

- - - - - - - -
Traversal Categorystd::traversal_category<X>::type - A type convertible to std::bidirectional_traversal_tag -
- -

Valid expressions

- - - - - - - - - - - - -
NameExpressionType requirementsReturn type
Predecrement--i X&
Postdecrementi-- convertible to const X&
- -

-


- - -

-Random Access Traversal Iterator -

- -An iterator that provides constant-time methods for moving forward and -backward in arbitrary-sized steps. - -

Refinement of

- -Bidirectional Traversal Iterator and -Less Than Comparable where < is a total ordering - -

Associated types

- - - - - - - -
Traversal Categorystd::traversal_category<X>::type - A type convertible to std::random_access_traversal_tag -
- -

Valid expressions

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameExpressionType requirementsReturn type
Iterator additioni += n X&
Iterator additioni + n or n + i X
Iterator subtractioni -= n X&
Iterator subtractioni - n X
Differencei - j std::iterator_traits<X>::difference_type
Element operatori[n]X must also be a model of - Readable Iterator. std::iterator_traits<X>::reference
Element assignmenti[n] = tX must also be a model of - Writable Iterator.unspecified
- -

- -


- - -
Copyright © 2000 -Jeremy Siek, Univ.of Notre Dame (jsiek@lsc.nd.edu) -
- - - diff --git a/doc/GNUmakefile b/doc/GNUmakefile deleted file mode 100755 index a536710..0000000 --- a/doc/GNUmakefile +++ /dev/null @@ -1,232 +0,0 @@ -# GNUmakefile for postprocessing PDF files -# -# © 2000 IBM Corporation. -# Licensed under the GNU GPL. - -######################################################################## -# Make sure that the following macros are correct for your setup -######################################################################## -# ... System utilities -RMRF = /bin/rm -rf -MV = /bin/mv -EGREP = /bin/egrep -ECHO = /bin/echo -PERL = /usr/bin/perl -CAT = /bin/cat -TOUCH = /bin/touch -ZIP = /usr/bin/zip - -# ... TeX & postprocessors -PPOWER4 = ppower4 -PDFLATEX = pdflatex -METAPOST = mpost -FIG2DEV = fig2dev -BIBTEX = bibtex -FOLIAGECUTTER = foliageCutter --verbose -RST2LATEX = rst2latex --documentclass book --documentoptions 10pt,twoside,pdftex # --use-latex-toc -RST2HTML = rst2html - -TEX = latex -export TEX -######################################################################## -# End of user servicable parts; don't fiddle with the remainder of this -# makefile unless you know what you do. -# -# You have been warned ;=) -######################################################################## - -# ... Variables -TEXFILES = $(strip $(wildcard *.tex)) -RSTFILES = $(strip $(wildcard *.rst)) --include GNUmakefile.local -TEXSTEMS = $(strip $(patsubst %.tex,%,${TEXFILES})) -RSTSTEMS = $(strip $(patsubst %.rst,%,${RSTFILES})) -CUTFOILS = $(strip $(patsubst %,%---toc.tex,${TEXSTEMS})) -PDFFILES = $(strip $(patsubst %.tex,%.pdf,${TEXFILES})) -PRINTS = $(patsubst %.pdf,%-print.pdf,${PDFFILES}) -PRINTZIP = prints.zip -SLIDEZIP = slides.zip - -# ... Depend -DEPENDFILE = .depend -GENFILE = .generated - -# ... List of extensions and files generated -texcrap = *.mpx *.log *.aux *.blg *-print.brf *-print.tex *.out - -mpxcrap = mpxerr.tex mpxerr.pdf - -generated = *.out *.[0-9] *.[0-9][0-9] *.bbl *.brf \ - *.mp *.mmp *.pdf .depend *.ps TMP-*.pdf *.ftoc\ - ${PRINTZIP} ${SLIDEZIP} ${GENFILE} ${DEPENDFILE} \ - ${texcrap} ${mpxcrap} ${CUTFOILS} $(strip $(wildcard *---*.tex)) - - -# ... canned command to run PDFLaTeX -define run-pdflatex -@${ECHO} "" -@${ECHO} "---- Running PDFLaTeX on $<" && ${PDFLATEX} $< -@${ECHO} "---- Running PDFLaTeX on $< again" && ${PDFLATEX} $< --@(${EGREP} -qi 'Rerun to get' $*.log && \ - ${ECHO} "---- Rerunning PDFLaTeX on $* to get cross-refs right" && \ - ${PDFLATEX} $<) || \ - ${ECHO} "---- No cross-refs correcting PDFLaTeX rerun required for $*" --@(${EGREP} -qi $*.ftoc $*.log && \ - ${ECHO} "---- Rerunning PDFLaTeX on $* for FTOC" && \ - ${PDFLATEX} $<) || \ - ${ECHO} "---- No FTOC PDFLaTeX run required for $*" --@(${EGREP} -qi 'Warning: Citation' $*.log && \ - ${ECHO} "---- Running BIBTeX on $*" && \ - ${BIBTEX} $* && \ - ${ECHO} "---- Running PDFLaTeX on $<" && \ - ${PDFLATEX} $<) || \ - ${ECHO} "---- No BIBTeX run required for $*" --@(${EGREP} -qi 'Warning: .+undefined references' $*.log && \ - ${ECHO} "---- Running PDFLaTeX on $<" && \ - ${PDFLATEX} $<) || \ - ${ECHO} "---- No further PDFLaTex run required for $<" -@${ECHO} "Generated: $@ {$<}" >> ${GENFILE} -@${RMRF} ${texcrap} -endef - -# ... canned command to run PDFLaTeX for printable versions -define run-pdflatex-for-print -@${ECHO} "" -@${ECHO} "---- Running PDFLaTeX on $*-print.tex" && ${PDFLATEX} $*-print.tex -@${ECHO} "---- Running PDFLaTeX on $< again" && ${PDFLATEX} $< --@(${EGREP} -qi 'Warning: Citation' $*-print.log && \ - ${ECHO} "---- Running BIBTeX on $*-print" && \ - ${BIBTEX} $*-print && \ - ${ECHO} "---- Running PDFLaTeX on $*-print.tex" && \ - ${PDFLATEX} $*-print.tex) || \ - ${ECHO} "---- No BIBTeX run required for $*" --@(${EGREP} -qi 'Warning: .+undefined references' $*-print.log && \ - ${ECHO} "---- Running PDFLaTeX on $*-print" && \ - ${PDFLATEX} $*-print.tex) || \ - ${ECHO} "---- No further PDFLaTex run required for $*-print" -@${ECHO} "Generated: $@ {$<}" >> ${GENFILE} -@${RMRF} ${texcrap} -endef - -# DWA begin modifications -# ... Rule: How to generate TeX from ReST -%.tex: %.txt - @${ECHO} "---- Running rst2latex on $<" - ${RST2LATEX} $< $@ - @${ECHO} "Generated: $@ {$<}" >> ${GENFILE} - -# ... Rule: How to generate TeX from ReST -%.tex: %.rst - @${ECHO} "---- Running rst2latex on $<" - ${RST2LATEX} $< $@ - @${ECHO} "Generated: $@ {$<}" >> ${GENFILE} - -# ... Rule: How to generate HTML from ReST -%.html: %.txt - @${ECHO} "---- Running rst2html on $<" - ${RST2HTML} $< $@ - @${ECHO} "Generated: $@ {$<}" >> ${GENFILE} - -# ... Rule: How to generate HTML from ReST -%.html: %.rst - @${ECHO} "---- Running rst2html on $<" - ${RST2HTML} $< $@ - @${ECHO} "Generated: $@ {$<}" >> ${GENFILE} -# DWA end modifications - -# ... Rule: How to generate PDF from TeX -%.pdf: %.tex - $(run-pdflatex) - @${MV} $@ TMP-$@ - @${ECHO} "---- Running PPower4 on $*" - ${PPOWER4} -v TMP-$@ $@ - @${RMRF} TMP-$@ - @${ECHO} "Postprocessed: $*.pdf {$*.pdf}" >> ${GENFILE} - -# ... Rule: How to generate printable PDF from TeX -%-print.pdf: %.tex - ${PERL} -pe 's/^\\documentclass\[(.*?)\]/\\documentclass\[$$1,prints\]/;' < $< > $*-print.tex - $(run-pdflatex-for-print) - @${ECHO} "Generated: $*-print.pdf {$*.pdf}" >> ${GENFILE} - -# ... Rule: How to generate cut foils from TeX master -%---toc.tex: %.tex - ${FOLIAGECUTTER} --prefix=$* $< - -# ... Rule: How to generate MetaPost from FIG -%.mp: %.fig - @${ECHO} "---- Running Fig2Dev (mp) on $<" - ${FIG2DEV} -L mp $< $@ - @${ECHO} "Generated: $@ {$<}" >> ${GENFILE} - -# ... Rule: How to generate MultiMetaPost from FIG -%.mmp: %.fig - @${ECHO} "---- Running Fig2Dev (mmp) on $<" - ${FIG2DEV} -L mmp $< $@ - @${ECHO} "Generated: $@ {$<}" >> ${GENFILE} - -# ... Rule: How to generate includable PS from FIG via MetaPost -%.mps: %.fig - @${ECHO} "---- Running Fig2Dev (mps) on $<" - ${FIG2DEV} -L mp $< $*.mps.mp - @${RMRF} $*.mps.[0-9] - ${METAPOST} $*.mps.mp - @${MV} $*.mps.0 $@ - @${ECHO} "Generated: $@ {$<}" >> ${GENFILE} - -# ... Rule: How to generate includable PS files from MultiMetaPost -%.0: %.mmp - @${ECHO} "---- Running MetaPost on $<" - @${RMRF} $*.[0-9] $*.[0-9][0-9] - ${METAPOST} $< - @${ECHO} "Generated: $*.0{...} {$<}" >> ${GENFILE} - -cleanup-crap: - @${RMRF} ${mpxcrap} - -# ... Target: all -all: cleanup-crap .depend ${PDFFILES} ${PRINTS} ${PRINTZIP} ${SLIDEZIP} - @${ECHO} "" - @${TOUCH} ${GENFILE} - @${CAT} ${GENFILE} - @${RMRF} ${GENFILE} - -# ... Target: ZIP files -zip zips: ${PRINTZIP} ${SLIDEZIP} - -# ... Target: ZIP file containing printable versions of slides -${PRINTZIP}: .depend ${PDFFILES} - @${RMRF} ${PRINTZIP} - ${ZIP} -r ${PRINTZIP} ${PRINTS} - @${ECHO} "Generated: ${PRINTZIP}" >> ${GENFILE} - -# ... Target: ZIP file containing screen versions of slides - ${SLIDEZIP}: .depend ${PDFFILES} - @${RMRF} ${SLIDEZIP} - ${ZIP} -r ${SLIDEZIP} ${PDFFILES} - @${ECHO} "Generated: ${SLIDEZIP}" >> ${GENFILE} - -# ... Target: clean up -clean: - ${RMRF} ${generated} - -# ... Target: create dependencies -depend: .depend - -# ... Target: dependency file (parse TEXFILES for multiinclude and includegraphics) -.depend: GNUmakefile ${TEXFILES} - ${RMRF} $@ - @for t in ${TEXSTEMS} ; do \ - ${ECHO} "Scanning $$t.tex"; \ - ${PERL} -e 'my $$target = shift @ARGV;' -e 'while (<>) { /\\multiinclude(\[.*?\])?{(.*?)}/ && print "$$target: $$2.0\n";}' $$t.pdf < $$t.tex >> $@; \ - ${PERL} -e 'my $$target = shift @ARGV;' -e 'while (<>) { /\\includegraphics(\[.*?\])?{(.*?)\.(.*?)}/ && print "$$target: $$2.$$3\n";}' $$t.pdf < $$t.tex >> $@; \ - done - @for t in ${RSTSTEMS} ; do \ - ${ECHO} "Scanning $$t.rst"; \ - ${PERL} -e 'my $$target = shift @ARGV;' -e 'while (<>) { /^\.\. include::\s+(.*)/ && print "$$target: $$1\n";}' $$t.html < $$t.rst >> $@; \ - ${PERL} -e 'my $$target = shift @ARGV;' -e 'while (<>) { /^\.\. include::\s+(.*)/ && print "$$target: $$1\n";}' $$t.tex < $$t.rst >> $@; \ - done - - -# ... include dependency file --include .depend diff --git a/doc/access.png b/doc/access.png deleted file mode 100644 index 80011dc..0000000 Binary files a/doc/access.png and /dev/null differ diff --git a/doc/access2old.png b/doc/access2old.png deleted file mode 100644 index 8a87b84..0000000 Binary files a/doc/access2old.png and /dev/null differ diff --git a/doc/counting_iterator.html b/doc/counting_iterator.html deleted file mode 100644 index 15fc046..0000000 --- a/doc/counting_iterator.html +++ /dev/null @@ -1,347 +0,0 @@ - - - - - - -Counting Iterator - - - - - - - -
-

Counting Iterator

- --- - - - - - - - - - - - -
Author:David Abrahams, Jeremy Siek, Thomas Witt
Contact:dave@boost-consulting.com, jsiek@osl.iu.edu, witt@ive.uni-hannover.de
Organization:Boost Consulting, Indiana University Open Systems -Lab, University of Hanover Institute for Transport -Railway Operation and Construction
Date:2003-09-14
Copyright:Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved
- --- - - - -
abstract:
-

The counting iterator adaptor implements dereference by returning a -reference to the base object. The other operations are implemented by -the base m_iterator, as per the inheritance from -iterator_adaptor.

- -
-template <
-    class Incrementable
-  , unsigned Access = use_default_access
-  , class Traversal = use_default
-  , class Difference = use_default
->
-class counting_iterator
-  : public iterator_adaptor<
-        counting_iterator<Incrementable, Access, Traversal, Difference>
-      , Incrementable
-      , Incrementable
-      , Access
-      , /* see details for traversal category */
-      , Incrementable const&
-      , Incrementable const*
-      , /* distance = Difference or a signed integral type */>
-{
-    friend class iterator_core_access;
- public:
-    counting_iterator();
-    counting_iterator(counting_iterator const& rhs);
-    counting_iterator(Incrementable x);
- private:
-    typename counting_iterator::reference dereference() const
-    {
-        return this->base_reference();
-    }
-  };
-
-
-
[Note: implementers are encouraged to provide an implementation of
-
distance_to and a difference_type that avoids overflows in -the cases when the Incrementable type is a numeric type.]
-
-
-

counting_iterator requirements

-

The Incrementable type must be Default Constructible, Copy -Constructible, and Assignable. The default distance is -an implementation defined signed integegral type.

-

The resulting counting_iterator models Readable Lvalue Iterator.

-

Furthermore, if you wish to create a counting iterator that is a Forward -Traversal Iterator, then the following expressions must be valid:

-
-Incrementable i, j;
-++i         // pre-increment
-i == j      // operator equal
-
-

If you wish to create a counting iterator that is a -Bidirectional Traversal Iterator, then pre-decrement is also required:

-
---i
-
-

If you wish to create a counting iterator that is a Random Access -Traversal Iterator, then these additional expressions are also -required:

-
-counting_iterator::difference_type n;
-i += n
-n = i - j
-i < j
-
-
-
-

counting_iterator operations

-

counting_iterator();

- --- - - - -
Returns:A default constructed instance of counting_iterator.
-

counting_iterator(counting_iterator const& rhs);

- --- - - - -
Returns:An instance of counting_iterator that is a copy of rhs.
-

counting_iterator(Incrementable x);

- --- - - - -
Returns:An instance of counting_iterator with its base -object copy constructed from x.
-
-
- - - - diff --git a/doc/counting_iterator.rst b/doc/counting_iterator.rst deleted file mode 100644 index 25fb3b3..0000000 --- a/doc/counting_iterator.rst +++ /dev/null @@ -1,23 +0,0 @@ -+++++++++++++++++++ - Counting Iterator -+++++++++++++++++++ - -:Author: David Abrahams, Jeremy Siek, Thomas Witt -:Contact: dave@boost-consulting.com, jsiek@osl.iu.edu, witt@ive.uni-hannover.de -:organization: `Boost Consulting`_, Indiana University `Open Systems - Lab`_, University of Hanover `Institute for Transport - Railway Operation and Construction`_ -:date: $Date$ -:copyright: Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved - -.. _`Boost Consulting`: http://www.boost-consulting.com -.. _`Open Systems Lab`: http://www.osl.iu.edu -.. _`Institute for Transport Railway Operation and Construction`: http://www.ive.uni-hannover.de - -:abstract: - -.. include:: counting_iterator_abstract.rst - -.. contents:: Table of Contents - -.. include:: counting_iterator_ref.rst diff --git a/doc/counting_iterator_abstract.rst b/doc/counting_iterator_abstract.rst deleted file mode 100644 index 2ac2233..0000000 --- a/doc/counting_iterator_abstract.rst +++ /dev/null @@ -1,5 +0,0 @@ -The counting iterator adaptor implements dereference by returning a -reference to the base object. The other operations are implemented by -the base ``m_iterator``, as per the inheritance from -``iterator_adaptor``. - diff --git a/doc/counting_iterator_ref.rst b/doc/counting_iterator_ref.rst deleted file mode 100644 index f443682..0000000 --- a/doc/counting_iterator_ref.rst +++ /dev/null @@ -1,91 +0,0 @@ -:: - - template < - class Incrementable - , unsigned Access = use_default_access - , class Traversal = use_default - , class Difference = use_default - > - class counting_iterator - : public iterator_adaptor< - counting_iterator - , Incrementable - , Incrementable - , Access - , /* see details for traversal category */ - , Incrementable const& - , Incrementable const* - , /* distance = Difference or a signed integral type */> - { - friend class iterator_core_access; - public: - counting_iterator(); - counting_iterator(counting_iterator const& rhs); - counting_iterator(Incrementable x); - private: - typename counting_iterator::reference dereference() const - { - return this->base_reference(); - } - }; - - -[*Note:* implementers are encouraged to provide an implementation of - ``distance_to`` and a ``difference_type`` that avoids overflows in - the cases when the ``Incrementable`` type is a numeric type.] - -``counting_iterator`` requirements ----------------------------------- - -The ``Incrementable`` type must be Default Constructible, Copy -Constructible, and Assignable. The default distance is -an implementation defined signed integegral type. - -The resulting ``counting_iterator`` models Readable Lvalue Iterator. - -Furthermore, if you wish to create a counting iterator that is a Forward -Traversal Iterator, then the following expressions must be valid: -:: - - Incrementable i, j; - ++i // pre-increment - i == j // operator equal - -If you wish to create a counting iterator that is a -Bidirectional Traversal Iterator, then pre-decrement is also required: -:: - - --i - -If you wish to create a counting iterator that is a Random Access -Traversal Iterator, then these additional expressions are also -required: -:: - - counting_iterator::difference_type n; - i += n - n = i - j - i < j - - - - -``counting_iterator`` operations --------------------------------- - -``counting_iterator();`` - -:Returns: A default constructed instance of ``counting_iterator``. - - -``counting_iterator(counting_iterator const& rhs);`` - -:Returns: An instance of ``counting_iterator`` that is a copy of ``rhs``. - - - -``counting_iterator(Incrementable x);`` - -:Returns: An instance of ``counting_iterator`` with its base - object copy constructed from ``x``. - diff --git a/doc/default.css b/doc/default.css deleted file mode 100644 index 2e1fddb..0000000 --- a/doc/default.css +++ /dev/null @@ -1,188 +0,0 @@ -/* -:Author: David Goodger -:Contact: goodger@users.sourceforge.net -:date: $Date$ -:version: $Revision$ -:copyright: This stylesheet has been placed in the public domain. - -Default cascading style sheet for the HTML output of Docutils. -*/ - -.first { - margin-top: 0 } - -.last { - margin-bottom: 0 } - -a.toc-backref { - text-decoration: none ; - color: black } - -dd { - margin-bottom: 0.5em } - -div.abstract { - margin: 2em 5em } - -div.abstract p.topic-title { - font-weight: bold ; - text-align: center } - -div.attention, div.caution, div.danger, div.error, div.hint, -div.important, div.note, div.tip, div.warning { - margin: 2em ; - border: medium outset ; - padding: 1em } - -div.attention p.admonition-title, div.caution p.admonition-title, -div.danger p.admonition-title, div.error p.admonition-title, -div.warning p.admonition-title { - color: red ; - font-weight: bold ; - font-family: sans-serif } - -div.hint p.admonition-title, div.important p.admonition-title, -div.note p.admonition-title, div.tip p.admonition-title { - font-weight: bold ; - font-family: sans-serif } - -div.dedication { - margin: 2em 5em ; - text-align: center ; - font-style: italic } - -div.dedication p.topic-title { - font-weight: bold ; - font-style: normal } - -div.figure { - margin-left: 2em } - -div.footer, div.header { - font-size: smaller } - -div.system-messages { - margin: 5em } - -div.system-messages h1 { - color: red } - -div.system-message { - border: medium outset ; - padding: 1em } - -div.system-message p.system-message-title { - color: red ; - font-weight: bold } - -div.topic { - margin: 2em } - -h1.title { - text-align: center } - -h2.subtitle { - text-align: center } - -hr { - width: 75% } - -ol.simple, ul.simple { - margin-bottom: 1em } - -ol.arabic { - list-style: decimal } - -ol.loweralpha { - list-style: lower-alpha } - -ol.upperalpha { - list-style: upper-alpha } - -ol.lowerroman { - list-style: lower-roman } - -ol.upperroman { - list-style: upper-roman } - -p.caption { - font-style: italic } - -p.credits { - font-style: italic ; - font-size: smaller } - -p.label { - white-space: nowrap } - -p.topic-title { - font-weight: bold } - -pre.address { - margin-bottom: 0 ; - margin-top: 0 ; - font-family: serif ; - font-size: 100% } - -pre.line-block { - font-family: serif ; - font-size: 100% } - -pre.literal-block, pre.doctest-block { - margin-left: 2em ; - margin-right: 2em ; - background-color: #eeeeee } - -span.classifier { - font-family: sans-serif ; - font-style: oblique } - -span.classifier-delimiter { - font-family: sans-serif ; - font-weight: bold } - -span.interpreted { - font-family: sans-serif } - -span.option-argument { - font-style: italic } - -span.pre { - white-space: pre } - -span.problematic { - color: red } - -table { - margin-top: 0.5em ; - margin-bottom: 0.5em } - -table.citation { - border-left: solid thin gray ; - padding-left: 0.5ex } - -table.docinfo { - margin: 2em 4em } - -table.footnote { - border-left: solid thin black ; - padding-left: 0.5ex } - -td, th { - padding-left: 0.5em ; - padding-right: 0.5em ; - vertical-align: top } - -th.docinfo-name, th.field-name { - font-weight: bold ; - text-align: left ; - white-space: nowrap } - -h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt { - font-size: 100% } - -tt { - background-color: #eeeeee } - -ul.auto-toc { - list-style-type: none } diff --git a/doc/facade-and-adaptor.html b/doc/facade-and-adaptor.html deleted file mode 100755 index a235706..0000000 --- a/doc/facade-and-adaptor.html +++ /dev/null @@ -1,2177 +0,0 @@ - - - - - - -Iterator Facade and Adaptor - - - - - - -
-

Iterator Facade and Adaptor

- --- - - - - - - - - - - - -
Author:David Abrahams, Jeremy Siek, Thomas Witt
Contact:dave@boost-consulting.com, jsiek@osl.iu.edu, witt@acm.org
Organization:Boost Consulting, Indiana University Open Systems -Lab, University of Hanover Institute for Transport -Railway Operation and Construction
Date:2003-11-24
Number:This is a revised version of N1530=03-0113, which was -accepted for Technical Report 1 by the C++ standard -committee's library working group.
- - --- - - - -
copyright:Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved
- --- - - - -
abstract:We propose a set of class templates that help programmers -build standard-conforming iterators, both from scratch and -by adapting other iterators.
-
-

Table of Contents

- -
-
-

Motivation

-

Iterators play an important role in modern C++ programming. The -iterator is the central abstraction of the algorithms of the Standard -Library, allowing algorithms to be re-used in in a wide variety of -contexts. The C++ Standard Library contains a wide variety of useful -iterators. Every one of the standard containers comes with constant -and mutable iterators 2, and also reverse versions of those -same iterators which traverse the container in the opposite direction. -The Standard also supplies istream_iterator and -ostream_iterator for reading from and writing to streams, -insert_iterator, front_insert_iterator and -back_insert_iterator for inserting elements into containers, and -raw_storage_iterator for initializing raw memory [7].

-

Despite the many iterators supplied by the Standard Library, obvious -and useful iterators are missing, and creating new iterator types is -still a common task for C++ programmers. The literature documents -several of these, for example line_iterator [3] and Constant_iterator -[9]. The iterator abstraction is so powerful that we expect -programmers will always need to invent new iterator types.

-

Although it is easy to create iterators that almost conform to the -standard, the iterator requirements contain subtleties which can make -creating an iterator which actually conforms quite difficult. -Further, the iterator interface is rich, containing many operators -that are technically redundant and tedious to implement. To automate -the repetitive work of constructing iterators, we propose -iterator_facade, an iterator base class template which provides -the rich interface of standard iterators and delegates its -implementation to member functions of the derived class. In addition -to reducing the amount of code necessary to create an iterator, the -iterator_facade also provides compile-time error detection. -Iterator implementation mistakes that often go unnoticed are turned -into compile-time errors because the derived class implementation must -match the expectations of the iterator_facade.

-

A common pattern of iterator construction is the adaptation of one -iterator to form a new one. The functionality of an iterator is -composed of four orthogonal aspects: traversal, indirection, equality -comparison and distance measurement. Adapting an old iterator to -create a new one often saves work because one can reuse one aspect of -functionality while redefining the other. For example, the Standard -provides reverse_iterator, which adapts any Bidirectional Iterator -by inverting its direction of traversal. As with plain iterators, -iterator adaptors defined outside the Standard have become commonplace -in the literature:

-
    -
  • Checked iter[13] adds bounds-checking to an existing iterator.
  • -
  • The iterators of the View Template Library[14], which adapts -containers, are themselves adaptors over the underlying iterators.
  • -
  • Smart iterators [5] adapt an iterator's dereferencing behavior by -applying a function object to the object being referenced and -returning the result.
  • -
  • Custom iterators [4], in which a variety of adaptor types are enumerated.
  • -
  • Compound iterators [1], which access a slice out of a container of containers.
  • -
  • Several iterator adaptors from the MTL [12]. The MTL contains a -strided iterator, where each call to operator++() moves the -iterator ahead by some constant factor, and a scaled iterator, which -multiplies the dereferenced value by some constant.
  • -
- - - - - -
[1]We use the term concept to mean a set of requirements -that a type must satisfy to be used with a particular template -parameter.
- - - - - -
[2]The term mutable iterator refers to iterators over objects that -can be changed by assigning to the dereferenced iterator, while -constant iterator refers to iterators over objects that cannot be -modified.
-

To fulfill the need for constructing adaptors, we propose the -iterator_adaptor class template. Instantiations of -iterator_adaptor serve as a base classes for new iterators, -providing the default behavior of forwarding all operations to the -underlying iterator. The user can selectively replace these features -in the derived iterator class. This proposal also includes a number -of more specialized adaptors, such as the transform_iterator that -applies some user-specified function during the dereference of the -iterator.

-
-
-

Impact on the Standard

-

This proposal is purely an addition to the C++ standard library. -However, note that this proposal relies on the proposal for New -Iterator Concepts.

-
-
-

Design

-
-

Iterator Concepts

-

This proposal is formulated in terms of the new iterator concepts -as proposed in n1550, since user-defined and especially adapted -iterators suffer from the well known categorization problems that are -inherent to the current iterator categories.

-

This proposal does not strictly depend on proposal n1550, as there -is a direct mapping between new and old categories. This proposal -could be reformulated using this mapping if n1550 was not accepted.

-
-
-

Interoperability

-

The question of iterator interoperability is poorly addressed in the -current standard. There are currently two defect reports that are -concerned with interoperability issues.

-

Issue 179 concerns the fact that mutable container iterator types -are only required to be convertible to the corresponding constant -iterator types, but objects of these types are not required to -interoperate in comparison or subtraction expressions. This situation -is tedious in practice and out of line with the way built in types -work. This proposal implements the proposed resolution to issue -179, as most standard library implementations do nowadays. In other -words, if an iterator type A has an implicit or user defined -conversion to an iterator type B, the iterator types are interoperable -and the usual set of operators are available.

-

Issue 280 concerns the current lack of interoperability between -reverse iterator types. The proposed new reverse_iterator template -fixes the issues raised in 280. It provides the desired -interoperability without introducing unwanted overloads.

-
-
-

Iterator Facade

- - -

While the iterator interface is rich, there is a core subset of the -interface that is necessary for all the functionality. We have -identified the following core behaviors for iterators:

-
    -
  • dereferencing
  • -
  • incrementing
  • -
  • decrementing
  • -
  • equality comparison
  • -
  • random-access motion
  • -
  • distance measurement
  • -
-

In addition to the behaviors listed above, the core interface elements -include the associated types exposed through iterator traits: -value_type, reference, difference_type, and -iterator_category.

-

Iterator facade uses the Curiously Recurring Template Pattern (CRTP) -[Cop95] so that the user can specify the behavior of -iterator_facade in a derived class. Former designs used policy -objects to specify the behavior. iterator_facade does not use policy -objects for several reasons:

-
-
    -
  1. the creation and eventual copying of the policy object may create -overhead that can be avoided with the current approach.
  2. -
  3. The policy object approach does not allow for custom constructors -on the created iterator types, an essential feature if -iterator_facade should be used in other library -implementations.
  4. -
  5. Without the use of CRTP, the standard requirement that an -iterator's operator++ returns the iterator type itself means -that all iterators generated by iterator_facade would be -specializations of iterator_facade. Cumbersome type generator -metafunctions would be needed to build new parameterized -iterators, and a separate iterator_adaptor layer would be -impossible.
  6. -
-
-
-

Usage

-

The user of iterator_facade derives his iterator class from a -specialization of iterator_facade and passes the derived -iterator class as iterator_facade's first template parameter. -The order of the other template parameters have been carefully -chosen to take advantage of useful defaults. For example, when -defining a constant lvalue iterator, the user can pass a -const-qualified version of the iterator's value_type as -iterator_facade's Value parameter and omit the -Reference parameter which follows.

-

The derived iterator class must define member functions implementing -the iterator's core behaviors. The following table describes -expressions which are required to be valid depending on the category -of the derived iterator type. These member functions are described -briefly below and in more detail in the iterator facade -requirements.

-
- ---- - - - - - - - - - - - - - - - - - - - - - - - - - -
ExpressionEffects
i.dereference()Access the value referred to
i.equal(j)Compare for equality with j
i.increment()Advance by one position
i.decrement()Retreat by one position
i.advance(n)Advance by n positions
i.distance_to(j)Measure the distance to j
-
- -

In addition to implementing the core interface functions, an iterator -derived from iterator_facade typically defines several -constructors. To model any of the standard iterator concepts, the -iterator must at least have a copy constructor. Also, if the iterator -type X is meant to be automatically interoperate with another -iterator type Y (as with constant and mutable iterators) then -there must be an implicit conversion from X to Y or from Y -to X (but not both), typically implemented as a conversion -constructor. Finally, if the iterator is to model Forward Traversal -Iterator or a more-refined iterator concept, a default constructor is -required.

-
-
-

Iterator Core Access

-

iterator_facade and the operator implementations need to be able -to access the core member functions in the derived class. Making the -core member functions public would expose an implementation detail to -the user. The design used here ensures that implementation details do -not appear in the public interface of the derived iterator type.

-

Preventing direct access to the core member functions has two -advantages. First, there is no possibility for the user to accidently -use a member function of the iterator when a member of the value_type -was intended. This has been an issue with smart pointer -implementations in the past. The second and main advantage is that -library implementers can freely exchange a hand-rolled iterator -implementation for one based on iterator_facade without fear of -breaking code that was accessing the public core member functions -directly.

-

In a naive implementation, keeping the derived class' core member -functions private would require it to grant friendship to -iterator_facade and each of the seven operators. In order to -reduce the burden of limiting access, iterator_core_access is -provided, a class that acts as a gateway to the core member functions -in the derived iterator class. The author of the derived class only -needs to grant friendship to iterator_core_access to make his core -member functions available to the library.

- - -

iterator_core_access will be typically implemented as an empty -class containing only private static member functions which invoke the -iterator core member functions. There is, however, no need to -standardize the gateway protocol. Note that even if -iterator_core_access used public member functions it would not -open a safety loophole, as every core member function preserves the -invariants of the iterator.

-
-
-

operator[]

-

The indexing operator for a generalized iterator presents special -challenges. A random access iterator's operator[] is only -required to return something convertible to its value_type. -Requiring that it return an lvalue would rule out currently-legal -random-access iterators which hold the referenced value in a data -member (e.g. counting_iterator), because *(p+n) is a reference -into the temporary iterator p+n, which is destroyed when -operator[] returns.

-

Writable iterators built with iterator_facade implement the -semantics required by the preferred resolution to issue 299 and -adopted by proposal n1550: the result of p[n] is a proxy object -containing a copy of p+n, and p[n] = x is equivalent to *(p -+ n) = x. This approach will work properly for any random-access -iterator regardless of the other details of its implementation. A -user who knows more about the implementation of her iterator is free -to implement an operator[] which returns an lvalue in the derived -iterator class; it will hide the one supplied by iterator_facade -from clients of her iterator.

-
-
-

operator->

-

The reference type of a readable iterator (and today's input -iterator) need not in fact be a reference, so long as it is -convertible to the iterator's value_type. When the value_type -is a class, however, it must still be possible to access members -through operator->. Therefore, an iterator whose reference -type is not in fact a reference must return a proxy containing a copy -of the referenced value from its operator->.

-

The return type for operator-> and operator[] is not -explicitly specified. Instead it requires each iterator_facade -specialization to meet the requirements of its iterator_category.

- - -- - - -
[Cop95][Coplien, 1995] Coplien, J., Curiously Recurring Template -Patterns, C++ Report, February 1995, pp. 24-27.
-
-
-
-

Iterator Adaptor

- - -

The iterator_adaptor class template adapts some Base 3 -type to create a new iterator. Instantiations of iterator_adaptor -are derived from a corresponding instantiation of iterator_facade -and implement the core behaviors in terms of the Base type. In -essence, iterator_adaptor merely forwards all operations to an -instance of the Base type, which it stores as a member.

- - - - - -
[3]The term "Base" here does not refer to a base class and is -not meant to imply the use of derivation. We have followed the lead -of the standard library, which provides a base() function to access -the underlying iterator object of a reverse_iterator adaptor.
-

The user of iterator_adaptor creates a class derived from an -instantiation of iterator_adaptor and then selectively -redefines some of the core member functions described in the table -above. The Base type need not meet the full requirements for an -iterator. It need only support the operations used by the core -interface functions of iterator_adaptor that have not been -redefined in the user's derived class.

-

Several of the template parameters of iterator_adaptor default -to use_default. This allows the -user to make use of a default parameter even when she wants to -specify a parameter later in the parameter list. Also, the -defaults for the corresponding associated types are somewhat -complicated, so metaprogramming is required to compute them, and -use_default can help to simplify the implementation. Finally, -the identity of the use_default type is not left unspecified -because specification helps to highlight that the Reference -template parameter may not always be identical to the iterator's -reference type, and will keep users from making mistakes based on -that assumption.

-
-
-

Specialized Adaptors

-

This proposal also contains several examples of specialized adaptors -which were easily implemented using iterator_adaptor:

-
    -
  • indirect_iterator, which iterates over iterators, pointers, -or smart pointers and applies an extra level of dereferencing.
  • -
  • A new reverse_iterator, which inverts the direction of a Base -iterator's motion, while allowing adapted constant and mutable -iterators to interact in the expected ways (unlike those in most -implementations of C++98).
  • -
  • transform_iterator, which applies a user-defined function object -to the underlying values when dereferenced.
  • -
  • projection_iterator, which is similar to transform_iterator -except that when dereferenced it returns a reference instead of -a value.
  • -
  • filter_iterator, which provides a view of an iterator range in -which some elements of the underlying range are skipped.
  • -
-
    -
  • counting_iterator, which adapts any incrementable type -(e.g. integers, iterators) so that incrementing/decrementing the -adapted iterator and dereferencing it produces successive values of -the Base type.
  • -
  • function_output_iterator, which makes it easier to create custom -output iterators.
  • -
-

Based on examples in the Boost library, users have generated many new -adaptors, among them a permutation adaptor which applies some -permutation to a random access iterator, and a strided adaptor, which -adapts a random access iterator by multiplying its unit of motion by a -constant factor. In addition, the Boost Graph Library (BGL) uses -iterator adaptors to adapt other graph libraries, such as LEDA [10] -and Stanford GraphBase [8], to the BGL interface (which requires C++ -Standard compliant iterators).

-
-
-
-

Proposed Text

-
-

Header <iterator_helper> synopsis [lib.iterator.helper.synopsis]

-
-struct use_default;
-
-struct iterator_core_access { /* implementation detail */ };
-
-template <
-    class Derived
-  , class Value
-  , class CategoryOrTraversal
-  , class Reference  = Value&
-  , class Difference = ptrdiff_t
->
-class iterator_facade;
-
-template <
-    class Derived
-  , class Base
-  , class Value      = use_default
-  , class CategoryOrTraversal  = use_default
-  , class Reference  = use_default
-  , class Difference = use_default
->
-class iterator_adaptor;
-
-template <
-    class Iterator
-  , class Value = use_default
-  , class CategoryOrTraversal = use_default
-  , class Reference = use_default
-  , class Difference = use_default
->
-class indirect_iterator;
-
-template <class Iterator>
-class reverse_iterator;
-
-template <
-    class UnaryFunction
-  , class Iterator
-  , class Reference = use_default
-  , class Value = use_default
->
-class transform_iterator;
-
-template <class Predicate, class Iterator>
-class filter_iterator;
-
-template <
-    class Incrementable
-  , class CategoryOrTraversal  = use_default
-  , class Difference = use_default
->
-class counting_iterator
-
-template <class UnaryFunction>
-class function_output_iterator;
-
-
-
-

Iterator facade [lib.iterator.facade]

-

iterator_facade is a base class template that implements the -interface of standard iterators in terms of a few core functions -and associated types, to be supplied by a derived iterator class.

-
-

Class template iterator_facade

- - -
-template <
-    class Derived
-  , class Value
-  , class CategoryOrTraversal
-  , class Reference  = Value&
-  , class Difference = ptrdiff_t
->
-class iterator_facade {
-public:
-    typedef remove_const<Value>::type value_type;
-    typedef Reference reference;
-    typedef Value* pointer;
-    typedef Difference difference_type;
-    typedef /* see below */ iterator_category;
-
-    reference operator*() const;
-    /* see below */ operator->() const;
-    /* see below */ operator[](difference_type n) const;
-    Derived& operator++();
-    Derived operator++(int);
-    Derived& operator--();
-    Derived operator--(int);
-    Derived& operator+=(difference_type n);
-    Derived& operator-=(difference_type n);
-    Derived operator-(difference_type n) const;
-};
-
-// Comparison operators
-template <class Dr1, class V1, class TC1, class R1, class D1,
-          class Dr2, class V2, class TC2, class R2, class D2>
-typename enable_if_interoperable<Dr1, Dr2, bool>::type // exposition
-operator ==(iterator_facade<Dr1, V1, TC1, R1, D1> const& lhs,
-            iterator_facade<Dr2, V2, TC2, R2, D2> const& rhs);
-
-template <class Dr1, class V1, class TC1, class R1, class D1,
-          class Dr2, class V2, class TC2, class R2, class D2>
-typename enable_if_interoperable<Dr1, Dr2, bool>::type
-operator !=(iterator_facade<Dr1, V1, TC1, R1, D1> const& lhs,
-            iterator_facade<Dr2, V2, TC2, R2, D2> const& rhs);
-
-template <class Dr1, class V1, class TC1, class R1, class D1,
-          class Dr2, class V2, class TC2, class R2, class D2>
-typename enable_if_interoperable<Dr1, Dr2, bool>::type
-operator <(iterator_facade<Dr1, V1, TC1, R1, D1> const& lhs,
-           iterator_facade<Dr2, V2, TC2, R2, D2> const& rhs);
-
-template <class Dr1, class V1, class TC1, class R1, class D1,
-          class Dr2, class V2, class TC2, class R2, class D2>
-typename enable_if_interoperable<Dr1, Dr2, bool>::type
-operator <=(iterator_facade<Dr1, V1, TC1, R1, D1> const& lhs,
-            iterator_facade<Dr2, V2, TC2, R2, D2> const& rhs);
-
-template <class Dr1, class V1, class TC1, class R1, class D1,
-          class Dr2, class V2, class TC2, class R2, class D2>
-typename enable_if_interoperable<Dr1, Dr2, bool>::type
-operator >(iterator_facade<Dr1, V1, TC1, R1, D1> const& lhs,
-           iterator_facade<Dr2, V2, TC2, R2, D2> const& rhs);
-
-template <class Dr1, class V1, class TC1, class R1, class D1,
-          class Dr2, class V2, class TC2, class R2, class D2>
-typename enable_if_interoperable<Dr1, Dr2, bool>::type
-operator >=(iterator_facade<Dr1, V1, TC1, R1, D1> const& lhs,
-            iterator_facade<Dr2, V2, TC2, R2, D2> const& rhs);
-
-template <class Dr1, class V1, class TC1, class R1, class D1,
-          class Dr2, class V2, class TC2, class R2, class D2>
-typename enable_if_interoperable<Dr1, Dr2, bool>::type
-operator >=(iterator_facade<Dr1, V1, TC1, R1, D1> const& lhs,
-            iterator_facade<Dr2, V2, TC2, R2, D2> const& rhs);
-
-// Iterator difference
-template <class Dr1, class V1, class TC1, class R1, class D1,
-          class Dr2, class V2, class TC2, class R2, class D2>
-typename enable_if_interoperable<Dr1, Dr2, bool>::type
-operator -(iterator_facade<Dr1, V1, TC1, R1, D1> const& lhs,
-           iterator_facade<Dr2, V2, TC2, R2, D2> const& rhs);
-
-// Iterator addition
-template <class Derived, class V, class TC, class R, class D>
-Derived operator+ (iterator_facade<Derived, V, TC, R, D> const&,
-                   typename Derived::difference_type n)
-
-

The enable_if_interoperable template used above is for exposition -purposes. The member operators should be only be in an overload set -provided the derived types Dr1 and Dr2 are interoperable, -meaning that at least one of the types is convertible to the other. The -enable_if_interoperable approach uses SFINAE to take the operators -out of the overload set when the types are not interoperable. -The operators should behave as-if enable_if_interoperable -were defined to be:

-
-template <bool, typename> enable_if_interoperable_impl
-{};
-
-template <typename T> enable_if_interoperable_impl<true,T>
-{ typedef T type; };
-
-template<typename Dr1, typename Dr2, typename T>
-struct enable_if_interoperable
-  : enable_if_interoperable_impl<
-        is_convertible<Dr1,Dr2>::value || is_convertible<Dr2,Dr1>::value
-      , T
-    >
-{};
-
-
-

iterator_facade usage

-

The following table describes the typical valid expressions on -iterator_facade's Derived parameter, depending on the -iterator concept(s) it will model. The operations in the first -column must be made accessible to member functions of class -iterator_core_access.

-

In the table below, F is iterator_facade<X,V,C,R,D>, a is an -object of type X, b and c are objects of type const X, -n is an object of F::difference_type, y is a constant -object of a single pass iterator type interoperable with X, and z -is a constant object of a random access traversal iterator type -interoperable with X.

- ------ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ExpressionReturn TypeAssertion/NoteUsed to implement Iterator -Concept(s)
c.dereference()F::reference Readable Iterator, Writable -Iterator
c.equal(b)convertible to booltrue iff b and c are -equivalent.Single Pass Iterator
c.equal(y)convertible to booltrue iff c and y refer to the -same position. Implements c == y -and c != y.Single Pass Iterator
a.advance(n)unused Random Access Traversal -Iterator
a.increment()unused Incrementable Iterator
a.decrement()unused Bidirectional Traversal -Iterator
c.distance_to(b)convertible to -F::difference_typeequivalent to distance(c, b)Random Access Traversal -Iterator
c.distance_to(z)convertible to -F::difference_typeequivalent to distance(c, z). -Implements c - z, c < z, c -<= z, c > z, and c >= c.Random Access Traversal -Iterator
-
-
-

iterator_facade iterator category

-

The iterator_category member of iterator_facade<X,V,R,C,D> -is a type which satisfies the following conditions:

-
-
    -
  • if C is convertible to std::input_iterator_tag or -C is convertible to std::output_iterator_tag, -iterator_category is the same as C.

    -
  • -
  • Otherwise, if C is not convertible to -incrementable_traversal_tag, the program is ill-formed

    -
  • -
  • Otherwise:

    -
      -
    • iterator_category is convertible to the iterator -category tag or tags given by the following algorithm, and -not to any more-derived iterator category tag or tags:

      -
      -if (R is a reference type
      -    && C is convertible to forward_traversal_tag)
      -{
      -    if (C is convertible to random_access_traversal_tag)
      -        return random_access_iterator_tag
      -    else if (C is convertible to bidirectional_traversal_tag)
      -        return bidirectional_iterator_tag
      -    else
      -        return forward_traversal_tag
      -}
      -else
      -{
      -    if (C is convertible to single_pass_traversal_tag
      -        && R is convertible to V)
      -    {
      -        if (V is const)
      -            return input_iterator_tag
      -        else
      -            return input_iterator_tag and output_iterator_tag
      -    }
      -    else
      -        return output_iterator_tag
      -}
      -
      -
    • -
    • iterator_traversal<X>::type is convertible to the most -derived traversal tag type to which C is also -convertible, and not to any more-derived traversal tag type.

      -
    • -
    -
  • -
-
-
-
-

iterator_facade operations

-

The operations in this section are described in terms of operations on -the core interface of Derived which may be inaccessible -(i.e. private). The implementation should access these operations -through member functions of class iterator_core_access.

-

reference operator*() const;

- --- - - - -
Returns:static_cast<Derived const*>(this)->dereference()
-

operator->() const; (see below)

- --- - - - -
Returns:

If reference is a reference type, an object -of type pointer equal to:

-
-&static_cast<Derived const*>(this)->dereference()
-
-

Otherwise returns an object of unspecified type such that, -(*static_cast<Derived const*>(this))->m is equivalent to (w = **static_cast<Derived const*>(this), -w.m) for some temporary object w of type value_type.

-
-

unspecified operator[](difference_type n) const;

- --- - - - -
Returns:an object convertible to reference and holding a copy -p of *static_cast<Derived const*>(this) + n such that, for a constant object v of type -value_type, (*static_cast<Derived const*>(this))[n] = v is equivalent -to p = v.
-

Derived& operator++();

- --- - - - -
Effects:
-static_cast<Derived*>(this)->increment();
-return *static_cast<Derived*>(this);
-
-
-

Derived operator++(int);

- --- - - - -
Effects:
-Derived tmp(static_cast<Derived const*>(this));
-++*this;
-return tmp;
-
-
-

Derived& operator--();

- --- - - - -
Effects:
-static_cast<Derived*>(this)->decrement();
-return static_cast<Derived*>(this);
-
-
-

Derived operator--(int);

- --- - - - -
Effects:
-Derived tmp(static_cast<Derived const*>(this));
---*this;
-return tmp;
-
-
-

Derived& operator+=(difference_type n);

- --- - - - -
Effects:
-static_cast<Derived*>(this)->advance(n);
-return static_cast<Derived*>(this);
-
-
-

Derived& operator-=(difference_type n);

- --- - - - -
Effects:
-static_cast<Derived*>(this)->advance(-n);
-return static_cast<Derived*>(this);
-
-
-

Derived operator-(difference_type n) const;

- --- - - - -
Effects:
-Derived tmp(static_cast<Derived const*>(this));
-return tmp -= n;
-
-
-
-
-
-
-

Iterator adaptor [lib.iterator.adaptor]

- - -

Each specialization of the iterator_adaptor class template is derived from -a specialization of iterator_facade. The core interface functions -expected by iterator_facade are implemented in terms of the -iterator_adaptor's Base template parameter. A class derived -from iterator_adaptor typically redefines some of the core -interface functions to adapt the behavior of the Base type. -Whether the derived class models any of the standard iterator concepts -depends on the operations supported by the Base type and which -core interface functions of iterator_facade are redefined in the -Derived class.

-
-

Class template iterator_adaptor

- - -
-template <
-    class Derived
-  , class Base
-  , class Value        = use_default
-  , class CategoryOrTraversal  = use_default
-  , class Reference  = use_default
-  , class Difference = use_default
->
-class iterator_adaptor 
-  : public iterator_facade<Derived, V, C, R, D> // see details
-{
-    friend class iterator_core_access;
- public:
-    iterator_adaptor();
-    explicit iterator_adaptor(Base iter);
-    Base base() const;
- protected:
-    Base const& base_reference() const;
-    Base& base_reference();
- private: // Core iterator interface for iterator_facade.  
-    typename iterator_adaptor::reference dereference() const;
-
-    template <
-    class OtherDerived, class OtherIterator, class V, class C, class R, class D
-    >   
-    bool equal(iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> const& x) const;
-
-    void advance(typename iterator_adaptor::difference_type n);
-    void increment();
-    void decrement();
-
-    template <
-        class OtherDerived, class OtherIterator, class V, class C, class R, class D
-    >   
-    typename iterator_adaptor::difference_type distance_to(
-        iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> const& y) const;
-
- private:
-    Base m_iterator; // exposition only
-};
-
-
-
-

iterator_adaptor base class parameters

-

The V, C, R, and D parameters of the iterator_facade -used as a base class in the summary of iterator_adaptor -above are defined as follows:

-
-V = if (Value is use_default)
-          return iterator_traits<Base>::value_type
-      else
-          return Value
-
-C = if (CategoryOrTraversal is use_default)
-          return iterator_traversal<Base>::type
-      else
-          return CategoryOrTraversal
-
-R = if (Reference is use_default)
-          if (Value is use_default)
-              return iterator_traits<Base>::reference
-          else
-              return Value&
-      else
-          return Reference
-
-D = if (Difference is use_default)
-          return iterator_traits<Base>::difference_type
-      else
-          return Difference
-
-
-
-

iterator_adaptor usage

-

The Derived template parameter must be a publicly derived from -iterator_adaptor. In order for Derived to model the -iterator concepts corresponding to -iterator_traits<Derived>::iterator_category, the expressions -involving m_iterator in the specifications of those private -member functions of iterator_adaptor that may be called by -iterator_facade<Derived, ``\ *V*\, \ *C*\, \ *R*\, \ -*D*\>`` in evaluating any valid expression involving Derived -in those concepts' requirements.

-
-
-

iterator_adaptor public operations

-

iterator_adaptor();

- --- - - - - - -
Requires:The Base type must be Default Constructible.
Returns:An instance of iterator_adaptor with -m_iterator default constructed.
-

explicit iterator_adaptor(Base iter);

- --- - - - -
Returns:An instance of iterator_adaptor with -m_iterator copy constructed from iter.
-

Base base() const;

- --- - - - -
Returns:m_iterator
-
-
-

iterator_adaptor protected member functions

-

Base const& base_reference() const;

- --- - - - -
Returns:A const reference to m_iterator.
-

Base& base_reference();

- --- - - - -
Returns:A non-const reference to m_iterator.
-
-
-

iterator_adaptor private member functions

-

typename iterator_adaptor::reference dereference() const;

- --- - - - -
Returns:*m_iterator
-
-template <
-class OtherDerived, class OtherIterator, class V, class C, class R, class D
->   
-bool equal(iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> const& x) const;
-
- --- - - - -
Returns:m_iterator == x.base()
-

void advance(typename iterator_adaptor::difference_type n);

- --- - - - -
Effects:m_iterator += n;
-

void increment();

- --- - - - -
Effects:++m_iterator;
-

void decrement();

- --- - - - -
Effects:--m_iterator;
-
-template <
-    class OtherDerived, class OtherIterator, class V, class C, class R, class D
->   
-typename iterator_adaptor::difference_type distance_to(
-    iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> const& y) const;
-
- --- - - - -
Returns:y.base() - m_iterator
-
-
-
-

Specialized adaptors [lib.iterator.special.adaptors]

-

The enable_if_convertible<X,Y>::type expression used in -this section is for exposition purposes. The converting constructors -for specialized adaptors should be only be in an overload set provided -that an object of type X is implicitly convertible to an object of -type Y. -The signatures involving enable_if_convertible should behave -as-if enable_if_convertible were defined to be:

-
-template <bool> enable_if_convertible_impl
-{};
-
-template <> enable_if_convertible_impl<true>
-{ struct type; };
-
-template<typename From, typename To>
-struct enable_if_convertible
-  : enable_if_convertible_impl<is_convertible<From,To>::value>
-{};
-
-

If an expression other than the default argument is used to supply -the value of a function parameter whose type is written in terms -of enable_if_convertible, the program is ill-formed, no -diagnostic required.

-

[Note: The enable_if_convertible approach uses SFINAE to -take the constructor out of the overload set when the types are not -implicitly convertible. -]

-
-

Indirect iterator

-

The indirect iterator adapts an iterator by applying an extra -dereference inside of operator*(). For example, this iterator -adaptor makes it possible to view a container of pointers -(e.g. list<foo*>) as if it were a container of the pointed-to type -(e.g. list<foo>) .

- -
-

Class template indirect_iterator

-
-template <
-    class Iterator
-  , class Value = use_default
-  , class CategoryOrTraversal = use_default
-  , class Reference = use_default
-  , class Difference = use_default
->
-class indirect_iterator
-{
- public:
-    typedef /* see below */ value_type;
-    typedef /* see below */ reference;
-    typedef /* see below */ pointer;
-    typedef /* see below */ difference_type;
-    typedef /* see below */ iterator_category;
-
-    indirect_iterator();
-    indirect_iterator(Iterator x);
-
-    template <
-        class Iterator2, class Value2, class Category2
-      , class Reference2, class Difference2
-    >
-    indirect_iterator(
-        indirect_iterator<
-             Iterator2, Value2, Category2, Reference2, Difference2
-        > const& y
-      , typename enable_if_convertible<Iterator2, Iterator>::type* = 0 // exposition
-    );
-};
-
-

The member types of indirect_iterator are defined according to the -following pseudo-code. We use the abbreviation -V=iterator_traits<Iterator>::value_type.:

-
-if (Value is use_default) then
-    typedef iterator_traits<V>::value_type value_type;
-else
-    typedef remove_const<Value>::type value_type;
-
-if (Reference is use_default) then
-    if (Value is use_default) then
-        typedef iterator_traits<V>::reference reference;
-    else
-        typedef Value& reference;
-else
-    typedef Reference reference;
-
-if (Value is use_default) then
-    typedef ?? pointer;
-else
-    typedef Value* pointer;
-
-if (Difference is use_default)
-    typedef iterator_traits<Iterator>::difference_type difference_type;
-else
-    typedef Difference difference_type;
-
-

The member indirect_iterator::iterator_category is a type that -satisfies the requirements of the concepts modeled by the indirect -iterator as specified in the models section.

-
-
-

indirect_iterator requirements

-

The Iterator argument shall meet the requirements of Readable -Iterator. The CategoryOrTraversal argument shall be one of the -standard iterator tags or use_default. If CategoryOrTraversal -is an iterator tag, the template parameter Iterator argument shall -meet the traversal requirements corresponding to the iterator tag.

-

The expression *v, where v is an object of type -iterator_traits<Iterator>::value_type, must be a valid expression -and must be convertible to indirect_iterator::reference. Also -indirect_iterator::reference must be convertible to -indirect_iterator::value. There are further requirements on the -iterator_traits<Iterator>::value_type if the Value parameter -is not use_default, as implied by the algorithm for deducing the -default for the value_type member.

-
-
-

indirect_iterator models

-

If CategoryOrTraversal is a standard iterator tag, -indirect_iterator is a model of the iterator concept corresponding -to the tag, otherwise indirect_iterator satisfies the requirements -of the most refined standard traversal concept that is satisfied by -the Iterator argument.

-

indirect_iterator models Readable Iterator. If -indirect_iterator::reference(*v) = t is a valid expression (where -t is an object of type indirect_iterator::value_type) then -indirect_iterator models Writable Iterator. If -indirect_iterator::reference is a reference then -indirect_iterator models Lvalue Iterator.

-
-
-

indirect_iterator operations

-

indirect_iterator();

- --- - - - - - -
Requires:Iterator must be Default Constructible.
Returns:An instance of indirect_iterator with -a default-constructed iterator_adaptor subobject.
-

indirect_iterator(Iterator x);

- --- - - - -
Returns:An instance of indirect_iterator with -the iterator_adaptor subobject copy constructed from x.
-
-template <
-    class Iterator2, class Value2, unsigned Access, class Traversal
-  , class Reference2, class Difference2
->
-indirect_iterator(
-    indirect_iterator<
-         Iterator2, Value2, Access, Traversal, Reference2, Difference2
-    > const& y
-  , typename enable_if_convertible<Iterator2, Iterator>::type* = 0 // exposition
-);
-
- --- - - - - - -
Requires:Iterator2 is implicitly convertible to Iterator.
Returns:An instance of indirect_iterator whose -iterator_adaptor subobject is constructed from y.base().
-
-
-
-

Reverse iterator

- -

The reverse iterator adaptor flips the direction of a base iterator's -motion. Invoking operator++() moves the base iterator backward and -invoking operator--() moves the base iterator forward.

-
-

Class template reverse_iterator

-
-template <class Iterator>
-class reverse_iterator :
-  public iterator_adaptor< reverse_iterator<Iterator>, Iterator >
-{
-  friend class iterator_core_access;
-public:
-  reverse_iterator() {}
-  explicit reverse_iterator(Iterator x) ;
-
-  template<class OtherIterator>
-  reverse_iterator(
-      reverse_iterator<OtherIterator> const& r
-    , typename enable_if_convertible<OtherIterator, Iterator>::type* = 0 // exposition
-  );
-
-private: // as-if specification
-  typename reverse_iterator::reference dereference() const { return *prior(this->base()); }
-
-  void increment() { --this->base_reference(); }
-  void decrement() { ++this->base_reference(); }
-
-  void advance(typename reverse_iterator::difference_type n)
-  {
-      this->base_reference() += -n;
-  }
-
-  template <class OtherIterator>
-  typename reverse_iterator::difference_type
-  distance_to(reverse_iterator<OtherIterator> const& y) const
-  {
-      return this->base_reference() - y.base();
-  }
-
-};
-
-
-
-

reverse_iterator requirements

-

The base Iterator must be a model of Bidirectional Traversal -Iterator. The resulting reverse_iterator will be a model of the -most refined standard traversal and access concepts that are modeled -by Iterator.

-

reverse_iterator();

- --- - - - - - -
Requires:Iterator must be Default Constructible.
Returns:An instance of reverse_iterator with a -default constructed base object.
-

explicit reverse_iterator(Iterator x);

- --- - - - -
Returns:An instance of reverse_iterator with a -base object copy constructed from x.
-
-template<class OtherIterator>
-reverse_iterator(
-    reverse_iterator<OtherIterator> const& r
-  , typename enable_if_convertible<OtherIterator, Iterator>::type* = 0 // exposition
-);
-
- --- - - - - - -
Requires:OtherIterator is implicitly convertible to Iterator.
Returns:An instance of reverse_iterator that is a copy of r.
-
-
-
-

Transform iterator

-

The transform iterator adapts an iterator by applying some function -object to the result of dereferencing the iterator. In other words, -the operator* of the transform iterator first dereferences the -base iterator, passes the result of this to the function object, and -then returns the result.

-
-

Class template transform_iterator

- -
-template <class UnaryFunction,
-          class Iterator, 
-          class Reference = use_default, 
-          class Value = use_default>
-class transform_iterator
-  : public iterator_adaptor</* see discussion */>
-{
-  friend class iterator_core_access;
-public:
-  transform_iterator();
-  transform_iterator(Iterator const& x, UnaryFunction f);
-
-  template<class F2, class I2, class R2, class V2>
-  transform_iterator(
-        transform_iterator<F2, I2, R2, V2> const& t
-      , typename enable_if_convertible<I2, Iterator>::type* = 0      // exposition
-      , typename enable_if_convertible<F2, UnaryFunction>::type* = 0 // exposition
-  );
-
-  UnaryFunction functor() const;
-private:
-  typename transform_iterator::value_type dereference() const;
-  UnaryFunction m_f;
-};
-
-
-
-

transform_iterator requirements

-

The type UnaryFunction must be Assignable, Copy Constructible, and -the expression f(*i) must be valid where f is an object of -type UnaryFunction, i is an object of type Iterator, and -where the type of f(*i) must be -result_of<UnaryFunction(iterator_traits<Iterator>::reference)>::type.

-

The type Iterator must at least model Readable Iterator. The -resulting transform_iterator models the most refined of the -following options that is also modeled by Iterator.

-
-
    -
  • Writable Lvalue Iterator if result_of<UnaryFunction(iterator_traits<Iterator>::reference)>::type is a non-const reference.
  • -
  • Readable Lvalue Iterator if result_of<UnaryFunction(iterator_traits<Iterator>::reference)>::type is a const -reference.
  • -
  • Readable Iterator otherwise.
  • -
-
-

The transform_iterator models the most refined standard traversal -concept that is modeled by Iterator.

-

The reference type of transform_iterator is -result_of<UnaryFunction(iterator_traits<Iterator>::reference)>::type. -The value_type is remove_cv<remove_reference<reference> >::type.

-
-
-

transform_iterator public operations

-

transform_iterator();

- --- - - - -
Returns:An instance of transform_iterator with m_f -and m_iterator default constructed.
-

transform_iterator(Iterator const& x, UnaryFunction f);

- --- - - - -
Returns:An instance of transform_iterator with m_f -initialized to f and m_iterator initialized to x.
-
-template<class OtherIterator, class R2, class V2>
-transform_iterator(
-      transform_iterator<UnaryFunction, OtherIterator, R2, V2> const& t
-    , typename enable_if_convertible<OtherIterator, Iterator>::type* = 0 // exposition
-);
-
- --- - - - - - -
Returns:An instance of transform_iterator that is a copy of t.
Requires:OtherIterator is implicitly convertible to Iterator.
-

UnaryFunction functor() const;

- --- - - - -
Returns:m_f
-
-
-

transform_iterator private operations

-

typename transform_iterator::value_type dereference() const;

- --- - - - -
Returns:m_f(transform_iterator::dereference());
-
-
-
-

Filter iterator

-

The filter iterator adaptor creates a view of an iterator range in -which some elements of the range are skipped over. A predicate -function object controls which elements are skipped. When the -predicate is applied to an element, if it returns true then the -element is retained and if it returns false then the element is -skipped over. When skipping over elements, it is necessary for the -filter adaptor to know when to stop so as to avoid going past the end -of the underlying range. Therefore the constructor of the filter -iterator takes two iterator parameters: the position for the filtered -iterator and the end of the range.

-
-

Class template filter_iterator

-
-template <class Predicate, class Iterator>
-class filter_iterator
-    : public iterator_adaptor<
-          filter_iterator<Predicate, Iterator>, Iterator
-        , use_default
-        , /* see details */
-      >
-{
- public:
-    filter_iterator();
-    filter_iterator(Predicate f, Iterator x, Iterator end = Iterator());
-    filter_iterator(Iterator x, Iterator end = Iterator());
-    template<class OtherIterator>
-    filter_iterator(
-        filter_iterator<Predicate, OtherIterator> const& t
-        , typename enable_if_convertible<OtherIterator, Iterator>::type* = 0 // exposition
-        );
-    Predicate predicate() const;
-    Iterator end() const;
-
- private: // as-if specification
-    void increment()
-    {
-        ++(this->base_reference());
-        satisfy_predicate();
-    }
-
-    void satisfy_predicate()
-    {
-        while (this->base() != this->m_end && !this->m_predicate(*this->base()))
-            ++(this->base_reference());
-    }
-
-    Predicate m_predicate;
-    Iterator m_end;
-};
-
-
-
-
-

filter_iterator requirements

-

The base Iterator parameter must be a model of Readable -Iterator and Single Pass Iterator. The resulting -filter_iterator will be a model of Forward Traversal Iterator -if Iterator is, otherwise the filter_iterator will be a -model of Single Pass Iterator. The access category of the -filter_iterator will be the same as the access category of -Iterator.

- -

The Predicate must be Assignable, Copy Constructible, and the -expression p(x) must be valid where p is an object of type -Predicate, x is an object of type -iterator_traits<Iterator>::value_type, and where the type of -p(x) must be convertible to bool.

-
-
-

filter_iterator operations

-

filter_iterator();

- --- - - - - - -
Requires:Predicate and Iterator must be Default Constructible.
Returns:a filter_iterator whose -predicate is a default constructed Predicate and -whose end is a default constructed Iterator.
-

filter_iterator(Predicate f, Iterator x, Iterator end = Iterator());

- --- - - - -
Returns:A filter_iterator at position x that filters according -to predicate f and that will not increment past end.
-

filter_iterator(Iterator x, Iterator end = Iterator());

- --- - - - - - -
Requires:Predicate must be Default Constructible.
Returns:A filter_iterator at position x that filters -according to a default constructed Predicate -and that will not increment past end.
-
-template <class OtherIterator>
-filter_iterator(
-    filter_iterator<Predicate, OtherIterator> const& t
-    , typename enable_if_convertible<OtherIterator, Iterator>::type* = 0 // exposition
-    );``
-
- --- - - - - - -
Requires:OtherIterator is implicitly convertible to Iterator.
Returns:A copy of iterator t.
-

Predicate predicate() const;

- --- - - - -
Returns:A copy of the predicate object used to construct *this.
-

Iterator end() const;

- --- - - - -
Returns:The object end used to construct *this.
-
-
-

Counting iterator

-

The counting iterator adaptor implements dereference by returning a -reference to the base object. The other operations are implemented by -the base m_iterator, as per the inheritance from -iterator_adaptor.

-
-

Class template counting_iterator

-
-template <
-    class Incrementable
-  , unsigned Access = use_default_access
-  , class Traversal = use_default
-  , class Difference = use_default
->
-class counting_iterator
-  : public iterator_adaptor<
-        counting_iterator<Incrementable, Access, Traversal, Difference>
-      , Incrementable
-      , Incrementable
-      , Access
-      , /* see details for traversal category */
-      , Incrementable const&
-      , Incrementable const*
-      , /* distance = Difference or a signed integral type */>
-{
-    friend class iterator_core_access;
- public:
-    counting_iterator();
-    counting_iterator(counting_iterator const& rhs);
-    counting_iterator(Incrementable x);
- private:
-    typename counting_iterator::reference dereference() const
-    {
-        return this->base_reference();
-    }
-  };
-
-
-
[Note: implementers are encouraged to provide an implementation of
-
distance_to and a difference_type that avoids overflows in -the cases when the Incrementable type is a numeric type.]
-
-
-
-
-

counting_iterator requirements

-

The Incrementable type must be Default Constructible, Copy -Constructible, and Assignable. The default distance is -an implementation defined signed integegral type.

-

The resulting counting_iterator models Readable Lvalue Iterator.

-

Furthermore, if you wish to create a counting iterator that is a Forward -Traversal Iterator, then the following expressions must be valid:

-
-Incrementable i, j;
-++i         // pre-increment
-i == j      // operator equal
-
-

If you wish to create a counting iterator that is a -Bidirectional Traversal Iterator, then pre-decrement is also required:

-
---i
-
-

If you wish to create a counting iterator that is a Random Access -Traversal Iterator, then these additional expressions are also -required:

-
-counting_iterator::difference_type n;
-i += n
-n = i - j
-i < j
-
-
-
-

counting_iterator operations

-

counting_iterator();

- --- - - - -
Returns:A default constructed instance of counting_iterator.
-

counting_iterator(counting_iterator const& rhs);

- --- - - - -
Returns:An instance of counting_iterator that is a copy of rhs.
-

counting_iterator(Incrementable x);

- --- - - - -
Returns:An instance of counting_iterator with its base -object copy constructed from x.
-
-
-

Function output iterator

-

The function output iterator adaptor makes it easier to create custom -output iterators. The adaptor takes a unary function and creates a -model of Output Iterator. Each item assigned to the output iterator is -passed as an argument to the unary function. The motivation for this -iterator is that creating a conforming output iterator is non-trivial, -particularly because the proper implementation usually requires a -proxy object.

-
-

Class template function_output_iterator

-
-template <class UnaryFunction>
-class function_output_iterator {
-public:
-  typedef iterator_tag<
-        writable_iterator
-      , incrementable_traversal_tag
-  > iterator_category;
-  typedef void                value_type;
-  typedef void                difference_type;
-  typedef void                pointer;
-  typedef void                reference;
-
-  explicit function_output_iterator(const UnaryFunction& f = UnaryFunction());
-
-  struct output_proxy {
-    output_proxy(UnaryFunction& f);
-    template <class T> output_proxy& operator=(const T& value);
-  };
-  output_proxy operator*();
-  function_output_iterator& operator++();
-  function_output_iterator& operator++(int);
-};
-
-
-
-
-

function_output_iterator requirements

-

The UnaryFunction must be Assignable, Copy Constructible, and the -expression f(x) must be valid, where f is an object of type -UnaryFunction and x is an object of a type accepted by f. -The resulting function_output_iterator is a model of the Writable -and Incrementable Iterator concepts.

-
-
-

function_output_iterator operations

-

explicit function_output_iterator(const UnaryFunction& f = UnaryFunction());

- --- - - - -
Returns:An instance of function_output_iterator with -f stored as a data member.
-

output_proxy operator*();

- --- - - - -
Returns:An instance of output_proxy constructed with -a copy of the unary function f.
-

function_output_iterator& operator++();

- --- - - - -
Returns:*this
-

function_output_iterator& operator++(int);

- --- - - - -
Returns:*this
-
-
-

function_output_iterator::output_proxy operations

-

output_proxy(UnaryFunction& f);

- --- - - - -
Returns:An instance of output_proxy with f stored as -a data member.
-

template <class T> output_proxy& operator=(const T& value);

- --- - - - -
Effects:
-m_f(value); 
-return *this; 
-
-
- -
-
-
-
- - - - diff --git a/doc/facade-and-adaptor.rst b/doc/facade-and-adaptor.rst deleted file mode 100644 index 17174a9..0000000 --- a/doc/facade-and-adaptor.rst +++ /dev/null @@ -1,423 +0,0 @@ -+++++++++++++++++++++++++++++ - Iterator Facade and Adaptor -+++++++++++++++++++++++++++++ - -:Author: David Abrahams, Jeremy Siek, Thomas Witt -:Contact: dave@boost-consulting.com, jsiek@osl.iu.edu, witt@acm.org -:organization: `Boost Consulting`_, Indiana University `Open Systems - Lab`_, University of Hanover `Institute for Transport - Railway Operation and Construction`_ -:date: $Date$ - -:Number: This is a revised version of N1530_\ =03-0113, which was - accepted for Technical Report 1 by the C++ standard - committee's library working group. - -.. Version 1.9 of this ReStructuredText document corresponds to - n1530_, the paper accepted by the LWG. - -.. _n1530: http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1530.html - -:copyright: Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved - -.. _`Boost Consulting`: http://www.boost-consulting.com -.. _`Open Systems Lab`: http://www.osl.iu.edu -.. _`Institute for Transport Railway Operation and Construction`: http://www.ive.uni-hannover.de - -:abstract: We propose a set of class templates that help programmers - build standard-conforming iterators, both from scratch and - by adapting other iterators. - -.. contents:: Table of Contents - -============ - Motivation -============ - -Iterators play an important role in modern C++ programming. The -iterator is the central abstraction of the algorithms of the Standard -Library, allowing algorithms to be re-used in in a wide variety of -contexts. The C++ Standard Library contains a wide variety of useful -iterators. Every one of the standard containers comes with constant -and mutable iterators [#mutable]_, and also reverse versions of those -same iterators which traverse the container in the opposite direction. -The Standard also supplies ``istream_iterator`` and -``ostream_iterator`` for reading from and writing to streams, -``insert_iterator``, ``front_insert_iterator`` and -``back_insert_iterator`` for inserting elements into containers, and -``raw_storage_iterator`` for initializing raw memory [7]. - -Despite the many iterators supplied by the Standard Library, obvious -and useful iterators are missing, and creating new iterator types is -still a common task for C++ programmers. The literature documents -several of these, for example line_iterator [3] and Constant_iterator -[9]. The iterator abstraction is so powerful that we expect -programmers will always need to invent new iterator types. - -Although it is easy to create iterators that *almost* conform to the -standard, the iterator requirements contain subtleties which can make -creating an iterator which *actually* conforms quite difficult. -Further, the iterator interface is rich, containing many operators -that are technically redundant and tedious to implement. To automate -the repetitive work of constructing iterators, we propose -``iterator_facade``, an iterator base class template which provides -the rich interface of standard iterators and delegates its -implementation to member functions of the derived class. In addition -to reducing the amount of code necessary to create an iterator, the -``iterator_facade`` also provides compile-time error detection. -Iterator implementation mistakes that often go unnoticed are turned -into compile-time errors because the derived class implementation must -match the expectations of the ``iterator_facade``. - -A common pattern of iterator construction is the adaptation of one -iterator to form a new one. The functionality of an iterator is -composed of four orthogonal aspects: traversal, indirection, equality -comparison and distance measurement. Adapting an old iterator to -create a new one often saves work because one can reuse one aspect of -functionality while redefining the other. For example, the Standard -provides ``reverse_iterator``, which adapts any Bidirectional Iterator -by inverting its direction of traversal. As with plain iterators, -iterator adaptors defined outside the Standard have become commonplace -in the literature: - -* Checked iter[13] adds bounds-checking to an existing iterator. - -* The iterators of the View Template Library[14], which adapts - containers, are themselves adaptors over the underlying iterators. - -* Smart iterators [5] adapt an iterator's dereferencing behavior by - applying a function object to the object being referenced and - returning the result. - -* Custom iterators [4], in which a variety of adaptor types are enumerated. - -* Compound iterators [1], which access a slice out of a container of containers. - -* Several iterator adaptors from the MTL [12]. The MTL contains a - strided iterator, where each call to ``operator++()`` moves the - iterator ahead by some constant factor, and a scaled iterator, which - multiplies the dereferenced value by some constant. - -.. [#concept] We use the term concept to mean a set of requirements - that a type must satisfy to be used with a particular template - parameter. - -.. [#mutable] The term mutable iterator refers to iterators over objects that - can be changed by assigning to the dereferenced iterator, while - constant iterator refers to iterators over objects that cannot be - modified. - -To fulfill the need for constructing adaptors, we propose the -``iterator_adaptor`` class template. Instantiations of -``iterator_adaptor`` serve as a base classes for new iterators, -providing the default behavior of forwarding all operations to the -underlying iterator. The user can selectively replace these features -in the derived iterator class. This proposal also includes a number -of more specialized adaptors, such as the ``transform_iterator`` that -applies some user-specified function during the dereference of the -iterator. - -======================== - Impact on the Standard -======================== - -This proposal is purely an addition to the C++ standard library. -However, note that this proposal relies on the proposal for New -Iterator Concepts. - -======== - Design -======== - -Iterator Concepts -================= - -This proposal is formulated in terms of the new ``iterator concepts`` -as proposed in n1550_, since user-defined and especially adapted -iterators suffer from the well known categorization problems that are -inherent to the current iterator categories. - -.. _n1550: http://anubis.dkuug.dk/JTC1/SC22/WG21/docs/papers/2003/n1550.html - -This proposal does not strictly depend on proposal n1550_, as there -is a direct mapping between new and old categories. This proposal -could be reformulated using this mapping if n1550_ was not accepted. - -Interoperability -================ - -The question of iterator interoperability is poorly addressed in the -current standard. There are currently two defect reports that are -concerned with interoperability issues. - -Issue 179_ concerns the fact that mutable container iterator types -are only required to be convertible to the corresponding constant -iterator types, but objects of these types are not required to -interoperate in comparison or subtraction expressions. This situation -is tedious in practice and out of line with the way built in types -work. This proposal implements the proposed resolution to issue -179_, as most standard library implementations do nowadays. In other -words, if an iterator type A has an implicit or user defined -conversion to an iterator type B, the iterator types are interoperable -and the usual set of operators are available. - -Issue 280_ concerns the current lack of interoperability between -reverse iterator types. The proposed new reverse_iterator template -fixes the issues raised in 280. It provides the desired -interoperability without introducing unwanted overloads. - -.. _179: http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-defects.html#179 -.. _280: http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-active.html#280 - - -Iterator Facade -=============== - -.. include:: iterator_facade_body.rst - -Iterator Adaptor -================ - -.. include:: iterator_adaptor_body.rst - -Specialized Adaptors -==================== - -This proposal also contains several examples of specialized adaptors -which were easily implemented using ``iterator_adaptor``: - -* ``indirect_iterator``, which iterates over iterators, pointers, - or smart pointers and applies an extra level of dereferencing. - -* A new ``reverse_iterator``, which inverts the direction of a Base - iterator's motion, while allowing adapted constant and mutable - iterators to interact in the expected ways (unlike those in most - implementations of C++98). - -* ``transform_iterator``, which applies a user-defined function object - to the underlying values when dereferenced. - -* ``projection_iterator``, which is similar to ``transform_iterator`` - except that when dereferenced it returns a reference instead of - a value. - -* ``filter_iterator``, which provides a view of an iterator range in - which some elements of the underlying range are skipped. - -.. _counting: - -* ``counting_iterator``, which adapts any incrementable type - (e.g. integers, iterators) so that incrementing/decrementing the - adapted iterator and dereferencing it produces successive values of - the Base type. - -* ``function_output_iterator``, which makes it easier to create custom - output iterators. - -Based on examples in the Boost library, users have generated many new -adaptors, among them a permutation adaptor which applies some -permutation to a random access iterator, and a strided adaptor, which -adapts a random access iterator by multiplying its unit of motion by a -constant factor. In addition, the Boost Graph Library (BGL) uses -iterator adaptors to adapt other graph libraries, such as LEDA [10] -and Stanford GraphBase [8], to the BGL interface (which requires C++ -Standard compliant iterators). - -=============== - Proposed Text -=============== - - -Header ```` synopsis [lib.iterator.helper.synopsis] -======================================================================= - - -:: - - struct use_default; - - struct iterator_core_access { /* implementation detail */ }; - - template < - class Derived - , class Value - , class CategoryOrTraversal - , class Reference = Value& - , class Difference = ptrdiff_t - > - class iterator_facade; - - template < - class Derived - , class Base - , class Value = use_default - , class CategoryOrTraversal = use_default - , class Reference = use_default - , class Difference = use_default - > - class iterator_adaptor; - - template < - class Iterator - , class Value = use_default - , class CategoryOrTraversal = use_default - , class Reference = use_default - , class Difference = use_default - > - class indirect_iterator; - - template - class reverse_iterator; - - template < - class UnaryFunction - , class Iterator - , class Reference = use_default - , class Value = use_default - > - class transform_iterator; - - template - class filter_iterator; - - template < - class Incrementable - , class CategoryOrTraversal = use_default - , class Difference = use_default - > - class counting_iterator - - template - class function_output_iterator; - - - -Iterator facade [lib.iterator.facade] -===================================== - -.. include:: iterator_facade_abstract.rst - -Class template ``iterator_facade`` ----------------------------------- - -.. include:: iterator_facade_ref.rst - -Iterator adaptor [lib.iterator.adaptor] -======================================= - -.. include:: iterator_adaptor_abstract.rst - -Class template ``iterator_adaptor`` ------------------------------------ - -.. include:: iterator_adaptor_ref.rst - - -Specialized adaptors [lib.iterator.special.adaptors] -==================================================== - - -The ``enable_if_convertible::type`` expression used in -this section is for exposition purposes. The converting constructors -for specialized adaptors should be only be in an overload set provided -that an object of type ``X`` is implicitly convertible to an object of -type ``Y``. -The signatures involving ``enable_if_convertible`` should behave -*as-if* ``enable_if_convertible`` were defined to be:: - - template enable_if_convertible_impl - {}; - - template <> enable_if_convertible_impl - { struct type; }; - - template - struct enable_if_convertible - : enable_if_convertible_impl::value> - {}; - -If an expression other than the default argument is used to supply -the value of a function parameter whose type is written in terms -of ``enable_if_convertible``, the program is ill-formed, no -diagnostic required. - -[*Note:* The ``enable_if_convertible`` approach uses SFINAE to -take the constructor out of the overload set when the types are not -implicitly convertible. -] - - -Indirect iterator ------------------ - -.. include:: indirect_iterator_abstract.rst - -Class template ``indirect_iterator`` -.................................... - -.. include:: indirect_iterator_ref.rst - -Reverse iterator ----------------- - -.. include:: reverse_iterator_abstract.rst - -Class template ``reverse_iterator`` -................................... - -.. include:: reverse_iterator_ref.rst - - -Transform iterator ------------------- - -.. include:: transform_iterator_abstract.rst - -Class template ``transform_iterator`` -..................................... - -.. include:: transform_iterator_ref.rst - - -Filter iterator ---------------- - -.. include:: filter_iterator_abstract.rst - - -Class template ``filter_iterator`` -.................................. - -.. include:: filter_iterator_ref.rst - - -Counting iterator ------------------ - -.. include:: counting_iterator_abstract.rst - -Class template ``counting_iterator`` -.................................... - -.. include:: counting_iterator_ref.rst - - -Function output iterator ------------------------- - -.. include:: function_output_iterator_abstract.rst - -Class template ``function_output_iterator`` -........................................... - -.. include:: function_output_iterator_ref.rst - - - - -.. LocalWords: Abrahams Siek Witt istream ostream iter MTL strided interoperate - LocalWords: CRTP metafunctions inlining lvalue JGS incrementable BGL LEDA cv - LocalWords: GraphBase struct ptrdiff UnaryFunction const int typename bool pp - LocalWords: lhs rhs SFINAE markup iff tmp OtherDerived OtherIterator DWA foo - LocalWords: dereferenceable subobject AdaptableUnaryFunction impl pre ifdef'd - LocalWords: OtherIncrementable Coplien diff --git a/doc/filter_iterator.html b/doc/filter_iterator.html deleted file mode 100644 index 2c3180f..0000000 --- a/doc/filter_iterator.html +++ /dev/null @@ -1,388 +0,0 @@ - - - - - - -Filter Iterator - - - - - - - -
-

Filter Iterator

- --- - - - - - - - - - - - -
Author:David Abrahams, Jeremy Siek, Thomas Witt
Contact:dave@boost-consulting.com, jsiek@osl.iu.edu, witt@ive.uni-hannover.de
Organization:Boost Consulting, Indiana University Open Systems -Lab, University of Hanover Institute for Transport -Railway Operation and Construction
Date:2003-09-14
Copyright:Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved
- --- - - - -
abstract:
-

The filter iterator adaptor creates a view of an iterator range in -which some elements of the range are skipped over. A predicate -function object controls which elements are skipped. When the -predicate is applied to an element, if it returns true then the -element is retained and if it returns false then the element is -skipped over. When skipping over elements, it is necessary for the -filter adaptor to know when to stop so as to avoid going past the end -of the underlying range. Therefore the constructor of the filter -iterator takes two iterator parameters: the position for the filtered -iterator and the end of the range.

- -
-template <class Predicate, class Iterator>
-class filter_iterator
-    : public iterator_adaptor<
-          filter_iterator<Predicate, Iterator>, Iterator
-        , use_default
-        , /* see details */
-      >
-{
- public:
-    filter_iterator();
-    filter_iterator(Predicate f, Iterator x, Iterator end = Iterator());
-    filter_iterator(Iterator x, Iterator end = Iterator());
-    template<class OtherIterator>
-    filter_iterator(
-        filter_iterator<Predicate, OtherIterator> const& t
-        , typename enable_if_convertible<OtherIterator, Iterator>::type* = 0 // exposition
-        );
-    Predicate predicate() const;
-    Iterator end() const;
-
- private: // as-if specification
-    void increment()
-    {
-        ++(this->base_reference());
-        satisfy_predicate();
-    }
-
-    void satisfy_predicate()
-    {
-        while (this->base() != this->m_end && !this->m_predicate(*this->base()))
-            ++(this->base_reference());
-    }
-
-    Predicate m_predicate;
-    Iterator m_end;
-};
-
-
-

filter_iterator requirements

-

The base Iterator parameter must be a model of Readable -Iterator and Single Pass Iterator. The resulting -filter_iterator will be a model of Forward Traversal Iterator -if Iterator is, otherwise the filter_iterator will be a -model of Single Pass Iterator. The access category of the -filter_iterator will be the same as the access category of -Iterator.

- -

The Predicate must be Assignable, Copy Constructible, and the -expression p(x) must be valid where p is an object of type -Predicate, x is an object of type -iterator_traits<Iterator>::value_type, and where the type of -p(x) must be convertible to bool.

-
-
-

filter_iterator operations

-

filter_iterator();

- --- - - - - - -
Requires:Predicate and Iterator must be Default Constructible.
Returns:a filter_iterator whose -predicate is a default constructed Predicate and -whose end is a default constructed Iterator.
-

filter_iterator(Predicate f, Iterator x, Iterator end = Iterator());

- --- - - - -
Returns:A filter_iterator at position x that filters according -to predicate f and that will not increment past end.
-

filter_iterator(Iterator x, Iterator end = Iterator());

- --- - - - - - -
Requires:Predicate must be Default Constructible.
Returns:A filter_iterator at position x that filters -according to a default constructed Predicate -and that will not increment past end.
-
-template <class OtherIterator>
-filter_iterator(
-    filter_iterator<Predicate, OtherIterator> const& t
-    , typename enable_if_convertible<OtherIterator, Iterator>::type* = 0 // exposition
-    );``
-
- --- - - - - - -
Requires:OtherIterator is implicitly convertible to Iterator.
Returns:A copy of iterator t.
-

Predicate predicate() const;

- --- - - - -
Returns:A copy of the predicate object used to construct *this.
-

Iterator end() const;

- --- - - - -
Returns:The object end used to construct *this.
-
-
- - - - diff --git a/doc/filter_iterator.rst b/doc/filter_iterator.rst deleted file mode 100644 index acd770e..0000000 --- a/doc/filter_iterator.rst +++ /dev/null @@ -1,23 +0,0 @@ -+++++++++++++++++ - Filter Iterator -+++++++++++++++++ - -:Author: David Abrahams, Jeremy Siek, Thomas Witt -:Contact: dave@boost-consulting.com, jsiek@osl.iu.edu, witt@ive.uni-hannover.de -:organization: `Boost Consulting`_, Indiana University `Open Systems - Lab`_, University of Hanover `Institute for Transport - Railway Operation and Construction`_ -:date: $Date$ -:copyright: Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved - -.. _`Boost Consulting`: http://www.boost-consulting.com -.. _`Open Systems Lab`: http://www.osl.iu.edu -.. _`Institute for Transport Railway Operation and Construction`: http://www.ive.uni-hannover.de - -:abstract: - -.. include:: filter_iterator_abstract.rst - -.. contents:: Table of Contents - -.. include:: filter_iterator_ref.rst diff --git a/doc/filter_iterator_abstract.rst b/doc/filter_iterator_abstract.rst deleted file mode 100644 index 9517b23..0000000 --- a/doc/filter_iterator_abstract.rst +++ /dev/null @@ -1,10 +0,0 @@ -The filter iterator adaptor creates a view of an iterator range in -which some elements of the range are skipped over. A predicate -function object controls which elements are skipped. When the -predicate is applied to an element, if it returns ``true`` then the -element is retained and if it returns ``false`` then the element is -skipped over. When skipping over elements, it is necessary for the -filter adaptor to know when to stop so as to avoid going past the end -of the underlying range. Therefore the constructor of the filter -iterator takes two iterator parameters: the position for the filtered -iterator and the end of the range. diff --git a/doc/filter_iterator_ref.rst b/doc/filter_iterator_ref.rst deleted file mode 100644 index 239d2f8..0000000 --- a/doc/filter_iterator_ref.rst +++ /dev/null @@ -1,109 +0,0 @@ -:: - - template - class filter_iterator - : public iterator_adaptor< - filter_iterator, Iterator - , use_default - , /* see details */ - > - { - public: - filter_iterator(); - filter_iterator(Predicate f, Iterator x, Iterator end = Iterator()); - filter_iterator(Iterator x, Iterator end = Iterator()); - template - filter_iterator( - filter_iterator const& t - , typename enable_if_convertible::type* = 0 // exposition - ); - Predicate predicate() const; - Iterator end() const; - - private: // as-if specification - void increment() - { - ++(this->base_reference()); - satisfy_predicate(); - } - - void satisfy_predicate() - { - while (this->base() != this->m_end && !this->m_predicate(*this->base())) - ++(this->base_reference()); - } - - Predicate m_predicate; - Iterator m_end; - }; - - -``filter_iterator`` requirements --------------------------------- - -The base ``Iterator`` parameter must be a model of Readable -Iterator and Single Pass Iterator. The resulting -``filter_iterator`` will be a model of Forward Traversal Iterator -if ``Iterator`` is, otherwise the ``filter_iterator`` will be a -model of Single Pass Iterator. The access category of the -``filter_iterator`` will be the same as the access category of -``Iterator``. - -.. Thomas is going to try implementing filter_iterator so that - it will be bidirectional if the underlying iterator is. -JGS - - -The ``Predicate`` must be Assignable, Copy Constructible, and the -expression ``p(x)`` must be valid where ``p`` is an object of type -``Predicate``, ``x`` is an object of type -``iterator_traits::value_type``, and where the type of -``p(x)`` must be convertible to ``bool``. - - - -``filter_iterator`` operations ------------------------------- - -``filter_iterator();`` - -:Requires: ``Predicate`` and ``Iterator`` must be Default Constructible. -:Returns: a ``filter_iterator`` whose - predicate is a default constructed ``Predicate`` and - whose ``end`` is a default constructed ``Iterator``. - - -``filter_iterator(Predicate f, Iterator x, Iterator end = Iterator());`` - -:Returns: A ``filter_iterator`` at position ``x`` that filters according - to predicate ``f`` and that will not increment past ``end``. - - -``filter_iterator(Iterator x, Iterator end = Iterator());`` - -:Requires: ``Predicate`` must be Default Constructible. -:Returns: A ``filter_iterator`` at position ``x`` that filters - according to a default constructed ``Predicate`` - and that will not increment past ``end``. - - -:: - - template - filter_iterator( - filter_iterator const& t - , typename enable_if_convertible::type* = 0 // exposition - );`` - -:Requires: ``OtherIterator`` is implicitly convertible to ``Iterator``. -:Returns: A copy of iterator ``t``. - - -``Predicate predicate() const;`` - -:Returns: A copy of the predicate object used to construct ``*this``. - - -``Iterator end() const;`` - -:Returns: The object ``end`` used to construct ``*this``. - diff --git a/doc/function_output_iterator.html b/doc/function_output_iterator.html deleted file mode 100644 index 8af8f32..0000000 --- a/doc/function_output_iterator.html +++ /dev/null @@ -1,356 +0,0 @@ - - - - - - -Function Output Iterator - - - - - - - -
-

Function Output Iterator

- --- - - - - - - - - - - - -
Author:David Abrahams, Jeremy Siek, Thomas Witt
Contact:dave@boost-consulting.com, jsiek@osl.iu.edu, witt@ive.uni-hannover.de
Organization:Boost Consulting, Indiana University Open Systems -Lab, University of Hanover Institute for Transport -Railway Operation and Construction
Date:2003-09-14
Copyright:Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved
- --- - - - -
abstract:
-

The function output iterator adaptor makes it easier to create custom -output iterators. The adaptor takes a unary function and creates a -model of Output Iterator. Each item assigned to the output iterator is -passed as an argument to the unary function. The motivation for this -iterator is that creating a conforming output iterator is non-trivial, -particularly because the proper implementation usually requires a -proxy object.

- -
-template <class UnaryFunction>
-class function_output_iterator {
-public:
-  typedef iterator_tag<
-        writable_iterator
-      , incrementable_traversal_tag
-  > iterator_category;
-  typedef void                value_type;
-  typedef void                difference_type;
-  typedef void                pointer;
-  typedef void                reference;
-
-  explicit function_output_iterator(const UnaryFunction& f = UnaryFunction());
-
-  struct output_proxy {
-    output_proxy(UnaryFunction& f);
-    template <class T> output_proxy& operator=(const T& value);
-  };
-  output_proxy operator*();
-  function_output_iterator& operator++();
-  function_output_iterator& operator++(int);
-};
-
-
-

function_output_iterator requirements

-

The UnaryFunction must be Assignable, Copy Constructible, and the -expression f(x) must be valid, where f is an object of type -UnaryFunction and x is an object of a type accepted by f. -The resulting function_output_iterator is a model of the Writable -and Incrementable Iterator concepts.

-
-
-

function_output_iterator operations

-

explicit function_output_iterator(const UnaryFunction& f = UnaryFunction());

- --- - - - -
Returns:An instance of function_output_iterator with -f stored as a data member.
-

output_proxy operator*();

- --- - - - -
Returns:An instance of output_proxy constructed with -a copy of the unary function f.
-

function_output_iterator& operator++();

- --- - - - -
Returns:*this
-

function_output_iterator& operator++(int);

- --- - - - -
Returns:*this
-
-
-

function_output_iterator::output_proxy operations

-

output_proxy(UnaryFunction& f);

- --- - - - -
Returns:An instance of output_proxy with f stored as -a data member.
-

template <class T> output_proxy& operator=(const T& value);

- --- - - - -
Effects:
-m_f(value); 
-return *this; 
-
-
-
-
- - - - diff --git a/doc/function_output_iterator.rst b/doc/function_output_iterator.rst deleted file mode 100644 index d1740fb..0000000 --- a/doc/function_output_iterator.rst +++ /dev/null @@ -1,23 +0,0 @@ -++++++++++++++++++++++++++ - Function Output Iterator -++++++++++++++++++++++++++ - -:Author: David Abrahams, Jeremy Siek, Thomas Witt -:Contact: dave@boost-consulting.com, jsiek@osl.iu.edu, witt@ive.uni-hannover.de -:organization: `Boost Consulting`_, Indiana University `Open Systems - Lab`_, University of Hanover `Institute for Transport - Railway Operation and Construction`_ -:date: $Date$ -:copyright: Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved - -.. _`Boost Consulting`: http://www.boost-consulting.com -.. _`Open Systems Lab`: http://www.osl.iu.edu -.. _`Institute for Transport Railway Operation and Construction`: http://www.ive.uni-hannover.de - -:abstract: - -.. include:: function_output_iterator_abstract.rst - -.. contents:: Table of Contents - -.. include:: function_output_iterator_ref.rst diff --git a/doc/function_output_iterator_abstract.rst b/doc/function_output_iterator_abstract.rst deleted file mode 100644 index 11fb4f1..0000000 --- a/doc/function_output_iterator_abstract.rst +++ /dev/null @@ -1,8 +0,0 @@ -The function output iterator adaptor makes it easier to create custom -output iterators. The adaptor takes a unary function and creates a -model of Output Iterator. Each item assigned to the output iterator is -passed as an argument to the unary function. The motivation for this -iterator is that creating a conforming output iterator is non-trivial, -particularly because the proper implementation usually requires a -proxy object. - diff --git a/doc/function_output_iterator_ref.rst b/doc/function_output_iterator_ref.rst deleted file mode 100644 index bee8a60..0000000 --- a/doc/function_output_iterator_ref.rst +++ /dev/null @@ -1,77 +0,0 @@ -:: - - template - class function_output_iterator { - public: - typedef iterator_tag< - writable_iterator - , incrementable_traversal_tag - > iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - explicit function_output_iterator(const UnaryFunction& f = UnaryFunction()); - - struct output_proxy { - output_proxy(UnaryFunction& f); - template output_proxy& operator=(const T& value); - }; - output_proxy operator*(); - function_output_iterator& operator++(); - function_output_iterator& operator++(int); - }; - - -``function_output_iterator`` requirements ------------------------------------------ - -The ``UnaryFunction`` must be Assignable, Copy Constructible, and the -expression ``f(x)`` must be valid, where ``f`` is an object of type -``UnaryFunction`` and ``x`` is an object of a type accepted by ``f``. -The resulting ``function_output_iterator`` is a model of the Writable -and Incrementable Iterator concepts. - - -``function_output_iterator`` operations ---------------------------------------- - -``explicit function_output_iterator(const UnaryFunction& f = UnaryFunction());`` - -:Returns: An instance of ``function_output_iterator`` with - ``f`` stored as a data member. - - -``output_proxy operator*();`` - -:Returns: An instance of ``output_proxy`` constructed with - a copy of the unary function ``f``. - - -``function_output_iterator& operator++();`` - -:Returns: ``*this`` - - -``function_output_iterator& operator++(int);`` - -:Returns: ``*this`` - - -``function_output_iterator::output_proxy`` operations ------------------------------------------------------ - -``output_proxy(UnaryFunction& f);`` - -:Returns: An instance of ``output_proxy`` with ``f`` stored as - a data member. - - -``template output_proxy& operator=(const T& value);`` - -:Effects: - :: - - m_f(value); - return *this; diff --git a/doc/generate.py b/doc/generate.py deleted file mode 100644 index 86572ba..0000000 --- a/doc/generate.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/python - -# -# Generate html, TeX, and PDF versions of all the source files -# -import os -import sys - -from syscmd import syscmd -from sources import sources - -if 0: - for s in sources: - syscmd('boosthtml %s' % s) -else: - extensions = ('html', 'tex', 'pdf') - - if len(sys.argv) > 1: - extensions = sys.argv[1:] - - all = [ '%s.%s' % (os.path.splitext(s)[0],ext) - for ext in extensions - for s in sources - ] - - print 'make %s' % ' '.join(all) - syscmd('make %s' % ' '.join(all)) - - diff --git a/doc/index.html b/doc/index.html deleted file mode 100755 index d9338c3..0000000 --- a/doc/index.html +++ /dev/null @@ -1,418 +0,0 @@ - - - - - - -The Boost.Iterator Library Boost - - - - - - - - diff --git a/doc/index.rst b/doc/index.rst deleted file mode 100755 index cc230fe..0000000 --- a/doc/index.rst +++ /dev/null @@ -1,265 +0,0 @@ -+++++++++++++++++++++++++++++++++++++++++++++++++ - The Boost.Iterator Library |(logo)|__ -+++++++++++++++++++++++++++++++++++++++++++++++++ - -.. |(logo)| image:: ../../../c++boost.gif - :alt: Boost - -__ ../../../index.htm - - -------------------------------------- - - -:Authors: David Abrahams, Jeremy Siek, Thomas Witt -:Contact: dave@boost-consulting.com, jsiek@osl.iu.edu, witt@ive.uni-hannover.de -:organizations: `Boost Consulting`_, Indiana University `Open Systems - Lab`_, University of Hanover `Institute for Transport - Railway Operation and Construction`_ -:date: $Date$ -:copyright: Copyright David Abrahams, Jeremy Siek, Thomas Witt 2003. All rights reserved - -.. _`Boost Consulting`: http://www.boost-consulting.com -.. _`Open Systems Lab`: http://www.osl.iu.edu -.. _`Institute for Transport Railway Operation and Construction`: http://www.ive.uni-hannover.de - -:Abstract: The Boost Iterator Library contains two parts. The first - is a system of concepts_ which extend the C++ standard - iterator requirements. The second is a framework of - components for building iterators based on these - extended concepts and includes several useful iterator - adaptors. The extended iterator concepts have been - carefully designed so that so that old-style iterators - can fit in the new concepts and so that new-style - iterators will be compatible with old-style algorithms, - though algorithms may need to be updated if they want to - take full advantage of the new-style iterator - capabilities. Several components of this library have - been accepted into the C++ standard technical report. - The components of the Boost Iterator Library replace the - older Boost Iterator Adaptor Library. - -.. _concepts: ../../../more/generic_programming.html#concept - -.. contents:: **Table of Contents** - - -------------------------------------- - - -===================== - New-Style Iterators -===================== - -The iterator categories defined in C++98 are extremely limiting -because they bind together two orthogonal concepts: traversal and -element access. For example, because a random access iterator is -required to return a reference (and not a proxy) when dereferenced, -it is impossible to capture the capabilities of -``vector::iterator`` using the C++98 categories. This is the -infamous "``vector`` is not a container, and its iterators -aren't random access iterators", debacle about which Herb Sutter -wrote two papers for the standards comittee (n1185_ and n1211_), -and a `Guru of the Week`__. New-style iterators go well beyond -patching up ``vector``, though: there are lots of other -iterators already in use which can't be adequately represented by -the existing concepts. For details about the new iterator -concepts, see our - -.. _n1185: http://www.gotw.ca/publications/N1185.pdf -.. _n1211: http://www.gotw.ca/publications/N1211.pdf -__ http://www.gotw.ca/gotw/050.htm - - - `Standard Proposal For New-Style Iterators`__ - -__ new-iter-concepts.html - -============================= - Iterator Facade and Adaptor -============================= - -Writing standard-conforming iterators is tricky, but the need comes -up often. In order to ease the implementation of new iterators, -the Boost.Iterator library provides the |facade|_ class template, -which implements many useful defaults and compile-time checks -designed to help the author iterator ensure that his iterator is -correct. - -It is also common to define a new iterator that is similar to some -underlying iterator or iterator-like type, but that modifies some -aspect of the underlying type's behavior. For that purpose, the -library supplies the |adaptor|_ class template, which is specially -designed to take advantage of as much of the underlying type's -behavior as possible. - -.. |facade| replace:: ``iterator_facade`` -.. _facade: iterator_facade.html -.. |adaptor| replace:: ``iterator_adaptor`` -.. _adaptor: iterator_adaptor.html - -Both |facade|_ and |adaptor|_ as well as many of the `specialized -adaptors`_ mentioned below have been proposed for standardization, -and accepted into the first C++ technical report; see our - - `Standard Proposal For Iterator Facade and Adaptor`__ - -for more details. - -__ facade-and-adaptor.html - -====================== - Specialized Adaptors -====================== - -The iterator library supplies a useful suite of standard-conforming -iterator templates based on the Boost `iterator facade and adaptor`_. - -* |counting|_: an iterator over a sequence of consecutive values. - Implements a "lazy sequence" - -* |filter|_: an iterator over the subset of elements of some - sequence which satisfy a given predicate - -* |indirect|_: an iterator over the objects *pointed-to* by the - elements of some sequence. - -* |permutation|_: an iterator over the elements of some random-access - sequence, rearranged according to some sequence of integer indices. - -* |reverse|_: an iterator which traverses the elements of some - bidirectional sequence in reverse. Corrects many of the - shortcomings of C++98's ``std::reverse_iterator``. - -* |transform|_: an iterator over elements which are the result of - applying some functional transformation to the elements of an - underlying sequence. This component also replaces the old - ``projection_iterator_adaptor``. - -.. |counting| replace:: ``counting_iterator`` -.. _counting: counting_iterator.html - -.. |filter| replace:: ``filter_iterator`` -.. _filter: filter_iterator.html - -.. |indirect| replace:: ``indirect_iterator`` -.. _indirect: indirect_iterator.html - -.. |permutation| replace:: ``permutation_iterator`` -.. _permutation: permutation_iterator.html - -.. |reverse| replace:: ``reverse_iterator`` -.. _reverse: reverse_iterator.html - -.. |transform| replace:: ``transform_iterator`` -.. _transform: transform_iterator.html - -==================== - Iterator Utilities -==================== - -Traits ------- - -* |iterator_traits|_: Provides MPL_\ -compatible metafunctions which - retrieve an iterator's traits. Also corrects for the deficiencies - of broken implementations of ``std::iterator_traits``. - -* |interoperable|_: Provides an MPL_\ -compatible metafunction for - testing iterator interoperability - -.. |iterator_traits| replace:: ``iterator_traits.hpp`` -.. _iterator_traits: iterator_traits.html - -.. |interoperable| replace:: ``interoperable.hpp`` -.. _interoperable: interoperable.html - -.. _MPL: ../../mpl/doc/index.html - -Testing and Concept Checking ----------------------------- - -* |iterator_archetypes|_: Add summary here - -* |iterator_concepts|_: Add summary - -.. |iterator_archetypes| replace:: ``iterator_archetypes.hpp`` -.. _iterator_archetypes: iterator_archetypes.html - -.. |iterator_concepts| replace:: ``iterator_concepts.hpp`` -.. _iterator_concepts: iterator_concepts.html - - -======================================================= - Upgrading from the old Boost Iterator Adaptor Library -======================================================= - -.. _Upgrading: - -If you have been using the old Boost Iterator Adaptor library to -implement iterators, you probably wrote a ``Policies`` class which -captures the core operations of your iterator. In the new library -design, you'll move those same core operations into the body of the -iterator class itself. If you were writing a family of iterators, -you probably wrote a `type generator`_ to build the -``iterator_adaptor`` specialization you needed; in the new library -design you don't need a type generator (though may want to keep it -around as a compatibility aid for older code) because, due to the -use of the Curiously Recurring Template Pattern (CRTP) [Cop95]_, -you can now define the iterator class yourself and acquire -functionality through inheritance from ``iterator_facade`` or -``iterator_adaptor``. As a result, you also get much finer control -over how your iterator works: you can add additional constructors, -or even override the iterator functionality provided by the -library. - -.. _`type generator`: ../../../more/generic_programming.html#type_generator - -If you're looking for the old ``projection_iterator`` component, -its functionality has been merged into ``transform_iterator``: as -long as the function object's ``result_type`` (or the ``Reference`` -template argument, if explicitly specified) is a true reference -type, ``transform_iterator`` will behave like -``projection_iterator`` used to. - -========= - History -========= - -In 2000 Dave Abrahams was writing an iterator for a container of -pointers, which would access the pointed-to elements when -dereferenced. Naturally, being a library writer, he decided to -generalize the idea and the Boost Iterator Adaptor library was born. -Dave was inspired by some writings of Andrei Alexandrescu and chose a -policy based design (though he probably didn't capture Andrei's idea -very well - there was only one policy class for all the iterator's -orthogonal properties). Soon Jeremy Siek realized he would need the -library and they worked together to produce a "Boostified" version, -which was reviewed and accepted into the library. They wrote a paper -and made several important revisions of the code. - -Eventually, several shortcomings of the older library began to make -the need for a rewrite apparent. Dave and Jeremy started working -at the Santa Cruz C++ committee meeting in 2002, and had quickly -generated a working prototype. At the urging of Mat Marcus, they -decided to use the GenVoca/CRTP pattern approach, and moved the -policies into the iterator class itself. Thomas Witt expressed -interest and became the voice of strict compile-time checking for -the project, adding uses of the SFINAE technique to eliminate false -converting constructors and operators from the overload set. He -also recognized the need for a separate ``iterator_facade``, and -factored it out of ``iterator_adaptor``. Finally, after a -near-complete rewrite of the prototype, they came up with the -library you see today. - -.. [Cop95] [Coplien, 1995] Coplien, J., Curiously Recurring Template - Patterns, C++ Report, February 1995, pp. 24-27. - -.. - LocalWords: Abrahams Siek Witt const bool Sutter's WG int UL LI href Lvalue - LocalWords: ReadableIterator WritableIterator SwappableIterator cv pre iter - LocalWords: ConstantLvalueIterator MutableLvalueIterator CopyConstructible TR - LocalWords: ForwardTraversalIterator BidirectionalTraversalIterator lvalue - LocalWords: RandomAccessTraversalIterator dereferenceable Incrementable tmp - LocalWords: incrementable xxx min prev inplace png oldeqnew AccessTag struct - LocalWords: TraversalTag typename lvalues DWA Hmm JGS diff --git a/doc/indirect_iterator.html b/doc/indirect_iterator.html deleted file mode 100644 index f44890e..0000000 --- a/doc/indirect_iterator.html +++ /dev/null @@ -1,397 +0,0 @@ - - - - - - -Indirect Iterator - - - - - - - -
-

Indirect Iterator

- --- - - - - - - - - - - - -
Author:David Abrahams, Jeremy Siek, Thomas Witt
Contact:dave@boost-consulting.com, jsiek@osl.iu.edu, witt@ive.uni-hannover.de
Organization:Boost Consulting, Indiana University Open Systems -Lab, University of Hanover Institute for Transport -Railway Operation and Construction
Date:2003-09-14
Copyright:Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved
- --- - - - -
abstract:
-

The indirect iterator adapts an iterator by applying an extra -dereference inside of operator*(). For example, this iterator -adaptor makes it possible to view a container of pointers -(e.g. list<foo*>) as if it were a container of the pointed-to type -(e.g. list<foo>) .

- - -
-template <
-    class Iterator
-  , class Value = use_default
-  , class CategoryOrTraversal = use_default
-  , class Reference = use_default
-  , class Difference = use_default
->
-class indirect_iterator
-{
- public:
-    typedef /* see below */ value_type;
-    typedef /* see below */ reference;
-    typedef /* see below */ pointer;
-    typedef /* see below */ difference_type;
-    typedef /* see below */ iterator_category;
-
-    indirect_iterator();
-    indirect_iterator(Iterator x);
-
-    template <
-        class Iterator2, class Value2, class Category2
-      , class Reference2, class Difference2
-    >
-    indirect_iterator(
-        indirect_iterator<
-             Iterator2, Value2, Category2, Reference2, Difference2
-        > const& y
-      , typename enable_if_convertible<Iterator2, Iterator>::type* = 0 // exposition
-    );
-};
-
-

The member types of indirect_iterator are defined according to the -following pseudo-code. We use the abbreviation -V=iterator_traits<Iterator>::value_type.:

-
-if (Value is use_default) then
-    typedef iterator_traits<V>::value_type value_type;
-else
-    typedef remove_const<Value>::type value_type;
-
-if (Reference is use_default) then
-    if (Value is use_default) then
-        typedef iterator_traits<V>::reference reference;
-    else
-        typedef Value& reference;
-else
-    typedef Reference reference;
-
-if (Value is use_default) then
-    typedef ?? pointer;
-else
-    typedef Value* pointer;
-
-if (Difference is use_default)
-    typedef iterator_traits<Iterator>::difference_type difference_type;
-else
-    typedef Difference difference_type;
-
-

The member indirect_iterator::iterator_category is a type that -satisfies the requirements of the concepts modeled by the indirect -iterator as specified in the models section.

-
-

indirect_iterator requirements

-

The Iterator argument shall meet the requirements of Readable -Iterator. The CategoryOrTraversal argument shall be one of the -standard iterator tags or use_default. If CategoryOrTraversal -is an iterator tag, the template parameter Iterator argument shall -meet the traversal requirements corresponding to the iterator tag.

-

The expression *v, where v is an object of type -iterator_traits<Iterator>::value_type, must be a valid expression -and must be convertible to indirect_iterator::reference. Also -indirect_iterator::reference must be convertible to -indirect_iterator::value. There are further requirements on the -iterator_traits<Iterator>::value_type if the Value parameter -is not use_default, as implied by the algorithm for deducing the -default for the value_type member.

-
-
-

indirect_iterator models

-

If CategoryOrTraversal is a standard iterator tag, -indirect_iterator is a model of the iterator concept corresponding -to the tag, otherwise indirect_iterator satisfies the requirements -of the most refined standard traversal concept that is satisfied by -the Iterator argument.

-

indirect_iterator models Readable Iterator. If -indirect_iterator::reference(*v) = t is a valid expression (where -t is an object of type indirect_iterator::value_type) then -indirect_iterator models Writable Iterator. If -indirect_iterator::reference is a reference then -indirect_iterator models Lvalue Iterator.

-
-
-

indirect_iterator operations

-

indirect_iterator();

- --- - - - - - -
Requires:Iterator must be Default Constructible.
Returns:An instance of indirect_iterator with -a default-constructed iterator_adaptor subobject.
-

indirect_iterator(Iterator x);

- --- - - - -
Returns:An instance of indirect_iterator with -the iterator_adaptor subobject copy constructed from x.
-
-template <
-    class Iterator2, class Value2, unsigned Access, class Traversal
-  , class Reference2, class Difference2
->
-indirect_iterator(
-    indirect_iterator<
-         Iterator2, Value2, Access, Traversal, Reference2, Difference2
-    > const& y
-  , typename enable_if_convertible<Iterator2, Iterator>::type* = 0 // exposition
-);
-
- --- - - - - - -
Requires:Iterator2 is implicitly convertible to Iterator.
Returns:An instance of indirect_iterator whose -iterator_adaptor subobject is constructed from y.base().
-
-
- - - - diff --git a/doc/indirect_iterator.rst b/doc/indirect_iterator.rst deleted file mode 100644 index 3ea8dcb..0000000 --- a/doc/indirect_iterator.rst +++ /dev/null @@ -1,23 +0,0 @@ -+++++++++++++++++++ - Indirect Iterator -+++++++++++++++++++ - -:Author: David Abrahams, Jeremy Siek, Thomas Witt -:Contact: dave@boost-consulting.com, jsiek@osl.iu.edu, witt@ive.uni-hannover.de -:organization: `Boost Consulting`_, Indiana University `Open Systems - Lab`_, University of Hanover `Institute for Transport - Railway Operation and Construction`_ -:date: $Date$ -:copyright: Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved - -.. _`Boost Consulting`: http://www.boost-consulting.com -.. _`Open Systems Lab`: http://www.osl.iu.edu -.. _`Institute for Transport Railway Operation and Construction`: http://www.ive.uni-hannover.de - -:abstract: - -.. include:: indirect_iterator_abstract.rst - -.. contents:: Table of Contents - -.. include:: indirect_iterator_ref.rst diff --git a/doc/indirect_iterator_abstract.rst b/doc/indirect_iterator_abstract.rst deleted file mode 100644 index 3b6c2a6..0000000 --- a/doc/indirect_iterator_abstract.rst +++ /dev/null @@ -1,8 +0,0 @@ -The indirect iterator adapts an iterator by applying an *extra* -dereference inside of ``operator*()``. For example, this iterator -adaptor makes it possible to view a container of pointers -(e.g. ``list``) as if it were a container of the pointed-to type -(e.g. ``list``) . - -.. At some point we should add the capability to handle - iterators over smart pointers, which the impl handles. -JGS diff --git a/doc/indirect_iterator_ref.rst b/doc/indirect_iterator_ref.rst deleted file mode 100644 index 21f90d9..0000000 --- a/doc/indirect_iterator_ref.rst +++ /dev/null @@ -1,136 +0,0 @@ -:: - - template < - class Iterator - , class Value = use_default - , class CategoryOrTraversal = use_default - , class Reference = use_default - , class Difference = use_default - > - class indirect_iterator - { - public: - typedef /* see below */ value_type; - typedef /* see below */ reference; - typedef /* see below */ pointer; - typedef /* see below */ difference_type; - typedef /* see below */ iterator_category; - - indirect_iterator(); - indirect_iterator(Iterator x); - - template < - class Iterator2, class Value2, class Category2 - , class Reference2, class Difference2 - > - indirect_iterator( - indirect_iterator< - Iterator2, Value2, Category2, Reference2, Difference2 - > const& y - , typename enable_if_convertible::type* = 0 // exposition - ); - }; - - -The member types of ``indirect_iterator`` are defined according to the -following pseudo-code. We use the abbreviation -``V=iterator_traits::value_type``.:: - - if (Value is use_default) then - typedef iterator_traits::value_type value_type; - else - typedef remove_const::type value_type; - - if (Reference is use_default) then - if (Value is use_default) then - typedef iterator_traits::reference reference; - else - typedef Value& reference; - else - typedef Reference reference; - - if (Value is use_default) then - typedef ?? pointer; - else - typedef Value* pointer; - - if (Difference is use_default) - typedef iterator_traits::difference_type difference_type; - else - typedef Difference difference_type; - - -The member ``indirect_iterator::iterator_category`` is a type that -satisfies the requirements of the concepts modeled by the indirect -iterator as specified in the models section. - - -``indirect_iterator`` requirements -.................................. - -The ``Iterator`` argument shall meet the requirements of Readable -Iterator. The ``CategoryOrTraversal`` argument shall be one of the -standard iterator tags or ``use_default``. If ``CategoryOrTraversal`` -is an iterator tag, the template parameter ``Iterator`` argument shall -meet the traversal requirements corresponding to the iterator tag. - -The expression ``*v``, where ``v`` is an object of type -``iterator_traits::value_type``, must be a valid expression -and must be convertible to ``indirect_iterator::reference``. Also -``indirect_iterator::reference`` must be convertible to -``indirect_iterator::value``. There are further requirements on the -``iterator_traits::value_type`` if the ``Value`` parameter -is not ``use_default``, as implied by the algorithm for deducing the -default for the ``value_type`` member. - - -``indirect_iterator`` models -............................ - -If ``CategoryOrTraversal`` is a standard iterator tag, -``indirect_iterator`` is a model of the iterator concept corresponding -to the tag, otherwise ``indirect_iterator`` satisfies the requirements -of the most refined standard traversal concept that is satisfied by -the ``Iterator`` argument. - -``indirect_iterator`` models Readable Iterator. If -``indirect_iterator::reference(*v) = t`` is a valid expression (where -``t`` is an object of type ``indirect_iterator::value_type``) then -``indirect_iterator`` models Writable Iterator. If -``indirect_iterator::reference`` is a reference then -``indirect_iterator`` models Lvalue Iterator. - - -``indirect_iterator`` operations -................................ - -``indirect_iterator();`` - -:Requires: ``Iterator`` must be Default Constructible. -:Returns: An instance of ``indirect_iterator`` with - a default-constructed ``iterator_adaptor`` subobject. - - -``indirect_iterator(Iterator x);`` - -:Returns: An instance of ``indirect_iterator`` with - the ``iterator_adaptor`` subobject copy constructed from ``x``. - -:: - - template < - class Iterator2, class Value2, unsigned Access, class Traversal - , class Reference2, class Difference2 - > - indirect_iterator( - indirect_iterator< - Iterator2, Value2, Access, Traversal, Reference2, Difference2 - > const& y - , typename enable_if_convertible::type* = 0 // exposition - ); - -:Requires: ``Iterator2`` is implicitly convertible to ``Iterator``. -:Returns: An instance of ``indirect_iterator`` whose - ``iterator_adaptor`` subobject is constructed from ``y.base()``. - - diff --git a/doc/interoperability-revisited.rst b/doc/interoperability-revisited.rst deleted file mode 100755 index 6754b9c..0000000 --- a/doc/interoperability-revisited.rst +++ /dev/null @@ -1,232 +0,0 @@ -++++++++++++++++++++++++++++ - Interoperability Revisited -++++++++++++++++++++++++++++ - -:date: $Date$ -:copyright: Copyright Thomas Witt 2004. - - -Problem -======= - -The current iterator_facade specification makes it unneccessarily tedious to -implement interoperable iterators. - -In the following text a simplified example of the current iterator_facade specification is used to -illustrate the problem. - -In the current specification binary operators are implemented in the following way: - -template -struct Facade -{ -}; - -template -struct is_interoperable : - or_< - is_convertible - , is_convertible - > -{}; - -template< - class Derived1 - , class Derived2 -> -enable_if, bool> operator==( - Derived1 const& lhs - , Derived2 const& rhs -) -{ - return static_cast(lhs).equal_to(static_cast -{ - bool equal_to(Mutable const&); -}; - -struct Constant : Facade -{ - Constant(); - Constant(Constant const&); - Constant(Mutable const&); - - ... - - bool equal_to(Constant const&); -}; - -Constant c; -Mutable m; - -c == m; // ok, dispatched to Constant::equal_to -m == c; // !! error, dispatched to Mutable::equal_to - -Instead the following "slightly" more complicated implementation is neccessary - -struct Mutable : Facade -{ - template - enable_if || is_convertible, bool>::type equal_to(T const&); -}; - -struct Constant : Tag -{ - Constant(); - Constant(Constant const&); - Constant(Mutable const&); - - template - enable_if || is_convertible, bool>::type equal_to(T const&); -}; - -Beside the fact that the code is significantly more complex to understand and to teach there is -a major design problem lurking here. Note that in both types equal_to is a function template with -an unconstrained argument T. This is neccessary so that further types can be made interoperable with -Mutable or Constant. Would Mutable be defined as - -struct Mutable : Facade -{ - bool equal_to(Mutable const&); - bool equal_to(Constant const&); -}; - -Constant and Mutable would still be interoperable but no further interoperable could be added -without changing Mutable. Even if this would be considered acceptable the current specification forces -a two way dependency between interoperable types. Note in the templated equal_to case this dependency -is implicitly created when specializing equal_to. - -Solution -======== - -The two way dependency can be avoided by enabling type conversion in the binary operator -implementation. Note that this is the usual way interoperability betwween types is achieved -for binary operators and one reason why binary operators are usually implemented as non-members. - -A simple implementation of this strategy would look like this - -template< - class T1 - , class T2 -> -struct interoperable_base : - if_< - is_convertible< - T2 - , T1 - > - , T1 - , T2> -{}; - - -template< - class Derived1 - , class Derived2 -> -enable_if, bool> operator==( - Derived1 const& lhs - , Derived2 const& rhs -) -{ - typedef interoperable_base< - Derived1 - , Derived2 - >::type Base; - - return static_cast(lhs).equal_to(static_cast -enable_if, bool> operator==( - Derived1 const& lhs - , Derived2 const& rhs -) -{ - return static_cast(lhs).equal_to(static_cast -enable_if, bool> operator==( - Derived1 const& lhs - , Derived2 const& rhs -) -{ - return static_cast(rhs).equal_to(static_cast -{ - Constant(); - Constant(Constant const&); - Constant(Mutable const&); - - ... - - bool equal_to(Constant const&); - bool equal_to(Mutable const&); -}; - -c == m; // ok, dispatched to Constant::equal_to(Mutable const&), no conversion -m == c; // ok, dispatched to Constant::equal_to(Mutable const&), no conversion - -This definition of operator== introduces a possible ambiguity when both types are convertible -to each other. I don't think this is a problem as this behaviour is the same with concrete types. -I.e. - -struct A {}; - -bool operator==(A, A); - -struct B { B(A); }; - -bool operator==(B, B); - -A a; -B b(a); - -a == b; // error, ambiguous overload - -Effect -====== - -Iterator implementations using iterator_facade look exactly as if they were -"hand-implemented" (I am working on better wording). - -a) Less burden for the user - -b) The definition (standardese) of specialized adpters might be easier - (This has to be proved yet) \ No newline at end of file diff --git a/doc/issues.html b/doc/issues.html deleted file mode 100755 index 8087b45..0000000 --- a/doc/issues.html +++ /dev/null @@ -1,165 +0,0 @@ - - - - - - -Problem with is_writable and is_swappable in N1550 - - - -
-

Problem with is_writable and is_swappable in N1550

- --- - - - - - - - - - - - -
Author:David Abrahams and Jeremy Siek
Contact:dave@boost-consulting.com, jsiek@osl.iu.edu
Organization:Boost Consulting, Indiana University Bloomington
date:$Date$
Copyright:Copyright David Abrahams, Jeremy Siek 2003. Use, modification and -distribution is subject to the Boost Software License, -Version 1.0. (See accompanying file LICENSE_1_0.txt or copy -at http://www.boost.org/LICENSE_1_0.txt)
- -
-

Introduction

-

The is_writable and is_swappable traits classes in N1550 -provide a mechanism for determining at compile time if an iterator -type is a model of the new Writable Iterator and Swappable Iterator -concepts, analogous to iterator_traits<X>::iterator_category -for the old iterator concepts. For backward compatibility, -is_writable and is_swappable not only work with new -iterators, but they also are intended to work for old -iterators (iterators that meet the requirements for one of the -iterator concepts in the current standard). In the case of old -iterators, the writability and swapability is deduced based on the -iterator_category and also the reference type. The -specification for this deduction gives false positives for forward -iterators that have non-assignable value types.

-

To review, the part of the is_writable trait definition which -applies to old iterators is:

-
-if (cat is convertible to output_iterator_tag)
-    return true;
-else if (cat is convertible to forward_iterator_tag
-         and iterator_traits<Iterator>::reference is a 
-             mutable reference)
-    return true;
-else
-    return false;
-
-

Suppose the value_type of the iterator It has a private -assignment operator:

-
-class B {
-public:
-  ...
-private:
-  B& operator=(const B&);
-};
-
-

and suppose the reference type of the iterator is B&. In -that case, is_writable<It>::value will be true when in fact -attempting to write into B will cause an error.

-

The same problem applies to is_swappable.

-
-
-

Proposed Resolution

-
    -
  1. Remove the is_writable and is_swappable traits, and remove the -requirements in the Writable Iterator and Swappable Iterator concepts -that require their models to support these traits.

    -
  2. -
  3. Change the is_readable specification to be: -is_readable<X>::type is true_type if the -result type of X::operator* is convertible to -iterator_traits<X>::value_type and is false_type -otherwise. Also, is_readable is required to satisfy -the requirements for the UnaryTypeTrait concept -(defined in the type traits proposal).

    -

    Remove the requirement for support of the is_readable trait from -the Readable Iterator concept.

    -
  4. -
  5. Remove the iterator_tag class.

    -
  6. -
  7. Change the specification of traversal_category to:

    -
    -traversal-category(Iterator) =
    -    let cat = iterator_traits<Iterator>::iterator_category
    -    if (cat is convertible to incrementable_iterator_tag)
    -      return cat; // Iterator is a new iterator
    -    else if (cat is convertible to random_access_iterator_tag)
    -        return random_access_traversal_tag;
    -    else if (cat is convertible to bidirectional_iterator_tag)
    -        return bidirectional_traversal_tag;
    -    else if (cat is convertible to forward_iterator_tag)
    -        return forward_traversal_tag;
    -    else if (cat is convertible to input_iterator_tag)
    -        return single_pass_iterator_tag;
    -    else if (cat is convertible to output_iterator_tag)
    -        return incrementable_iterator_tag;
    -    else
    -        return null_category_tag;
    -
    -
  8. -
-
-
-

Rationale

-
    -
  1. There are two reasons for removing is_writable -and is_swappable. The first is that we do not know of -a way to fix the specification so that it gives the correct -answer for all iterators. Second, there was only a weak -motivation for having is_writable and is_swappable -there in the first place. The main motivation was simply -uniformity: we have tags for the old iterator categories -so we should have tags for the new iterator categories. -While having tags and the capability to dispatch based -on the traversal categories is often used, we see -less of a need for dispatching based on writability -and swappability, since typically algorithms -that need these capabilities have no alternative if -they are not provided.
  2. -
  3. We discovered that the is_readable trait can be implemented -using only the iterator type itself and its value_type. -Therefore we remove the requirement for is_readable from the -Readable Iterator concept, and change the definition of -is_readable so that it works for any iterator type.
  4. -
  5. The purpose of the iterator_tag class was to -bundle the traversal and access category tags -into the iterator_category typedef. -With is_writable and is_swappable gone, and -is_readable no longer in need of special hints, -there is no reason for iterators to provide -information about the access capabilities of an iterator. -Thus there is no need for the iterator_tag. The -traversal tag can be directly used for the -iterator_category. If a new iterator is intended to be backward -compatible with old iterator concepts, a tag type -that is convertible to both one of the new traversal tags -and also to an old iterator tag can be created and use -for the iterator_category.
  6. -
  7. The changes to the specification of traversal_category are a -direct result of the removal of iterator_tag.
  8. -
-
-
- - diff --git a/doc/issues.rst b/doc/issues.rst deleted file mode 100755 index 5ddb61f..0000000 --- a/doc/issues.rst +++ /dev/null @@ -1,152 +0,0 @@ -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - Problem with ``is_writable`` and ``is_swappable`` in N1550_ -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -.. _N1550: http://www.boost-consulting.com/writing/n1550.html -.. _N1530: http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1530.html - -:Author: David Abrahams and Jeremy Siek -:Contact: dave@boost-consulting.com, jsiek@osl.iu.edu -:Organization: `Boost Consulting`_, Indiana University Bloomington -:date: $Date$ -:Copyright: Copyright David Abrahams, Jeremy Siek 2003. Use, modification and - distribution is subject to the Boost Software License, - Version 1.0. (See accompanying file LICENSE_1_0.txt or copy - at http://www.boost.org/LICENSE_1_0.txt) - -.. _`Boost Consulting`: http://www.boost-consulting.com - -.. contents:: Table of Contents - -============== - Introduction -============== - -The ``is_writable`` and ``is_swappable`` traits classes in N1550_ -provide a mechanism for determining at compile time if an iterator -type is a model of the new Writable Iterator and Swappable Iterator -concepts, analogous to ``iterator_traits::iterator_category`` -for the old iterator concepts. For backward compatibility, -``is_writable`` and ``is_swappable`` not only work with new -iterators, but they also are intended to work for old -iterators (iterators that meet the requirements for one of the -iterator concepts in the current standard). In the case of old -iterators, the writability and swapability is deduced based on the -``iterator_category`` and also the ``reference`` type. The -specification for this deduction gives false positives for forward -iterators that have non-assignable value types. - -To review, the part of the ``is_writable`` trait definition which -applies to old iterators is:: - - if (cat is convertible to output_iterator_tag) - return true; - else if (cat is convertible to forward_iterator_tag - and iterator_traits::reference is a - mutable reference) - return true; - else - return false; - -Suppose the ``value_type`` of the iterator ``It`` has a private -assignment operator:: - - class B { - public: - ... - private: - B& operator=(const B&); - }; - -and suppose the ``reference`` type of the iterator is ``B&``. In -that case, ``is_writable::value`` will be true when in fact -attempting to write into ``B`` will cause an error. - -The same problem applies to ``is_swappable``. - - -==================== - Proposed Resolution -==================== - -1. Remove the ``is_writable`` and ``is_swappable`` traits, and remove the - requirements in the Writable Iterator and Swappable Iterator concepts - that require their models to support these traits. - -2. Change the ``is_readable`` specification to be: - ``is_readable::type`` is ``true_type`` if the - result type of ``X::operator*`` is convertible to - ``iterator_traits::value_type`` and is ``false_type`` - otherwise. Also, ``is_readable`` is required to satisfy - the requirements for the UnaryTypeTrait concept - (defined in the type traits proposal). - - Remove the requirement for support of the ``is_readable`` trait from - the Readable Iterator concept. - - -3. Remove the ``iterator_tag`` class. - -4. Change the specification of ``traversal_category`` to:: - - traversal-category(Iterator) = - let cat = iterator_traits::iterator_category - if (cat is convertible to incrementable_iterator_tag) - return cat; // Iterator is a new iterator - else if (cat is convertible to random_access_iterator_tag) - return random_access_traversal_tag; - else if (cat is convertible to bidirectional_iterator_tag) - return bidirectional_traversal_tag; - else if (cat is convertible to forward_iterator_tag) - return forward_traversal_tag; - else if (cat is convertible to input_iterator_tag) - return single_pass_iterator_tag; - else if (cat is convertible to output_iterator_tag) - return incrementable_iterator_tag; - else - return null_category_tag; - - -========== - Rationale -========== - -1. There are two reasons for removing ``is_writable`` - and ``is_swappable``. The first is that we do not know of - a way to fix the specification so that it gives the correct - answer for all iterators. Second, there was only a weak - motivation for having ``is_writable`` and ``is_swappable`` - there in the first place. The main motivation was simply - uniformity: we have tags for the old iterator categories - so we should have tags for the new iterator categories. - While having tags and the capability to dispatch based - on the traversal categories is often used, we see - less of a need for dispatching based on writability - and swappability, since typically algorithms - that need these capabilities have no alternative if - they are not provided. - -2. We discovered that the ``is_readable`` trait can be implemented - using only the iterator type itself and its ``value_type``. - Therefore we remove the requirement for ``is_readable`` from the - Readable Iterator concept, and change the definition of - ``is_readable`` so that it works for any iterator type. - -3. The purpose of the ``iterator_tag`` class was to - bundle the traversal and access category tags - into the ``iterator_category`` typedef. - With ``is_writable`` and ``is_swappable`` gone, and - ``is_readable`` no longer in need of special hints, - there is no reason for iterators to provide - information about the access capabilities of an iterator. - Thus there is no need for the ``iterator_tag``. The - traversal tag can be directly used for the - ``iterator_category``. If a new iterator is intended to be backward - compatible with old iterator concepts, a tag type - that is convertible to both one of the new traversal tags - and also to an old iterator tag can be created and use - for the ``iterator_category``. - -4. The changes to the specification of ``traversal_category`` are a - direct result of the removal of ``iterator_tag``. - diff --git a/doc/iter-issue-list.rst b/doc/iter-issue-list.rst deleted file mode 100644 index c854900..0000000 --- a/doc/iter-issue-list.rst +++ /dev/null @@ -1,1037 +0,0 @@ -+++++++++++++++++++++++++++++++++++++ - Iterator concept and adapter issues -+++++++++++++++++++++++++++++++++++++ - -:date: $Date$ -:copyright: Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. - -=================================== - Issues from Matt's TR issues list -=================================== - -.. contents:: Index - -9.1 iterator_access overspecified? -================================== - -:Submitter: Pete Becker -:Status: New - -The proposal includes:: - - enum iterator_access { - readable_iterator = 1, writable_iterator = 2, - swappable_iterator = 4, lvalue_iterator = 8 - }; - -In general, the standard specifies thing like this as a bitmask type with a list of defined names, -and specifies neither the exact type nor the specific values. Is there a reason for iterator_access to -be more specific? - -:Proposed resolution: The iterator_access enum will be removed, so - this is no longer an issue. See the resolution to 9.15. - - -9.2 operators of iterator_facade overspecified -============================================== - -:Submitter: Pete Becker -:Status: New - -In general, we've provided operational semantics for things like -operator++. That is, we've said that ++iter must work, without -requiring either a member function or a non-member function. -iterator_facade specifies most operators as member -functions. There's no inherent reason for these to be members, so -we should remove this requirement. Similarly, some operations are -specified as non-member functions but could be implemented as -members. Again, the standard doesn't make either of these choices, -and TR1 shouldn't, either. So: ``operator*()``, ``operator++()``, -``operator++(int)``, ``operator--()``, ``operator--(int)``, -``operator+=``, ``operator-=``, ``operator-(difference_type)``, -``operator-(iterator_facade instance)``, and ``operator+`` should -be specified with operational semantics and not explicitly required -to be members or non-members. - -:Proposed resolution: Not a defect. - -:Rationale: We are following the approach in the standard. Classes - such as reverse_iterator are specified by listing the function - prototypes for the various operators. Further, the prototype - specification does not prevent the implementor from using members - or non-members. - - -9.3 enable_if_interoperable needs standardese -============================================= - -:Submitter: Pete Becker -:Status: New - -The only discussion of what this means is in a note, so is non-normative. Further, the note seems -to be incorrect. It says that enable_if_interoperable only works for types that "are -interoperable, by which we mean they are convertible to each other." This requirement is too -strong: it should be that one of the types is convertible to the other. -N1541 48 - -:Proposed resolution: Pete proposed: - - Remove the enable_if_interoperable stuff, and just write all the - comparisons to return bool. Then add a blanket statement that the - behavior of these functions is undefined if the two types aren't - interoperable. - - **Needs work** (Dave) I'm not happy with Pete's proposal. - - (thw) Pete is correct with regard to the requirement. Removing the - interoperable stuff would be an error. By all means we don't want - undefined behaviour here. - -9.4 enable_if_convertible unspecified, conflicts with requires -============================================================== - -:Submitter: Pete Becker -:Status: New - -In every place where enable_if_convertible is used it's used like -this (simplified):: - - template - struct C - { - template - C(T1, enable_if_convertible::type* = 0); - }; - -The idea being that this constructor won't compile if T1 isn't convertible to T. As a result, the -constructor won't be considered as a possible overload when constructing from an object x where -the type of x isn't convertible to T. In addition, however, each of these constructors has a requires -clause that requires convertibility, so the behavior of a program that attempts such a construction -is undefined. Seems like the enable_if_convertible part is irrelevant, and should be removed. -There are two problems. First, enable_if_convertible is never specified, so we don’t -know what this is supposed to do. Second: we could reasonably say that this overload should be -disabled in certain cases or we could reasonably say that behavior is undefined, but we can’t say -both. - -Thomas Witt writes that the goal of putting in enable_if_convertible here is to make -sure that a specific overload doesn’t interfere with the generic case except when that overload -makes sense. He agrees that what we currently have is deficient. -Dave Abrahams writes that there is no conflict with the requires cause because the requires -clause only takes effect when the function is actually called. The presence of the constructor -signature -can/will be detected by is_convertible without violating the requires clause, and thus it makes a -difference to disable those constructor instantiations that would be disabled by -enable_if_convertible even if calling them invokes undefined behavior. -There was more discussion on the reflector: c++std-lib-12312, c++std-lib-12325, c++std-lib- -12330, c++std-lib-12334, c++std-lib-12335, c++std-lib-12336, c++std-lib-12338, c++std-lib- -12362. - -:Proposed resolution: Specify enable_if_convertible to be as-if - :: - - template enable_if_convertible_impl - {}; - - template <> enable_if_convertible_impl - { struct type; }; - - template - struct enable_if_convertible - : enable_if_convertible_impl< - is_convertible::value> - {}; - - -9.5 iterator_adaptor has an extraneous 'bool' at the start of the template definition -===================================================================================== - -:Submitter: Pete Becker -:Status: New - -The title says it all; this is probably just a typo. - -:Proposed resolution: Remove the 'bool'. - -9.6 Name of private member shouldn't be normative -================================================= - -:Submitter: Pete Becker -:Status: New - -iterator_adaptor has a private member named m_iterator. Presumably this is for exposition only, -since it's an implementation detail. It needs to be marked as such. - -:Proposed resolution: Mark the member m_iterator as exposition - only. Note/DWA: I think this is NAD because the user can't - detect it, though I'm happy to mark it exposition only. - -9.7 iterator_adaptor operations specifications are a bit inconsistent -===================================================================== - -:Submitter: Pete Becker -:Status: New - -iterator_adpator() has a Requires clause, that Base must be default constructible. -iterator_adaptor(Base) has no Requires clause, although the Returns clause says that the Base -member is copy construced from the argument (this may actually be an oversight in N1550, -which doesn't require iterators to be copy constructible or assignable). - -:Proposed resolution: **Needs work** (Jeremy) - Add a requirements section for the template parameters of - iterator_adaptor, and state that Base must be Copy Constructible and - Assignable. - - -9.8 Specialized adaptors text should be normative -================================================= - -:Submitter: Pete Becker -:Status: New - -similar to 9.3, "Specialized Adaptors" has a note describing enable_if_convertible. This should -be normative text. - -:Proposed resolution: **Needs work** (Dave) Change it to normative - text. See the resolution of 9.4 - -9.9 Reverse_iterator text is too informal -========================================= - -:Submitter: Pete Becker -:Status: New - -reverse iterator "flips the direction of the base iterator's motion". This needs to be more formal, -as in the current standard. Something like: "iterates through the controlled sequence in the -opposite direction" - -:Proposed resolution: **Needs work** (Jeremy) - We agree and need to find wording. - -9.10 'prior' is undefined -========================= - -:Submitter: Pete Becker -:Status: New - -reverse_iterator::dereference is specified as calling a function named 'prior' which has no -specification. - -:Proposed resolution: **Needs language** (Jeremy) - Replace use of prior with what it does. - - -9.11 "In other words" is bad wording -==================================== - -:Submitter: Pete Becker -:Status: New - -Transform iterator has a two-part specification: it does this, in other words, it does that. "In other -words" always means "I didn't say it right, so I'll try again." We need to say it once. - -:Proposed resolution: **Needs work** (Jeremy) - -Reword. - -9.12 Transform_iterator shouldn’t mandate private member -======================================================== - -:Submitter: Pete Becker -:Status: New - -transform_iterator has a private member named 'm_f' which should be marked "exposition only." - -:Proposed resolution: Mark the member m_f as exposition - only. Note/DWA: I think this is NAD because the user can't - detect it, though I'm happy to makr it exposition only. - - -9.13 Unclear description of counting iterator -============================================= - -:Submitter: Pete Becker -:Status: New - -The description of Counting iterator is unclear. "The counting iterator adaptor implements -dereference by returning a reference to the base object. The other operations are implemented by -the base m_iterator, as per the inheritance from iterator_adaptor." - -:Proposed resolution: **Needs work** (Jeremy) Reword. - - -9.14 Counting_iterator's difference type -======================================== - -:Submitter: Pete Becker -:Status: New - -Counting iterator has the following note: - - [Note: implementers are encouraged to provide an implementation - of distance_to and a difference_type that avoids overflows in the - cases when the Incrementable type is a numeric type.] - -I'm not sure what this means. The user provides a template argument named Difference, but -there's no difference_type. I assume this is just a glitch in the wording. But if implementors are -encouraged to ignore this argument if it won't work right, why is it there? - -:Proposed resolution: **Needs work** (Jeremy) - Reword. - - -9.15 How to detect lvalueness? -============================== - -:Submitter: Dave Abrahams -:Status: New - -Shortly after N1550 was accepted, we discovered that an iterator's lvalueness can be determined -knowing only its value_type. This predicate can be calculated even for old-style iterators (on -whose reference type the standard places few requirements). A trait in the Boost iterator library -does it by relying on the compiler's unwillingness to bind an rvalue to a T& function template -parameter. Similarly, it is possible to detect an iterator's readability knowing only its value_type. -Thus, any interface which asks the user to explicitly describe an iterator's lvalue-ness or -readability seems to introduce needless complexity. - - -:Proposed resolution: - - 1. Remove the ``is_writable`` and ``is_swappable`` traits, and remove the - requirements in the Writable Iterator and Swappable Iterator concepts - that require their models to support these traits. - - 2. Change the ``is_readable`` specification to be: - - ``is_readable::type`` is ``true_type`` if the - result type of ``X::operator*`` is convertible to - ``iterator_traits::value_type`` and is ``false_type`` - otherwise. Also, ``is_readable`` is required to satisfy - the requirements for the UnaryTypeTrait concept - (defined in the type traits proposal). - - Remove the requirement for support of the ``is_readable`` trait from - the Readable Iterator concept. - - - 3. Remove the ``iterator_tag`` class. - - 4. Change the specification of ``traversal_category`` to:: - - traversal-category(Iterator) = - let cat = iterator_traits::iterator_category - if (cat is convertible to incrementable_iterator_tag) - return cat; // Iterator is a new iterator - else if (cat is convertible to random_access_iterator_tag) - return random_access_traversal_tag; - else if (cat is convertible to bidirectional_iterator_tag) - return bidirectional_traversal_tag; - else if (cat is convertible to forward_iterator_tag) - return forward_traversal_tag; - else if (cat is convertible to input_iterator_tag) - return single_pass_iterator_tag; - else if (cat is convertible to output_iterator_tag) - return incrementable_iterator_tag; - else - return null_category_tag; - -:Rationale: - -1. There are two reasons for removing ``is_writable`` - and ``is_swappable``. The first is that we do not know of - a way to fix the specification so that it gives the correct - answer for all iterators. Second, there was only a weak - motivation for having ``is_writable`` and ``is_swappable`` - there in the first place. The main motivation was simply - uniformity: we have tags for the old iterator categories - so we should have tags for the new iterator categories. - While having tags and the capability to dispatch based - on the traversal categories is often used, we see - less of a need for dispatching based on writability - and swappability, since typically algorithms - that need these capabilities have no alternative if - they are not provided. - -2. We discovered that the ``is_readable`` trait can be implemented - using only the iterator type itself and its ``value_type``. - Therefore we remove the requirement for ``is_readable`` from the - Readable Iterator concept, and change the definition of - ``is_readable`` so that it works for any iterator type. - -3. The purpose of the ``iterator_tag`` class was to - bundle the traversal and access category tags - into the ``iterator_category`` typedef. - With ``is_writable`` and ``is_swappable`` gone, and - ``is_readable`` no longer in need of special hints, - there is no reason for iterators to provide - information about the access capabilities of an iterator. - Thus there is no need for the ``iterator_tag``. The - traversal tag can be directly used for the - ``iterator_category``. If a new iterator is intended to be backward - compatible with old iterator concepts, a tag type - that is convertible to both one of the new traversal tags - and also to an old iterator tag can be created and use - for the ``iterator_category``. - -4. The changes to the specification of ``traversal_category`` are a - direct result of the removal of ``iterator_tag``. - - - -9.16 is_writable_iterator returns false positives -================================================= - -:Submitter: Dave Abrahams -:Status: New - -is_writable_iterator returns false positives for forward iterators whose value_type has a private -assignment operator, or whose reference type is not a reference (currently legal). - -:Proposed Resolution: See the resolution to 9.15. - - -9.17 is_swappable_iterator returns false positives -================================================== - -:Submitter: Dave Abrahams -:Status: New - -is_swappable_iterator has the same problems as is_writable_iterator. In addition, if we allow -users to write their own iter_swap functions it's easy to imagine old-style iterators for which -is_swappable returns false negatives. - -:Proposed Resolution: See the resolution to 9.15. - - -9.18 Are is_readable, is_writable, and is_swappable useful? -=========================================================== - -:Submitter: Dave Abrahams -:Status: New - -I am concerned that there is little use for any of is_readable, is_writable, or is_swappable, and -that not only do they unduly constrain iterator implementors but they add overhead to -iterator_facade and iterator_adaptor in the form of a template parameter which would otherwise -be unneeded. Since we can't implement two of them accurately for old-style iterators, I am -having a hard time justifying their impact on the rest of the proposal(s). - -:Proposed Resolution: See the resolution to 9.15. - -9.19 Non-Uniformity of the "lvalue_iterator Bit" -================================================ - -:Submitter: Dave Abrahams -:Status: New - -The proposed iterator_tag class template accepts an "access bits" -parameter which includes a bit to indicate the iterator's -lvalueness (whether its dereference operator returns a reference to -its value_type. The relevant part of N1550 says: - - The purpose of the lvalue_iterator part of the iterator_access - enum is to communicate to iterator_tagwhether the reference type - is an lvalue so that the appropriate old category can be chosen - for the base class. The lvalue_iterator bit is not recorded in - the iterator_tag::access data member. - -The lvalue_iterator bit is not recorded because N1550 aims to -improve orthogonality of the iterator concepts, and a new-style -iterator's lvalueness is detectable by examining its reference -type. This inside/outside difference is awkward and confusing. - -:Proposed Resolution: The iterator_tag class will be removed, so this is no longer an issue. - See the resolution to 9.15. - - -9.20 Traversal Concepts and Tags -================================ - -:Submitter: Dave Abrahams -:Status: New - -Howard Hinnant pointed out some inconsistencies with the naming of these tag types:: - - incrementable_iterator_tag // ++r, r++ - single_pass_iterator_tag // adds a == b, a != b - forward_traversal_iterator_tag // adds multi-pass - bidirectional_traversal_iterator_tag // adds --r, r-- - random_access_traversal_iterator_tag // adds r+n,n+r,etc. - -Howard thought that it might be better if all tag names contained the word "traversal". -It's not clear that would result in the best possible names, though. For example, incrementable -iterators can only make a single pass over their input. What really distinguishes single pass -iterators from incrementable iterators is not that they can make a single pass, but that they are -equality comparable. Forward traversal iterators really distinguish themselves by introducing -multi-pass capability. Without entering a "Parkinson's Bicycle Shed" type of discussion, it might -be worth giving the names of these tags (and the associated concepts) some extra attention. - -:Proposed resolution: Change the names of the traversal tags to the - following names:: - - incrementable_traversal_tag - single_pass_traversal_tag - forward_traversal_tag - bidirectional_traversal_tag - random_access_traversal_tag - - - ** Needs work ** (thw) I still believe that implicit_traversal_tag is more - appropriate than incrementable_traversal_tag - - -9.21 iterator_facade Derived template argument underspecified -============================================================= - -:Submitter: Pete Becker -:Status: New - -The first template argument to iterator_facade is named Derived, -and the proposal says: - - The Derived template parameter must be a class derived from - iterator_facade. - -First, iterator_facade is a template, so cannot be derived from. Rather, the class must be derived -from a specialization of iterator_facade. More important, isn't Derived required to be the class -that is being defined? That is, if I understand it right, the -definition of D here this is not valid:: - - class C : public iterator_facade { ... }; - class D : public iterator_facade { ... }; - -In the definition of D, the Derived argument to iterator_facade is a class derived from a -specialization of iterator_facade, so the requirement is met. Shouldn't the requirement be more -like "when using iterator_facade to define an iterator class Iter, the class Iter must be derived -from a specialization of iterator_facade whose first template argument is Iter." That's a bit -awkward, but at the moment I don't see a better way of phrasing it. - -:Proposed resolution: **Needs work** (Dave) Reword. - 01/01/04 thw - The wording is certainly insufficient. AFAICS there are two issues. - First the issue addressed by Pete i.e. specifying the requirements for - implementing a valid iterator. The other issue I can see is that we - need to be able to unambigously cast the iterator_facade specialisation - to Iter. - -9.22 return type of Iterator difference for iterator facade -=========================================================== - -:Submitter: Pete Becker -:Status: New - -The proposal says:: - - template - typename enable_if_interoperable::type - operator -(iterator_facade const& lhs, - iterator_facade const& rhs); - -Shouldn't the return type be one of the two iterator types? Which -one? The idea is that if one of the iterator types can be converted -to the other type, then the subtraction is okay. Seems like the -return type should then be the type that was converted to. Is that -right? - -:Proposed resolution: - Change the return type from :: - - typename enable_if_interoperable::type - - to :: - - typename enable_if_interoperable::type - - 01/01/04 thw - Almost, the return type should be the difference_type of the - converted to iterator. BTW how does std::distance handle - different but interoperable iterator types? - - -9.23 Iterator_facade: minor wording Issue -========================================= - -:Submitter: Pete Becker -:Status: New - -In the table that lists the required (sort of) member functions of iterator types that are based on -iterator_facade, the entry for c.equal(y) says: - - true iff c and y refer to the same position. Implements c == y - and c != y. The second sentence is inside out. c.equal(y) does - not implement either of these operations. It is used to implement - them. Same thing in the description of c.distance_to(z). - -:Proposed resolution: **Needs work** (Dave) Reword. - - -9.24 Use of undefined name in iterator_facade table -=================================================== - -:Submitter: Pete Becker -:Status: New - -Several of the descriptions use the name X without defining it. This seems to be a carryover from -the table immediately above this section, but the text preceding that table says "In the table -below, X is the derived iterator type." Looks like the X:: qualifiers aren't really needed; -X::reference can simply be reference, since that's defined by the iterator_facade specialization -itself. - -:Proposed resolution: **Needs language** (Dave) Remove the use of X. - - -9.25 Iterator_facade: wrong return type -======================================= - -:Submitter: Pete Becker -:Status: New - -Several of the member functions return a Derived object or a Derived&. Their Effects clauses -end with:: - - return *this; - -This should be :: - - return *static_cast(this); - -:Proposed resolution: - Change the returns clause to:: - - return *static_cast(this); - - Note/DWA: I think this needs to be a more detailed change list, - so I'm marking it **Needs language**. - -9.26 Iterator_facade: unclear returns clause for operator[] -=========================================================== - -:Submitter: Pete Becker -:Status: New - -The returns clause for ``operator[](difference_type n)`` const -says: - - Returns: an object convertible to X::reference and holding a copy - p of a+n such that, for a constant object v of type - X::value_type, X::reference(a[n] = v) is equivalent to p = v. - This needs to define 'a', but assuming it's supposed to be - ``*this`` (or maybe ``*(Derived*)this``), it still isn't clear - what this says. Presumably, the idea is that you can index off of - an iterator and assign to the result. But why the requirement - that it hold a copy of a+n? Granted, that's probably how it's - implemented, but it seems over-constrained. And the last phrase - seems wrong. p is an iterator; there's no requirement that you - can assign a value_type object to it. Should that be ``*p = v``? - But why the cast in reference(a[n] = v)? - -:Proposed resolution: **Needs work** - (Dave) - - Change ``*this`` to ``*static_cast(this)``. Also reword - the stuff about ``X::reference(a[n] = v)`` is equivalent to ``p = - v``. Also make sure whatever's written accounts for ``v = a[n]`` - - - -9.27 Iterator_facade: redundant clause -====================================== - -:Submitter: Pete Becker -:Status: New - -``operator-`` has both an effects clause and a returns clause. Looks like the returns clause should be -removed. - -:Proposed resolution: Remove the returns clause. - - -9.28 indirect_iterator: incorrect specification of default constructor -====================================================================== - -:Submitter: Pete Becker -:Status: New - -The default constructor returns "An instance of indirect_iterator with a default constructed base -object", but the constructor that takes an Iterator object returns "An instance of indirect_iterator -with the iterator_adaptor subobject copy constructed from x." The latter is the correct form, since -it does not reach inside the base class for its semantics. So the default constructor shoudl return -"An instance of indirect_iterator with a default-constructed iterator_adaptor subobject." - -:Proposed resolution: Change the effects clause to - - Effects: Constructs an instance of indirect_iterator with a default - constructed iterator_adaptor subobject. - - -9.29 indirect_iterator: unclear specification of template constructor -===================================================================== - -:Submitter: Pete Becker -:Status: New - -The templated constructor that takes an indirect_iterator with a different set of template -arguments says that it returns "An instance of indirect_iterator that is a copy of [the argument]". -But the type of the argument is different from the type of the object being constructed, and there -is no description of what a "copy" means. The Iterator template parameter for the argument must -be convertible to the Iterator template parameter for the type being constructed, which suggests -that the argument's contained Iterator object should be converted to the target type's Iterator type. -Is that what's meant here? -(Pete later writes: In fact, this problem is present in all of the specialized adaptors that have a -constructor like this: the constructor returns "a copy" of the argument without saying what a -copy is.) - -:Proposed resolution: Change the effects clause - to - - Effects: Constructs an instance of indirect_iterator whose - iterator_adaptor subobject is constructed from y.base(). - - Note/DWA: isn't the iterator_adaptor base class an - implementation detail? I'm marking this **Needs Work** - -9.30 transform_iterator argument irregularity -============================================= - -:Submitter: Pete Becker -:Status: New - -The specialized adaptors that take both a Value and a Reference template argument all take them -in that order, i.e. Value precedes Reference in the template argument list, with the exception of -transform_iterator, where Reference precedes Value. This seems like a possible source of -confusion. Is there a reason why this order is preferable? - -:Proposed resolution: Change the argument order so that Value precedes reference. - - -9.31 function_output_iterator overconstrained -============================================= - -:Submitter: Pete Becker -:Status: New - -function_output_iterator requirements says: "The UnaryFunction must be Assignable, Copy -Constructible, and the expression f(x) must be valid, where f is an object of type UnaryFunction -and x is an object of a type accepted by f." - -Everything starting with "and," somewhat reworded, is actually a constraint on -output_proxy::operator=. All that's needed to create a function_output_iterator object is that the -UnaryFunction type be Assignable and CopyConstructible. That's also sufficient to dereference -and to increment such an object. It's only when you try to assign through a dereferenced iterator -that f(x) has to work, and then only for the particular function object that the iterator holds and -for the particular value that is being assigned. - -:Proposed resolution: **Needs work** (Jeremy) Agree, need to find wording. - - - -9.32 Should output_proxy really be a named type? -================================================ - -:Submitter: Pete Becker -:Status: New - -This means someone can store an output_proxy object for later use, whatever that means. It also -constrains output_proxy to hold a copy of the function object, rather than a pointer to the iterator -object. Is all this mechanism really necessary? - -:Proposed resolution: **Needs work** (Jeremy) Agree, need to find wording. - - - -9.33 istreambuf_iterator isn't a Readable Iterator -================================================== - -:Submitter: Pete Becker -:Status: New - -c++std-lib-12333: - - N1550 requires that for a Readable Iterator a of type X, ``*a`` returns an object of type - iterator_traits::reference. ``istreambuf_iterator::operator*`` returns charT, but - istreambuf_iterator::reference is charT&. So am I overlooking something, or is - istreambuf_iterator not Readable - -:Proposed resolution: **Needs language** (Jeremy) - Remove requirements on the reference type from Readable Iterator. - - - -9.34 iterator_facade free functions unspecified -=============================================== - -:Submitter: Pete Becker -:Status: New - -c++std-lib-12562: - - The template functions ``operator==``, ``operator!=``, - ``operator<``, ``operator<=``, ``operator>``, ``operator>=``, and - ``operator-`` that take two arguments that are specializations of - iterator_facade have no specification. The template function - operator+ that takes an argument that is a specialization of - iterator_facade and an argument of type difference_type has no - specification. - -:Proposed resolution: **Needs work** (Dave) Add the missing specifications. - - -9.35 iterator_facade: too many equals? -====================================== - -:Submitter: Pete Becker -:Status: New - -c++std-lib-12563: - - The table listing the functions required for types derived from iterator_facade has two functions - named equal and two named distance_to:: - - c.equal(b) - c.equal(y) - c.distance_to(b) - c.distance_to(z) - - where b and c are const objects of the derived type, y and z are constant objects of certain iterator - types that are interoperable with the derived type. - Seems like the 'b' versions are redundant: in both cases, the other version will take a 'b'. In fact, - iterator_adaptor is specified to use iterator_facade, but does not provide the 'b' versions of these - functions. - - Are the 'b' versions needed? - -:Proposed resolution: Remove the 'b' versions. - - -9.36 iterator_facade function requirements -========================================== - -:Submitter: Pete Becker -:Status: New - -c++std-lib-12636: - - The table that lists required functions for the derived type X passed to iterator_facade lists, - among others: - for a single pass iterator:: - - c.equal(b) - c.equal(y) - - where b and c are const X objects, and y is a const object of a single pass iterator that is - interoperable with X. Since X is interoperable with itself, c.equal(b) is redundant. There is a - difference in their descriptions, but its meaning isn't clear. The first is "true iff b and c are - equivalent", and the second is "true iff c and y refer to the same position." Is there a difference - between the undefined term "equivalent" and "refer to the same position"? - - Similarly, for a random access traversal iterator:: - - c.distance_to(b) - c.distance_to(z) - - where z is a constant object of a random access traversal iterator that is interoperable with X. - Again, X is interoperable with itself, so c.distance_to(b) is redundant. - Also, the specification for c.distance_to(z) isn't valid. It's written as "equivalent to distance(c, - z)". The template function distance takes two arguments of the same type, so distance(c, z) isn't - valid if c and z are different types. Should it be distance(c, (X)z)? - -:Proposed resolution: **Needs work** (Dave) - - We need to define what "same position" means for iterators. This also - needs to be part of the definition of an Interoperable Iterator - concept. - - -==================================== - More Issues (not from Matt's list) -==================================== - - - -Inheritance in iterator_adaptor and other adaptors is an overspecification -========================================================================== - -:Submitter: Pete Becker -:Status: New - -c++std-lib-12696: -The paper requires that iterator_adaptor be derived from an -appropriate instance of iterator_facade, and that most of the specific -forms of adaptors be derived from appropriate instances of -iterator_adaptor. That seems like overspecification, and we ought to -look at specifying these things in terms of what the various templates -provide rather than how they're implemented. - -:Proposed resolution: **Needs work** - -Remove the specfication of inheritance, and add lots of specification -to make up for it. In iterator_adaptor, that means duplicating a lot of -function prototypes. In the other adaptors, that means making sure we -state what concepts are modeled. Also, we will need an Interoperable -Iterator concept to accomplish this. - -I'll start on the work of changing the specification for the -specialized adaptors. -Jeremy - - -Problem with specification of a->m in Readable Iterator -======================================================= - -:Submitter: Howard Hinnant -:Status: New - -c++std-lib-12585: - -Readable Iterator Requirements says:: - - a->m U& pre: (*a).m is well-defined. Equivalent to (*a).m - -Do we mean to outlaw iterators with proxy references from meeting the -readable requirements? - -Would it be better for the requirements to read ``static_cast(*a).m`` -instead of ``(*a).m`` ? - -:Proposed resolution: Change the requirement to - - :pre: ``static_cast(*a).m`` is well-defined. If - ``static_cast(*a).m`` is well-defined, equivalent to - ``static_cast(*a).m``; otherwise, equivalent to - ``static_cast(*a).m``. - - -counting_iterator Traversal argument unspecified -================================================ - -:Submitter: Pete Becker - -c++std-lib-12635: - -counting_iterator takes an argument for its Traversal type, with a -default value of use_default. It is derived from an instance of -iterator_adaptor, where the argument passed for the Traversal type -is described as "\ ``/* see details for traversal category -*/``". The details for counting_iterator describe constraints on -the Incrementable type imposed by various traversal -categories. There is no description of what the argument to -iterator_adaptor should be. - - -:Proposed resolution: **Needs work** (Jeremy) - - - - -indirect_iterator requirements muddled -====================================== - -:Submitter: Pete Becker - -c++std-lib-12640: - - The value_type of the Iterator template parameter should itself be - dereferenceable. The return type of the ``operator*`` for the value_type must - be the same type as the Reference template parameter. - - I'd say this a bit differently, to emphasize what's required: - iterator_traits::value_type must be dereferenceable. - The Reference template parameter must be the same type as - ``*iterator_traits::value_type()``. - - The Value template parameter will be the value_type for the - indirect_iterator, unless Value is const. If Value is const X, then - value_type will be non- const X. - - Also non-volatile, right? In other words, if Value isn't use_default, it - just gets passed as the Value argument for iterator_adaptor. - - The default for Value is:: - - iterator_traits< iterator_traits::value_type >::value_type - - If the default is used for Value, then there must be a valid - specialization of iterator_traits for the value type of the - base iterator. - - The earlier requirement is that - ``iterator_traits::value_type`` must be - dereferenceable. Now it's being treated as an iterator. Is this - just a pun, or is ``iterator_traits::value_type`` - required to be some form of iterator? If it's the former we need - to find a different way to say it. If it's the latter we need to - say so. - -:Proposed resolution: **Needs work** (Jeremy) - - -:Rationale: - -iterator_facade just does remove_const::type, so value_type is -volatile if Value is. - - - -Problem with transform_iterator requirements -============================================ - -:Submitter: Pete Becker - -c++std-lib-12641: - - The reference type of transform_iterator is - ``result_of::reference)>::type``. The - ``value_type`` is ``remove_cv >::type``. - - These are the defaults, right? If the user supplies their own types that's - what gets passed to iterator_adaptor. And again, the specification should - be in terms of the specialization of iterator_adaptor, and not in terms of - the result: - - Reference argument to iterator_adaptor:: - - if (Reference != use_default) - Reference - else - result_of::reference)>::type - - Value argument to iterator_adaptor:: - - if (Value != use_default) - Value - else if (Reference != use_default) - remove_reference::type - else - remove_reference::reference)>::type>::type - - There's probably a better way to specify that last alternative, but I've - been at this too long, and it's all turning into a maze of twisty passages, - all alike. - -:Proposed resolution: **Needs work** (Jeremy) - - -filter_iterator details unspecified -=================================== - -:Submitter: Pete Becker - -c++std-lib-12642: - -The paper says:: - - template - class filter_iterator - : public iterator_adaptor< - filter_iterator, - Iterator, - use_default, - /* see details */ > - -That comment covers the Access, Traversal, Reference, and Difference -arguments. The only specification for any of these in the details is:: - - The access category of the filter_iterator will be the same as - the access category of Iterator. - -Needs more. - -:Proposed resolution: **Needs work** (Jeremy) diff --git a/doc/iterator_adaptor.html b/doc/iterator_adaptor.html deleted file mode 100644 index bd0ead3..0000000 --- a/doc/iterator_adaptor.html +++ /dev/null @@ -1,525 +0,0 @@ - - - - - - -Iterator Adaptor - - - - - - - -
-

Iterator Adaptor

- --- - - - - - - - - - - - -
Author:David Abrahams, Jeremy Siek, Thomas Witt
Contact:dave@boost-consulting.com, jsiek@osl.iu.edu, witt@ive.uni-hannover.de
Organization:Boost Consulting, Indiana University Open Systems -Lab, University of Hanover Institute for Transport -Railway Operation and Construction
Date:2003-09-14
Copyright:Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved
- --- - - - -
abstract:
- - -

Each specialization of the iterator_adaptor class template is derived from -a specialization of iterator_facade. The core interface functions -expected by iterator_facade are implemented in terms of the -iterator_adaptor's Base template parameter. A class derived -from iterator_adaptor typically redefines some of the core -interface functions to adapt the behavior of the Base type. -Whether the derived class models any of the standard iterator concepts -depends on the operations supported by the Base type and which -core interface functions of iterator_facade are redefined in the -Derived class.

- -
-

Introduction

- - -

The iterator_adaptor class template adapts some Base 1 -type to create a new iterator. Instantiations of iterator_adaptor -are derived from a corresponding instantiation of iterator_facade -and implement the core behaviors in terms of the Base type. In -essence, iterator_adaptor merely forwards all operations to an -instance of the Base type, which it stores as a member.

- - - - - -
[1]The term "Base" here does not refer to a base class and is -not meant to imply the use of derivation. We have followed the lead -of the standard library, which provides a base() function to access -the underlying iterator object of a reverse_iterator adaptor.
-

The user of iterator_adaptor creates a class derived from an -instantiation of iterator_adaptor and then selectively -redefines some of the core member functions described in the table -above. The Base type need not meet the full requirements for an -iterator. It need only support the operations used by the core -interface functions of iterator_adaptor that have not been -redefined in the user's derived class.

-

Several of the template parameters of iterator_adaptor default -to use_default. This allows the -user to make use of a default parameter even when she wants to -specify a parameter later in the parameter list. Also, the -defaults for the corresponding associated types are somewhat -complicated, so metaprogramming is required to compute them, and -use_default can help to simplify the implementation. Finally, -the identity of the use_default type is not left unspecified -because specification helps to highlight that the Reference -template parameter may not always be identical to the iterator's -reference type, and will keep users from making mistakes based on -that assumption.

-
-
-

Reference

- - -
-template <
-    class Derived
-  , class Base
-  , class Value        = use_default
-  , class CategoryOrTraversal  = use_default
-  , class Reference  = use_default
-  , class Difference = use_default
->
-class iterator_adaptor 
-  : public iterator_facade<Derived, V, C, R, D> // see details
-{
-    friend class iterator_core_access;
- public:
-    iterator_adaptor();
-    explicit iterator_adaptor(Base iter);
-    Base base() const;
- protected:
-    Base const& base_reference() const;
-    Base& base_reference();
- private: // Core iterator interface for iterator_facade.  
-    typename iterator_adaptor::reference dereference() const;
-
-    template <
-    class OtherDerived, class OtherIterator, class V, class C, class R, class D
-    >   
-    bool equal(iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> const& x) const;
-
-    void advance(typename iterator_adaptor::difference_type n);
-    void increment();
-    void decrement();
-
-    template <
-        class OtherDerived, class OtherIterator, class V, class C, class R, class D
-    >   
-    typename iterator_adaptor::difference_type distance_to(
-        iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> const& y) const;
-
- private:
-    Base m_iterator; // exposition only
-};
-
-
-

iterator_adaptor base class parameters

-

The V, C, R, and D parameters of the iterator_facade -used as a base class in the summary of iterator_adaptor -above are defined as follows:

-
-V = if (Value is use_default)
-          return iterator_traits<Base>::value_type
-      else
-          return Value
-
-C = if (CategoryOrTraversal is use_default)
-          return iterator_traversal<Base>::type
-      else
-          return CategoryOrTraversal
-
-R = if (Reference is use_default)
-          if (Value is use_default)
-              return iterator_traits<Base>::reference
-          else
-              return Value&
-      else
-          return Reference
-
-D = if (Difference is use_default)
-          return iterator_traits<Base>::difference_type
-      else
-          return Difference
-
-
-
-

iterator_adaptor usage

-

The Derived template parameter must be a publicly derived from -iterator_adaptor. In order for Derived to model the -iterator concepts corresponding to -iterator_traits<Derived>::iterator_category, the expressions -involving m_iterator in the specifications of those private -member functions of iterator_adaptor that may be called by -iterator_facade<Derived, ``\ *V*\, \ *C*\, \ *R*\, \ -*D*\>`` in evaluating any valid expression involving Derived -in those concepts' requirements.

-
-
-

iterator_adaptor public operations

-

iterator_adaptor();

- --- - - - - - -
Requires:The Base type must be Default Constructible.
Returns:An instance of iterator_adaptor with -m_iterator default constructed.
-

explicit iterator_adaptor(Base iter);

- --- - - - -
Returns:An instance of iterator_adaptor with -m_iterator copy constructed from iter.
-

Base base() const;

- --- - - - -
Returns:m_iterator
-
-
-

iterator_adaptor protected member functions

-

Base const& base_reference() const;

- --- - - - -
Returns:A const reference to m_iterator.
-

Base& base_reference();

- --- - - - -
Returns:A non-const reference to m_iterator.
-
-
-

iterator_adaptor private member functions

-

typename iterator_adaptor::reference dereference() const;

- --- - - - -
Returns:*m_iterator
-
-template <
-class OtherDerived, class OtherIterator, class V, class C, class R, class D
->   
-bool equal(iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> const& x) const;
-
- --- - - - -
Returns:m_iterator == x.base()
-

void advance(typename iterator_adaptor::difference_type n);

- --- - - - -
Effects:m_iterator += n;
-

void increment();

- --- - - - -
Effects:++m_iterator;
-

void decrement();

- --- - - - -
Effects:--m_iterator;
-
-template <
-    class OtherDerived, class OtherIterator, class V, class C, class R, class D
->   
-typename iterator_adaptor::difference_type distance_to(
-    iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> const& y) const;
-
- --- - - - -
Returns:y.base() - m_iterator
-
-
-
- - - - diff --git a/doc/iterator_adaptor.rst b/doc/iterator_adaptor.rst deleted file mode 100644 index e64e93a..0000000 --- a/doc/iterator_adaptor.rst +++ /dev/null @@ -1,32 +0,0 @@ -+++++++++++++++++ - Iterator Adaptor -+++++++++++++++++ - -:Author: David Abrahams, Jeremy Siek, Thomas Witt -:Contact: dave@boost-consulting.com, jsiek@osl.iu.edu, witt@ive.uni-hannover.de -:organization: `Boost Consulting`_, Indiana University `Open Systems - Lab`_, University of Hanover `Institute for Transport - Railway Operation and Construction`_ -:date: $Date$ -:copyright: Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved - -.. _`Boost Consulting`: http://www.boost-consulting.com -.. _`Open Systems Lab`: http://www.osl.iu.edu -.. _`Institute for Transport Railway Operation and Construction`: http://www.ive.uni-hannover.de - -:abstract: - -.. include:: iterator_adaptor_abstract.rst - -.. contents:: Table of Contents - -Introduction -============ - -.. include:: iterator_adaptor_body.rst - - -Reference -========= - -.. include:: iterator_adaptor_ref.rst diff --git a/doc/iterator_adaptor_abstract.rst b/doc/iterator_adaptor_abstract.rst deleted file mode 100644 index c20ac7b..0000000 --- a/doc/iterator_adaptor_abstract.rst +++ /dev/null @@ -1,16 +0,0 @@ -.. Version 1.1 of this ReStructuredText document corresponds to - n1530_, the paper accepted by the LWG. - -.. Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All - rights reserved - -Each specialization of the ``iterator_adaptor`` class template is derived from -a specialization of ``iterator_facade``. The core interface functions -expected by ``iterator_facade`` are implemented in terms of the -``iterator_adaptor``\ 's ``Base`` template parameter. A class derived -from ``iterator_adaptor`` typically redefines some of the core -interface functions to adapt the behavior of the ``Base`` type. -Whether the derived class models any of the standard iterator concepts -depends on the operations supported by the ``Base`` type and which -core interface functions of ``iterator_facade`` are redefined in the -``Derived`` class. diff --git a/doc/iterator_adaptor_body.rst b/doc/iterator_adaptor_body.rst deleted file mode 100644 index 59b8cef..0000000 --- a/doc/iterator_adaptor_body.rst +++ /dev/null @@ -1,39 +0,0 @@ -.. Version 1.2 of this ReStructuredText document corresponds to - n1530_, the paper accepted by the LWG for TR1. - -.. Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All - rights reserved - -The ``iterator_adaptor`` class template adapts some ``Base`` [#base]_ -type to create a new iterator. Instantiations of ``iterator_adaptor`` -are derived from a corresponding instantiation of ``iterator_facade`` -and implement the core behaviors in terms of the ``Base`` type. In -essence, ``iterator_adaptor`` merely forwards all operations to an -instance of the ``Base`` type, which it stores as a member. - -.. [#base] The term "Base" here does not refer to a base class and is - not meant to imply the use of derivation. We have followed the lead - of the standard library, which provides a base() function to access - the underlying iterator object of a ``reverse_iterator`` adaptor. - -The user of ``iterator_adaptor`` creates a class derived from an -instantiation of ``iterator_adaptor`` and then selectively -redefines some of the core member functions described in the table -above. The ``Base`` type need not meet the full requirements for an -iterator. It need only support the operations used by the core -interface functions of ``iterator_adaptor`` that have not been -redefined in the user's derived class. - -Several of the template parameters of ``iterator_adaptor`` default -to ``use_default``. This allows the -user to make use of a default parameter even when she wants to -specify a parameter later in the parameter list. Also, the -defaults for the corresponding associated types are somewhat -complicated, so metaprogramming is required to compute them, and -``use_default`` can help to simplify the implementation. Finally, -the identity of the ``use_default`` type is not left unspecified -because specification helps to highlight that the ``Reference`` -template parameter may not always be identical to the iterator's -``reference`` type, and will keep users from making mistakes based on -that assumption. - diff --git a/doc/iterator_adaptor_ref.rst b/doc/iterator_adaptor_ref.rst deleted file mode 100644 index 384f147..0000000 --- a/doc/iterator_adaptor_ref.rst +++ /dev/null @@ -1,169 +0,0 @@ -.. Version 1.4 of this ReStructuredText document corresponds to - n1530_, the paper accepted by the LWG for TR1. - -.. Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All - rights reserved. - -.. parsed-literal:: - - template < - class Derived - , class Base - , class Value = use_default - , class CategoryOrTraversal = use_default - , class Reference = use_default - , class Difference = use_default - > - class iterator_adaptor - : public iterator_facade // see details__ - { - friend class iterator_core_access; - public: - iterator_adaptor(); - explicit iterator_adaptor(Base iter); - Base base() const; - protected: - Base const& base_reference() const; - Base& base_reference(); - private: // Core iterator interface for iterator_facade. - typename iterator_adaptor::reference dereference() const; - - template < - class OtherDerived, class OtherIterator, class V, class C, class R, class D - > - bool equal(iterator_adaptor const& x) const; - - void advance(typename iterator_adaptor::difference_type n); - void increment(); - void decrement(); - - template < - class OtherDerived, class OtherIterator, class V, class C, class R, class D - > - typename iterator_adaptor::difference_type distance_to( - iterator_adaptor const& y) const; - - private: - Base m_iterator; // exposition only - }; - -__ base_parameters_ - -.. _base_parameters: - -``iterator_adaptor`` base class parameters ------------------------------------------- - -The *V*, *C*, *R*, and *D* parameters of the ``iterator_facade`` -used as a base class in the summary of ``iterator_adaptor`` -above are defined as follows: - -.. parsed-literal:: - - *V* = if (Value is use_default) - return iterator_traits::value_type - else - return Value - - *C* = if (CategoryOrTraversal is use_default) - return iterator_traversal::type - else - return CategoryOrTraversal - - *R* = if (Reference is use_default) - if (Value is use_default) - return iterator_traits::reference - else - return Value& - else - return Reference - - *D* = if (Difference is use_default) - return iterator_traits::difference_type - else - return Difference - -``iterator_adaptor`` usage --------------------------- - -The ``Derived`` template parameter must be a publicly derived from -``iterator_adaptor``. In order for ``Derived`` to model the -iterator concepts corresponding to -``iterator_traits::iterator_category``, the expressions -involving ``m_iterator`` in the specifications of those private -member functions of ``iterator_adaptor`` that may be called by -``iterator_facade`` in evaluating any valid expression involving ``Derived`` -in those concepts' requirements. - -``iterator_adaptor`` public operations --------------------------------------- - -``iterator_adaptor();`` - -:Requires: The ``Base`` type must be Default Constructible. -:Returns: An instance of ``iterator_adaptor`` with - ``m_iterator`` default constructed. - - -``explicit iterator_adaptor(Base iter);`` - -:Returns: An instance of ``iterator_adaptor`` with - ``m_iterator`` copy constructed from ``iter``. - -``Base base() const;`` - -:Returns: ``m_iterator`` - - -``iterator_adaptor`` protected member functions ------------------------------------------------ - -``Base const& base_reference() const;`` - -:Returns: A const reference to ``m_iterator``. - - -``Base& base_reference();`` - -:Returns: A non-const reference to ``m_iterator``. - - -``iterator_adaptor`` private member functions ---------------------------------------------- - -``typename iterator_adaptor::reference dereference() const;`` - -:Returns: ``*m_iterator`` - -:: - - template < - class OtherDerived, class OtherIterator, class V, class C, class R, class D - > - bool equal(iterator_adaptor const& x) const; - -:Returns: ``m_iterator == x.base()`` - - -``void advance(typename iterator_adaptor::difference_type n);`` - -:Effects: ``m_iterator += n;`` - -``void increment();`` - -:Effects: ``++m_iterator;`` - -``void decrement();`` - -:Effects: ``--m_iterator;`` - -:: - - template < - class OtherDerived, class OtherIterator, class V, class C, class R, class D - > - typename iterator_adaptor::difference_type distance_to( - iterator_adaptor const& y) const; - -:Returns: ``y.base() - m_iterator`` diff --git a/doc/iterator_facade.html b/doc/iterator_facade.html deleted file mode 100644 index 07ec2df..0000000 --- a/doc/iterator_facade.html +++ /dev/null @@ -1,850 +0,0 @@ - - - - - - -Iterator Facade - - - - - - - -
-

Iterator Facade

- --- - - - - - - - - - - - -
Author:David Abrahams, Jeremy Siek, Thomas Witt
Contact:dave@boost-consulting.com, jsiek@osl.iu.edu, witt@ive.uni-hannover.de
Organization:Boost Consulting, Indiana University Open Systems -Lab, University of Hanover Institute for Transport -Railway Operation and Construction
Date:2003-11-24
Copyright:Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved
- --- - - - -
abstract:iterator_facade is a base class template that implements the -interface of standard iterators in terms of a few core functions -and associated types, to be supplied by a derived iterator class.
- -
-

Overview

-
-

Motivation

- - -

While the iterator interface is rich, there is a core subset of the -interface that is necessary for all the functionality. We have -identified the following core behaviors for iterators:

-
    -
  • dereferencing
  • -
  • incrementing
  • -
  • decrementing
  • -
  • equality comparison
  • -
  • random-access motion
  • -
  • distance measurement
  • -
-

In addition to the behaviors listed above, the core interface elements -include the associated types exposed through iterator traits: -value_type, reference, difference_type, and -iterator_category.

-

Iterator facade uses the Curiously Recurring Template Pattern (CRTP) -[Cop95] so that the user can specify the behavior of -iterator_facade in a derived class. Former designs used policy -objects to specify the behavior. iterator_facade does not use policy -objects for several reasons:

-
-
    -
  1. the creation and eventual copying of the policy object may create -overhead that can be avoided with the current approach.
  2. -
  3. The policy object approach does not allow for custom constructors -on the created iterator types, an essential feature if -iterator_facade should be used in other library -implementations.
  4. -
  5. Without the use of CRTP, the standard requirement that an -iterator's operator++ returns the iterator type itself means -that all iterators generated by iterator_facade would be -specializations of iterator_facade. Cumbersome type generator -metafunctions would be needed to build new parameterized -iterators, and a separate iterator_adaptor layer would be -impossible.
  6. -
-
-
-
-

Usage

-

The user of iterator_facade derives his iterator class from a -specialization of iterator_facade and passes the derived -iterator class as iterator_facade's first template parameter. -The order of the other template parameters have been carefully -chosen to take advantage of useful defaults. For example, when -defining a constant lvalue iterator, the user can pass a -const-qualified version of the iterator's value_type as -iterator_facade's Value parameter and omit the -Reference parameter which follows.

-

The derived iterator class must define member functions implementing -the iterator's core behaviors. The following table describes -expressions which are required to be valid depending on the category -of the derived iterator type. These member functions are described -briefly below and in more detail in the iterator facade -requirements.

-
- ---- - - - - - - - - - - - - - - - - - - - - - - - - - -
ExpressionEffects
i.dereference()Access the value referred to
i.equal(j)Compare for equality with j
i.increment()Advance by one position
i.decrement()Retreat by one position
i.advance(n)Advance by n positions
i.distance_to(j)Measure the distance to j
-
- -

In addition to implementing the core interface functions, an iterator -derived from iterator_facade typically defines several -constructors. To model any of the standard iterator concepts, the -iterator must at least have a copy constructor. Also, if the iterator -type X is meant to be automatically interoperate with another -iterator type Y (as with constant and mutable iterators) then -there must be an implicit conversion from X to Y or from Y -to X (but not both), typically implemented as a conversion -constructor. Finally, if the iterator is to model Forward Traversal -Iterator or a more-refined iterator concept, a default constructor is -required.

-
-
-

Iterator Core Access

-

iterator_facade and the operator implementations need to be able -to access the core member functions in the derived class. Making the -core member functions public would expose an implementation detail to -the user. The design used here ensures that implementation details do -not appear in the public interface of the derived iterator type.

-

Preventing direct access to the core member functions has two -advantages. First, there is no possibility for the user to accidently -use a member function of the iterator when a member of the value_type -was intended. This has been an issue with smart pointer -implementations in the past. The second and main advantage is that -library implementers can freely exchange a hand-rolled iterator -implementation for one based on iterator_facade without fear of -breaking code that was accessing the public core member functions -directly.

-

In a naive implementation, keeping the derived class' core member -functions private would require it to grant friendship to -iterator_facade and each of the seven operators. In order to -reduce the burden of limiting access, iterator_core_access is -provided, a class that acts as a gateway to the core member functions -in the derived iterator class. The author of the derived class only -needs to grant friendship to iterator_core_access to make his core -member functions available to the library.

- - -

iterator_core_access will be typically implemented as an empty -class containing only private static member functions which invoke the -iterator core member functions. There is, however, no need to -standardize the gateway protocol. Note that even if -iterator_core_access used public member functions it would not -open a safety loophole, as every core member function preserves the -invariants of the iterator.

-
-
-

operator[]

-

The indexing operator for a generalized iterator presents special -challenges. A random access iterator's operator[] is only -required to return something convertible to its value_type. -Requiring that it return an lvalue would rule out currently-legal -random-access iterators which hold the referenced value in a data -member (e.g. counting_iterator), because *(p+n) is a reference -into the temporary iterator p+n, which is destroyed when -operator[] returns.

-

Writable iterators built with iterator_facade implement the -semantics required by the preferred resolution to issue 299 and -adopted by proposal n1550: the result of p[n] is a proxy object -containing a copy of p+n, and p[n] = x is equivalent to *(p -+ n) = x. This approach will work properly for any random-access -iterator regardless of the other details of its implementation. A -user who knows more about the implementation of her iterator is free -to implement an operator[] which returns an lvalue in the derived -iterator class; it will hide the one supplied by iterator_facade -from clients of her iterator.

-
-
-

operator->

-

The reference type of a readable iterator (and today's input -iterator) need not in fact be a reference, so long as it is -convertible to the iterator's value_type. When the value_type -is a class, however, it must still be possible to access members -through operator->. Therefore, an iterator whose reference -type is not in fact a reference must return a proxy containing a copy -of the referenced value from its operator->.

-

The return type for operator-> and operator[] is not -explicitly specified. Instead it requires each iterator_facade -specialization to meet the requirements of its iterator_category.

- - -- - - -
[Cop95][Coplien, 1995] Coplien, J., Curiously Recurring Template -Patterns, C++ Report, February 1995, pp. 24-27.
-
-
-
-

Tutorial Example

-

I'm working on a Tutorial example to go here.

-
-
-

Reference

-
-

Ref

-

We need to resolve the title levels here.

- - -
-template <
-    class Derived
-  , class Value
-  , class CategoryOrTraversal
-  , class Reference  = Value&
-  , class Difference = ptrdiff_t
->
-class iterator_facade {
-public:
-    typedef remove_const<Value>::type value_type;
-    typedef Reference reference;
-    typedef Value* pointer;
-    typedef Difference difference_type;
-    typedef /* see below */ iterator_category;
-
-    reference operator*() const;
-    /* see below */ operator->() const;
-    /* see below */ operator[](difference_type n) const;
-    Derived& operator++();
-    Derived operator++(int);
-    Derived& operator--();
-    Derived operator--(int);
-    Derived& operator+=(difference_type n);
-    Derived& operator-=(difference_type n);
-    Derived operator-(difference_type n) const;
-};
-
-// Comparison operators
-template <class Dr1, class V1, class TC1, class R1, class D1,
-          class Dr2, class V2, class TC2, class R2, class D2>
-typename enable_if_interoperable<Dr1, Dr2, bool>::type // exposition
-operator ==(iterator_facade<Dr1, V1, TC1, R1, D1> const& lhs,
-            iterator_facade<Dr2, V2, TC2, R2, D2> const& rhs);
-
-template <class Dr1, class V1, class TC1, class R1, class D1,
-          class Dr2, class V2, class TC2, class R2, class D2>
-typename enable_if_interoperable<Dr1, Dr2, bool>::type
-operator !=(iterator_facade<Dr1, V1, TC1, R1, D1> const& lhs,
-            iterator_facade<Dr2, V2, TC2, R2, D2> const& rhs);
-
-template <class Dr1, class V1, class TC1, class R1, class D1,
-          class Dr2, class V2, class TC2, class R2, class D2>
-typename enable_if_interoperable<Dr1, Dr2, bool>::type
-operator <(iterator_facade<Dr1, V1, TC1, R1, D1> const& lhs,
-           iterator_facade<Dr2, V2, TC2, R2, D2> const& rhs);
-
-template <class Dr1, class V1, class TC1, class R1, class D1,
-          class Dr2, class V2, class TC2, class R2, class D2>
-typename enable_if_interoperable<Dr1, Dr2, bool>::type
-operator <=(iterator_facade<Dr1, V1, TC1, R1, D1> const& lhs,
-            iterator_facade<Dr2, V2, TC2, R2, D2> const& rhs);
-
-template <class Dr1, class V1, class TC1, class R1, class D1,
-          class Dr2, class V2, class TC2, class R2, class D2>
-typename enable_if_interoperable<Dr1, Dr2, bool>::type
-operator >(iterator_facade<Dr1, V1, TC1, R1, D1> const& lhs,
-           iterator_facade<Dr2, V2, TC2, R2, D2> const& rhs);
-
-template <class Dr1, class V1, class TC1, class R1, class D1,
-          class Dr2, class V2, class TC2, class R2, class D2>
-typename enable_if_interoperable<Dr1, Dr2, bool>::type
-operator >=(iterator_facade<Dr1, V1, TC1, R1, D1> const& lhs,
-            iterator_facade<Dr2, V2, TC2, R2, D2> const& rhs);
-
-template <class Dr1, class V1, class TC1, class R1, class D1,
-          class Dr2, class V2, class TC2, class R2, class D2>
-typename enable_if_interoperable<Dr1, Dr2, bool>::type
-operator >=(iterator_facade<Dr1, V1, TC1, R1, D1> const& lhs,
-            iterator_facade<Dr2, V2, TC2, R2, D2> const& rhs);
-
-// Iterator difference
-template <class Dr1, class V1, class TC1, class R1, class D1,
-          class Dr2, class V2, class TC2, class R2, class D2>
-typename enable_if_interoperable<Dr1, Dr2, bool>::type
-operator -(iterator_facade<Dr1, V1, TC1, R1, D1> const& lhs,
-           iterator_facade<Dr2, V2, TC2, R2, D2> const& rhs);
-
-// Iterator addition
-template <class Derived, class V, class TC, class R, class D>
-Derived operator+ (iterator_facade<Derived, V, TC, R, D> const&,
-                   typename Derived::difference_type n)
-
-

The enable_if_interoperable template used above is for exposition -purposes. The member operators should be only be in an overload set -provided the derived types Dr1 and Dr2 are interoperable, -meaning that at least one of the types is convertible to the other. The -enable_if_interoperable approach uses SFINAE to take the operators -out of the overload set when the types are not interoperable. -The operators should behave as-if enable_if_interoperable -were defined to be:

-
-template <bool, typename> enable_if_interoperable_impl
-{};
-
-template <typename T> enable_if_interoperable_impl<true,T>
-{ typedef T type; };
-
-template<typename Dr1, typename Dr2, typename T>
-struct enable_if_interoperable
-  : enable_if_interoperable_impl<
-        is_convertible<Dr1,Dr2>::value || is_convertible<Dr2,Dr1>::value
-      , T
-    >
-{};
-
-
-

iterator_facade usage

-

The following table describes the typical valid expressions on -iterator_facade's Derived parameter, depending on the -iterator concept(s) it will model. The operations in the first -column must be made accessible to member functions of class -iterator_core_access.

-

In the table below, F is iterator_facade<X,V,C,R,D>, a is an -object of type X, b and c are objects of type const X, -n is an object of F::difference_type, y is a constant -object of a single pass iterator type interoperable with X, and z -is a constant object of a random access traversal iterator type -interoperable with X.

- ------ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ExpressionReturn TypeAssertion/NoteUsed to implement Iterator -Concept(s)
c.dereference()F::reference Readable Iterator, Writable -Iterator
c.equal(b)convertible to booltrue iff b and c are -equivalent.Single Pass Iterator
c.equal(y)convertible to booltrue iff c and y refer to the -same position. Implements c == y -and c != y.Single Pass Iterator
a.advance(n)unused Random Access Traversal -Iterator
a.increment()unused Incrementable Iterator
a.decrement()unused Bidirectional Traversal -Iterator
c.distance_to(b)convertible to -F::difference_typeequivalent to distance(c, b)Random Access Traversal -Iterator
c.distance_to(z)convertible to -F::difference_typeequivalent to distance(c, z). -Implements c - z, c < z, c -<= z, c > z, and c >= c.Random Access Traversal -Iterator
-
-
-

iterator_facade iterator category

-

The iterator_category member of iterator_facade<X,V,R,C,D> -is a type which satisfies the following conditions:

-
-
    -
  • if C is convertible to std::input_iterator_tag or -C is convertible to std::output_iterator_tag, -iterator_category is the same as C.

    -
  • -
  • Otherwise, if C is not convertible to -incrementable_traversal_tag, the program is ill-formed

    -
  • -
  • Otherwise:

    -
      -
    • iterator_category is convertible to the iterator -category tag or tags given by the following algorithm, and -not to any more-derived iterator category tag or tags:

      -
      -if (R is a reference type
      -    && C is convertible to forward_traversal_tag)
      -{
      -    if (C is convertible to random_access_traversal_tag)
      -        return random_access_iterator_tag
      -    else if (C is convertible to bidirectional_traversal_tag)
      -        return bidirectional_iterator_tag
      -    else
      -        return forward_traversal_tag
      -}
      -else
      -{
      -    if (C is convertible to single_pass_traversal_tag
      -        && R is convertible to V)
      -    {
      -        if (V is const)
      -            return input_iterator_tag
      -        else
      -            return input_iterator_tag and output_iterator_tag
      -    }
      -    else
      -        return output_iterator_tag
      -}
      -
      -
    • -
    • iterator_traversal<X>::type is convertible to the most -derived traversal tag type to which C is also -convertible, and not to any more-derived traversal tag type.

      -
    • -
    -
  • -
-
-
-
-

iterator_facade operations

-

The operations in this section are described in terms of operations on -the core interface of Derived which may be inaccessible -(i.e. private). The implementation should access these operations -through member functions of class iterator_core_access.

-

reference operator*() const;

- --- - - - -
Returns:static_cast<Derived const*>(this)->dereference()
-

operator->() const; (see below)

- --- - - - -
Returns:

If reference is a reference type, an object -of type pointer equal to:

-
-&static_cast<Derived const*>(this)->dereference()
-
-

Otherwise returns an object of unspecified type such that, -(*static_cast<Derived const*>(this))->m is equivalent to (w = **static_cast<Derived const*>(this), -w.m) for some temporary object w of type value_type.

-
-

unspecified operator[](difference_type n) const;

- --- - - - -
Returns:an object convertible to reference and holding a copy -p of *static_cast<Derived const*>(this) + n such that, for a constant object v of type -value_type, (*static_cast<Derived const*>(this))[n] = v is equivalent -to p = v.
-

Derived& operator++();

- --- - - - -
Effects:
-static_cast<Derived*>(this)->increment();
-return *static_cast<Derived*>(this);
-
-
-

Derived operator++(int);

- --- - - - -
Effects:
-Derived tmp(static_cast<Derived const*>(this));
-++*this;
-return tmp;
-
-
-

Derived& operator--();

- --- - - - -
Effects:
-static_cast<Derived*>(this)->decrement();
-return static_cast<Derived*>(this);
-
-
-

Derived operator--(int);

- --- - - - -
Effects:
-Derived tmp(static_cast<Derived const*>(this));
---*this;
-return tmp;
-
-
-

Derived& operator+=(difference_type n);

- --- - - - -
Effects:
-static_cast<Derived*>(this)->advance(n);
-return static_cast<Derived*>(this);
-
-
-

Derived& operator-=(difference_type n);

- --- - - - -
Effects:
-static_cast<Derived*>(this)->advance(-n);
-return static_cast<Derived*>(this);
-
-
-

Derived operator-(difference_type n) const;

- --- - - - -
Effects:
-Derived tmp(static_cast<Derived const*>(this));
-return tmp -= n;
-
-
-
-
-
-
- - - - diff --git a/doc/iterator_facade.rst b/doc/iterator_facade.rst deleted file mode 100644 index a48ede2..0000000 --- a/doc/iterator_facade.rst +++ /dev/null @@ -1,46 +0,0 @@ -++++++++++++++++ - Iterator Facade -++++++++++++++++ - -:Author: David Abrahams, Jeremy Siek, Thomas Witt -:Contact: dave@boost-consulting.com, jsiek@osl.iu.edu, witt@ive.uni-hannover.de -:organization: `Boost Consulting`_, Indiana University `Open Systems - Lab`_, University of Hanover `Institute for Transport - Railway Operation and Construction`_ -:date: $Date$ -:copyright: Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved - -.. _`Boost Consulting`: http://www.boost-consulting.com -.. _`Open Systems Lab`: http://www.osl.iu.edu -.. _`Institute for Transport Railway Operation and Construction`: http://www.ive.uni-hannover.de - -:abstract: - - .. include:: iterator_facade_abstract.rst - -.. contents:: Table of Contents - -Overview -======== - -Motivation ----------- - -.. include:: iterator_facade_body.rst - -Tutorial Example -================ - -.. include:: iterator_facade_tutorial.rst - -Reference -========= - -Ref ---- - -We need to resolve the title levels here. - -.. include:: iterator_facade_ref.rst - -.. _counting: counting_iterator.html diff --git a/doc/iterator_facade_abstract.rst b/doc/iterator_facade_abstract.rst deleted file mode 100644 index f024b9b..0000000 --- a/doc/iterator_facade_abstract.rst +++ /dev/null @@ -1,4 +0,0 @@ -``iterator_facade`` is a base class template that implements the -interface of standard iterators in terms of a few core functions -and associated types, to be supplied by a derived iterator class. - diff --git a/doc/iterator_facade_body.rst b/doc/iterator_facade_body.rst deleted file mode 100644 index 370539d..0000000 --- a/doc/iterator_facade_body.rst +++ /dev/null @@ -1,190 +0,0 @@ -.. Version 1.1 of this ReStructuredText document corresponds to - n1530_, the paper accepted by the LWG for TR1. - -.. Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All - rights reserved - - -While the iterator interface is rich, there is a core subset of the -interface that is necessary for all the functionality. We have -identified the following core behaviors for iterators: - -* dereferencing -* incrementing -* decrementing -* equality comparison -* random-access motion -* distance measurement - -In addition to the behaviors listed above, the core interface elements -include the associated types exposed through iterator traits: -``value_type``, ``reference``, ``difference_type``, and -``iterator_category``. - -Iterator facade uses the Curiously Recurring Template Pattern (CRTP) -[Cop95]_ so that the user can specify the behavior of -``iterator_facade`` in a derived class. Former designs used policy -objects to specify the behavior. ``iterator_facade`` does not use policy -objects for several reasons: - - 1. the creation and eventual copying of the policy object may create - overhead that can be avoided with the current approach. - - 2. The policy object approach does not allow for custom constructors - on the created iterator types, an essential feature if - ``iterator_facade`` should be used in other library - implementations. - - 3. Without the use of CRTP, the standard requirement that an - iterator's ``operator++`` returns the iterator type itself means - that all iterators generated by ``iterator_facade`` would be - specializations of ``iterator_facade``. Cumbersome type generator - metafunctions would be needed to build new parameterized - iterators, and a separate ``iterator_adaptor`` layer would be - impossible. - -Usage ------ - -The user of ``iterator_facade`` derives his iterator class from a -specialization of ``iterator_facade`` and passes the derived -iterator class as ``iterator_facade``\ 's first template parameter. -The order of the other template parameters have been carefully -chosen to take advantage of useful defaults. For example, when -defining a constant lvalue iterator, the user can pass a -const-qualified version of the iterator's ``value_type`` as -``iterator_facade``\ 's ``Value`` parameter and omit the -``Reference`` parameter which follows. - -The derived iterator class must define member functions implementing -the iterator's core behaviors. The following table describes -expressions which are required to be valid depending on the category -of the derived iterator type. These member functions are described -briefly below and in more detail in the iterator facade -requirements. - - +------------------------+-------------------------------+ - |Expression |Effects | - +========================+===============================+ - |``i.dereference()`` |Access the value referred to | - +------------------------+-------------------------------+ - |``i.equal(j)`` |Compare for equality with ``j``| - +------------------------+-------------------------------+ - |``i.increment()`` |Advance by one position | - +------------------------+-------------------------------+ - |``i.decrement()`` |Retreat by one position | - +------------------------+-------------------------------+ - |``i.advance(n)`` |Advance by ``n`` positions | - +------------------------+-------------------------------+ - |``i.distance_to(j)`` |Measure the distance to ``j`` | - +------------------------+-------------------------------+ - -.. Should we add a comment that a zero overhead implementation of iterator_facade - is possible with proper inlining? - -In addition to implementing the core interface functions, an iterator -derived from ``iterator_facade`` typically defines several -constructors. To model any of the standard iterator concepts, the -iterator must at least have a copy constructor. Also, if the iterator -type ``X`` is meant to be automatically interoperate with another -iterator type ``Y`` (as with constant and mutable iterators) then -there must be an implicit conversion from ``X`` to ``Y`` or from ``Y`` -to ``X`` (but not both), typically implemented as a conversion -constructor. Finally, if the iterator is to model Forward Traversal -Iterator or a more-refined iterator concept, a default constructor is -required. - - - -Iterator Core Access --------------------- - -``iterator_facade`` and the operator implementations need to be able -to access the core member functions in the derived class. Making the -core member functions public would expose an implementation detail to -the user. The design used here ensures that implementation details do -not appear in the public interface of the derived iterator type. - -Preventing direct access to the core member functions has two -advantages. First, there is no possibility for the user to accidently -use a member function of the iterator when a member of the value_type -was intended. This has been an issue with smart pointer -implementations in the past. The second and main advantage is that -library implementers can freely exchange a hand-rolled iterator -implementation for one based on ``iterator_facade`` without fear of -breaking code that was accessing the public core member functions -directly. - -In a naive implementation, keeping the derived class' core member -functions private would require it to grant friendship to -``iterator_facade`` and each of the seven operators. In order to -reduce the burden of limiting access, ``iterator_core_access`` is -provided, a class that acts as a gateway to the core member functions -in the derived iterator class. The author of the derived class only -needs to grant friendship to ``iterator_core_access`` to make his core -member functions available to the library. - -.. This is no long uptodate -thw -.. Yes it is; I made sure of it! -DWA - -``iterator_core_access`` will be typically implemented as an empty -class containing only private static member functions which invoke the -iterator core member functions. There is, however, no need to -standardize the gateway protocol. Note that even if -``iterator_core_access`` used public member functions it would not -open a safety loophole, as every core member function preserves the -invariants of the iterator. - -``operator[]`` --------------- - -The indexing operator for a generalized iterator presents special -challenges. A random access iterator's ``operator[]`` is only -required to return something convertible to its ``value_type``. -Requiring that it return an lvalue would rule out currently-legal -random-access iterators which hold the referenced value in a data -member (e.g. |counting|_), because ``*(p+n)`` is a reference -into the temporary iterator ``p+n``, which is destroyed when -``operator[]`` returns. - -.. |counting| replace:: ``counting_iterator`` - -Writable iterators built with ``iterator_facade`` implement the -semantics required by the preferred resolution to `issue 299`_ and -adopted by proposal n1550_: the result of ``p[n]`` is an object -convertible to the iterator's ``value_type``, and ``p[n] = x`` is -equivalent to ``*(p + n) = x`` (Note: This result object may be -implemented as a proxy containing a copy of ``p+n``). This approach -will work properly for any random-access iterator regardless of the -other details of its implementation. A user who knows more about -the implementation of her iterator is free to implement an -``operator[]`` that returns an lvalue in the derived iterator -class; it will hide the one supplied by ``iterator_facade`` from -clients of her iterator. - -.. _n1550: http://anubis.dkuug.dk/JTC1/SC22/WG21/docs/papers/2003/n1550.html - -.. _`issue 299`: http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-active.html#299 - -.. _`operator arrow`: - - -``operator->`` --------------- - -The ``reference`` type of a readable iterator (and today's input -iterator) need not in fact be a reference, so long as it is -convertible to the iterator's ``value_type``. When the ``value_type`` -is a class, however, it must still be possible to access members -through ``operator->``. Therefore, an iterator whose ``reference`` -type is not in fact a reference must return a proxy containing a copy -of the referenced value from its ``operator->``. - -The return type for ``operator->`` and ``operator[]`` is not -explicitly specified. Instead it requires each ``iterator_facade`` -specialization to meet the requirements of its ``iterator_category``. - - -.. [Cop95] [Coplien, 1995] Coplien, J., Curiously Recurring Template - Patterns, C++ Report, February 1995, pp. 24-27. - diff --git a/doc/iterator_facade_ref.rst b/doc/iterator_facade_ref.rst deleted file mode 100644 index c763573..0000000 --- a/doc/iterator_facade_ref.rst +++ /dev/null @@ -1,329 +0,0 @@ -.. Version 1.3 of this ReStructuredText document corresponds to - n1530_, the paper accepted by the LWG for TR1. - -.. Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All - rights reserved - - -.. parsed-literal:: - - template < - class Derived - , class Value - , class CategoryOrTraversal - , class Reference = Value& - , class Difference = ptrdiff_t - > - class iterator_facade { - public: - typedef remove_const::type value_type; - typedef Reference reference; - typedef Value* pointer; - typedef Difference difference_type; - typedef /* see below__ \*/ iterator_category; - - reference operator\*() const; - /* see below__ \*/ operator->() const; - /* see below__ \*/ operator[](difference_type n) const; - Derived& operator++(); - Derived operator++(int); - Derived& operator--(); - Derived operator--(int); - Derived& operator+=(difference_type n); - Derived& operator-=(difference_type n); - Derived operator-(difference_type n) const; - }; - - // Comparison operators - template - typename enable_if_interoperable::type // exposition - operator ==(iterator_facade const& lhs, - iterator_facade const& rhs); - - template - typename enable_if_interoperable::type - operator !=(iterator_facade const& lhs, - iterator_facade const& rhs); - - template - typename enable_if_interoperable::type - operator <(iterator_facade const& lhs, - iterator_facade const& rhs); - - template - typename enable_if_interoperable::type - operator <=(iterator_facade const& lhs, - iterator_facade const& rhs); - - template - typename enable_if_interoperable::type - operator >(iterator_facade const& lhs, - iterator_facade const& rhs); - - template - typename enable_if_interoperable::type - operator >=(iterator_facade const& lhs, - iterator_facade const& rhs); - - template - typename enable_if_interoperable::type - operator >=(iterator_facade const& lhs, - iterator_facade const& rhs); - - // Iterator difference - template - typename enable_if_interoperable::type - operator -(iterator_facade const& lhs, - iterator_facade const& rhs); - - // Iterator addition - template - Derived operator+ (iterator_facade const&, - typename Derived::difference_type n) - - -__ `facade iterator category`_ - -__ `operator arrow`_ - -__ brackets_ - -The ``enable_if_interoperable`` template used above is for exposition -purposes. The member operators should be only be in an overload set -provided the derived types ``Dr1`` and ``Dr2`` are interoperable, -meaning that at least one of the types is convertible to the other. The -``enable_if_interoperable`` approach uses SFINAE to take the operators -out of the overload set when the types are not interoperable. -The operators should behave *as-if* ``enable_if_interoperable`` -were defined to be:: - - template enable_if_interoperable_impl - {}; - - template enable_if_interoperable_impl - { typedef T type; }; - - template - struct enable_if_interoperable - : enable_if_interoperable_impl< - is_convertible::value || is_convertible::value - , T - > - {}; - - -``iterator_facade`` usage -......................... - -The following table describes the typical valid expressions on -``iterator_facade``\ 's ``Derived`` parameter, depending on the -iterator concept(s) it will model. The operations in the first -column must be made accessible to member functions of class -``iterator_core_access``. - -In the table below, ``F`` is ``iterator_facade``, ``a`` is an -object of type ``X``, ``b`` and ``c`` are objects of type ``const X``, -``n`` is an object of ``F::difference_type``, ``y`` is a constant -object of a single pass iterator type interoperable with ``X``, and ``z`` -is a constant object of a random access traversal iterator type -interoperable with ``X``. - -+--------------------+----------------------+-------------------------------------+---------------------------+ -|Expression |Return Type |Assertion/Note |Used to implement Iterator | -| | | |Concept(s) | -+====================+======================+=====================================+===========================+ -|``c.dereference()`` |``F::reference`` | |Readable Iterator, Writable| -| | | |Iterator | -+--------------------+----------------------+-------------------------------------+---------------------------+ -|``c.equal(b)`` |convertible to bool |true iff ``b`` and ``c`` are |Single Pass Iterator | -| | |equivalent. | | -+--------------------+----------------------+-------------------------------------+---------------------------+ -|``c.equal(y)`` |convertible to bool |true iff ``c`` and ``y`` refer to the|Single Pass Iterator | -| | |same position. Implements ``c == y``| | -| | |and ``c != y``. | | -+--------------------+----------------------+-------------------------------------+---------------------------+ -|``a.advance(n)`` |unused | |Random Access Traversal | -| | | |Iterator | -+--------------------+----------------------+-------------------------------------+---------------------------+ -|``a.increment()`` |unused | |Incrementable Iterator | -+--------------------+----------------------+-------------------------------------+---------------------------+ -|``a.decrement()`` |unused | |Bidirectional Traversal | -| | | |Iterator | -+--------------------+----------------------+-------------------------------------+---------------------------+ -|``c.distance_to(b)``|convertible to |equivalent to ``distance(c, b)`` |Random Access Traversal | -| |``F::difference_type``| |Iterator | -+--------------------+----------------------+-------------------------------------+---------------------------+ -|``c.distance_to(z)``|convertible to |equivalent to ``distance(c, z)``. |Random Access Traversal | -| |``F::difference_type``|Implements ``c - z``, ``c < z``, ``c |Iterator | -| | |<= z``, ``c > z``, and ``c >= c``. | | -+--------------------+----------------------+-------------------------------------+---------------------------+ - -.. _facade iterator category: - -``iterator_facade`` iterator category -..................................... - -The ``iterator_category`` member of ``iterator_facade`` -is a type which satisfies the following conditions: - - * if ``C`` is convertible to ``std::input_iterator_tag`` or - ``C`` is convertible to ``std::output_iterator_tag``, - ``iterator_category`` is the same as ``C``. - - * Otherwise, if ``C`` is not convertible to - ``incrementable_traversal_tag``, the program is ill-formed - - * Otherwise: - - - ``iterator_category`` is convertible to the iterator - category tag or tags given by the following algorithm, and - not to any more-derived iterator category tag or tags:: - - if (R is a reference type - && C is convertible to forward_traversal_tag) - { - if (C is convertible to random_access_traversal_tag) - return random_access_iterator_tag - else if (C is convertible to bidirectional_traversal_tag) - return bidirectional_iterator_tag - else - return forward_traversal_tag - } - else - { - if (C is convertible to single_pass_traversal_tag - && R is convertible to V) - { - if (V is const) - return input_iterator_tag - else - return input_iterator_tag and output_iterator_tag - } - else - return output_iterator_tag - } - - - ``iterator_traversal::type`` is convertible to the most - derived traversal tag type to which ``C`` is also - convertible, and not to any more-derived traversal tag type. - - -``iterator_facade`` operations -.............................. - -The operations in this section are described in terms of operations on -the core interface of ``Derived`` which may be inaccessible -(i.e. private). The implementation should access these operations -through member functions of class ``iterator_core_access``. - -``reference operator*() const;`` - -:Returns: ``static_cast(this)->dereference()`` - -``operator->() const;`` (see below__) - -__ `operator arrow`_ - -:Returns: If ``reference`` is a reference type, an object - of type ``pointer`` equal to:: - - &static_cast(this)->dereference() - - Otherwise returns an object of unspecified type such that, - ``(*static_cast(this))->m`` is equivalent to ``(w = **static_cast(this), - w.m)`` for some temporary object ``w`` of type ``value_type``. - -.. _brackets: - -*unspecified* ``operator[](difference_type n) const;`` - -:Returns: an object convertible to ``value_type``. For constant - objects ``v`` of type ``value_type``, and ``n`` of type - ``difference_type``, and reference ``p`` equal to - ``*static_cast(this)``, ``(*this)[n] = v`` is - equivalent to ``*(p+ n) = v``, and ``static_cast((*this)[n])`` is equivalent to - ``static_cast(*(p+n))`` - - - -``Derived& operator++();`` - -:Effects: - - :: - - static_cast(this)->increment(); - return *static_cast(this); - -``Derived operator++(int);`` - -:Effects: - - :: - - Derived tmp(static_cast(this)); - ++*this; - return tmp; - - -``Derived& operator--();`` - -:Effects: - - :: - - static_cast(this)->decrement(); - return static_cast(this); - - -``Derived operator--(int);`` - -:Effects: - - :: - - Derived tmp(static_cast(this)); - --*this; - return tmp; - - -``Derived& operator+=(difference_type n);`` - -:Effects: - - :: - - static_cast(this)->advance(n); - return static_cast(this); - - -``Derived& operator-=(difference_type n);`` - -:Effects: - - :: - - static_cast(this)->advance(-n); - return static_cast(this); - - -``Derived operator-(difference_type n) const;`` - -:Effects: - - :: - - Derived tmp(static_cast(this)); - return tmp -= n; - - - diff --git a/doc/iterator_facade_tutorial.rst b/doc/iterator_facade_tutorial.rst deleted file mode 100755 index 3437bef..0000000 --- a/doc/iterator_facade_tutorial.rst +++ /dev/null @@ -1,73 +0,0 @@ -.. Copyright David Abrahams 2004. Use, modification and distribution is -.. subject to the Boost Software License, Version 1.0. (See accompanying -.. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -Introduction ------------- - -In this section we'll walk through the implementation of a few -iterators using ``iterator_facade``, based around the simple -example of a linked list of polymorphic objects. - -The Problem ------------ - -Say we've written a polymorphic linked list node as follows:: - - # include - - struct node_base - { - node_base() : m_next(0) {} - - virtual ~node_base() { delete m_next; } - - node_base* next() const { return m_next; } - - // print to the stream - virtual void print(std::ostream& s) const = 0; - - // double the value - virtual void twice() = 0; - - void append(node_base* p) - { - if (m_next) - m_next->append(p); - else - m_next = p; - } - - private: - node_base* m_next; - }; - -Lists can hold objects of different types by linking together -specializations of the following template:: - - template - struct node : node_base - { - node(T x) - : m_value(x) - {} - - void print(std::ostream& s) const { s << this->m_value; } - void twice() { m_value += m_value; } - - private: - T m_value; - }; - -And we can print any node using the following streaming operator:: - - inline std::ostream& operator<<(std::ostream& s, node_base const& n) - { - n.print(s); - return s; - } - - -.. sidebar:: Note - - This is in progress; check the ../example directory for code. \ No newline at end of file diff --git a/doc/new-iter-concepts.html b/doc/new-iter-concepts.html deleted file mode 100755 index 8ea5c49..0000000 --- a/doc/new-iter-concepts.html +++ /dev/null @@ -1,1082 +0,0 @@ - - - - - - -New Iterator Concepts - - - - - - - -
-

New Iterator Concepts

- --- - - - - - - - - - - - - - -
Author:David Abrahams, Jeremy Siek, Thomas Witt
Contact:dave@boost-consulting.com, jsiek@osl.iu.edu, witt@acm.org
Organization:Boost Consulting, Indiana University Open -Systems Lab, University of Hanover Institute for -Transport Railway Operation and Construction
Date:2003-12-02
Number:This is a revised version of n1550=03-0133, which was -accepted for Technical Report 1 by the C++ standard -committee's library working group. This proposal is a -revision of paper n1297, n1477, and n1531.
Copyright:Copyright David Abrahams, Jeremy Siek, and Thomas Witt -2003. All rights reserved
- - --- - - - -
Abstract:We propose a new system of iterator concepts that treat -access and positioning independently. This allows the -concepts to more closely match the requirements -of algorithms and provides better categorizations -of iterators that are used in practice.
- -
-

Motivation

-

The standard iterator categories and requirements are flawed because -they use a single hierarchy of concepts to address two orthogonal -issues: iterator traversal and value access. As a result, many -algorithms with requirements expressed in terms of the iterator -categories are too strict. Also, many real-world iterators can not be -accurately categorized. A proxy-based iterator with random-access -traversal, for example, may only legally have a category of "input -iterator", so generic algorithms are unable to take advantage of its -random-access capabilities. The current iterator concept hierarchy is -geared towards iterator traversal (hence the category names), while -requirements that address value access sneak in at various places. The -following table gives a summary of the current value access -requirements in the iterator categories.

- ---- - - - - - - - - - - - - - - - - - - -
Value Access Requirements in Existing Iterator Categories
Output Iterator*i = a
Input Iterator*i is convertible to T
Forward Iterator*i is T& (or const T& once issue 200 -is resolved)
Random Access Iteratori[n] is convertible to T (also i[n] = t -is required for mutable iterators once issue 299 -is resolved)
-

Because iterator traversal and value access are mixed together in a -single hierarchy, many useful iterators can not be appropriately -categorized. For example, vector<bool>::iterator is almost a -random access iterator, but the return type is not bool& (see -issue 96 and Herb Sutter's paper J16/99-0008 = WG21 -N1185). Therefore, the iterators of vector<bool> only meet the -requirements of input iterator and output iterator. This is so -nonintuitive that the C++ standard contradicts itself on this point. -In paragraph 23.2.4/1 it says that a vector is a sequence that -supports random access iterators.

-

Another difficult-to-categorize iterator is the transform iterator, an -adaptor which applies a unary function object to the dereferenced -value of the some underlying iterator (see transform_iterator). -For unary functions such as times, the return type of -operator* clearly needs to be the result_type of the function -object, which is typically not a reference. Because random access -iterators are required to return lvalues from operator*, if you -wrap int* with a transform iterator, you do not get a random -access iterator as might be expected, but an input iterator.

-

A third example is found in the vertex and edge iterators of the -Boost Graph Library. These iterators return vertex and edge -descriptors, which are lightweight handles created on-the-fly. They -must be returned by-value. As a result, their current standard -iterator category is input_iterator_tag, which means that, -strictly speaking, you could not use these iterators with algorithms -like min_element(). As a temporary solution, the concept -Multi-Pass Input Iterator was introduced to describe the vertex and -edge descriptors, but as the design notes for the concept suggest, a -better solution is needed.

-

In short, there are many useful iterators that do not fit into the -current standard iterator categories. As a result, the following bad -things happen:

-
    -
  • Iterators are often mis-categorized.
  • -
  • Algorithm requirements are more strict than necessary, because they -cannot separate the need for random access or bidirectional -traversal from the need for a true reference return type.
  • -
-
-
-

Impact on the Standard

-

This proposal for TR1 is a pure extension. Further, the new iterator -concepts are backward-compatible with the old iterator requirements, -and old iterators are forward-compatible with the new iterator -concepts. That is to say, iterators that satisfy the old requirements -also satisfy appropriate concepts in the new system, and iterators -modeling the new concepts will automatically satisfy the appropriate -old requirements.

- - -

Note that as currently specified, istreambuf_iterator doesn't -meet the Readable Iterator requirements because its value_type -is not convertible to its reference type. We believe this to -be a defect in the standard; it should be fixed by changing its -reference type from value_type& to value_type const&.

-
-

Possible (but not proposed) Changes to the Working Paper

-

The extensions in this paper suggest several changes we might make -to the working paper for the next standard. These changes are not -a formal part of this proposal for TR1.

-
-

Changes to Algorithm Requirements

-

The algorithms in the standard library could benefit from the new -iterator concepts because the new concepts provide a more accurate way -to express their type requirements. The result is algorithms that are -usable in more situations and have fewer type requirements.

-

For the next working paper (but not for TR1), the committee should -consider the following changes to the type requirements of -algorithms. These changes are phrased as phrased as textual -substitutions, listing the algorithms to which each textual -substitution applies.

-

Forward Iterator -> Forward Traversal Iterator and Readable Iterator

-
-find_end, adjacent_find, search, search_n, rotate_copy, -lower_bound, upper_bound, equal_range, binary_search, -min_element, max_element
-

Forward Iterator (1) -> Single Pass Iterator and Readable Iterator, -Forward Iterator (2) -> Forward Traversal Iterator and Readable Iterator

-
-find_first_of
-

Forward Iterator -> Readable Iterator and Writable Iterator

-
-iter_swap
-

Forward Iterator -> Single Pass Iterator and Writable Iterator

-
-fill, generate
-

Forward Iterator -> Forward Traversal Iterator and Swappable Iterator

-
-rotate
-

Forward Iterator (1) -> Swappable Iterator and Single Pass Iterator, -Forward Iterator (2) -> Swappable Iterator and Incrementable Iterator

-
-swap_ranges
-
-
Forward Iterator -> Forward Traversal Iterator and Readable Iterator and Writable Iterator
-
remove, remove_if, unique
-
-

Forward Iterator -> Single Pass Iterator and Readable Iterator and Writable Iterator

-
-replace, replace_if
-
-
Bidirectional Iterator -> Bidirectional Traversal Iterator and Swappable Iterator
-
reverse
-
Bidirectional Iterator -> Bidirectional Traversal Iterator and Readable and Swappable Iterator
-
partition
-
-

Bidirectional Iterator (1) -> Bidirectional Traversal Iterator and Readable Iterator, -Bidirectional Iterator (2) -> Bidirectional Traversal Iterator and Writable Iterator

-
-copy_backwards
-
-
Bidirectional Iterator -> Bidirectional Traversal Iterator and Swappable Iterator and Readable Iterator
-
next_permutation, prev_permutation
-
Bidirectional Iterator -> Bidirectional Traversal Iterator and Readable Iterator and Writable Iterator
-
stable_partition, inplace_merge
-
Bidirectional Iterator -> Bidirectional Traversal Iterator and Readable Iterator
-
reverse_copy
-
Random Access Iterator -> Random Access Traversal Iterator and Readable and Writable Iterator
-
random_shuffle, sort, stable_sort, partial_sort, nth_element, push_heap, pop_heap -make_heap, sort_heap
-
Input Iterator (2) -> Incrementable Iterator and Readable Iterator
-
equal, mismatch
-
Input Iterator (2) -> Incrementable Iterator and Readable Iterator
-
transform
-
-
-
-

Deprecations

-

For the next working paper (but not for TR1), the committee should -consider deprecating the old iterator tags, and -std::iterator_traits, since it will be superceded by individual -traits metafunctions.

-
-
-

vector<bool>

-

For the next working paper (but not for TR1), the committee should -consider reclassifying vector<bool>::iterator as a Random -Access Traversal Iterator and Readable Iterator and Writable -Iterator.

-
-
-
-
-

Design

-

The iterator requirements are to be separated into two groups. One set -of concepts handles the syntax and semantics of value access:

-
    -
  • Readable Iterator
  • -
  • Writable Iterator
  • -
  • Swappable Iterator
  • -
  • Lvalue Iterator
  • -
-

The access concepts describe requirements related to operator* and -operator->, including the value_type, reference, and -pointer associated types.

-

The other set of concepts handles traversal:

-
    -
  • Incrementable Iterator
  • -
  • Single Pass Iterator
  • -
  • Forward Traversal Iterator
  • -
  • Bidirectional Traversal Iterator
  • -
  • Random Access Traversal Iterator
  • -
-

The refinement relationships for the traversal concepts are in the -following diagram.

-

traversal.png

-

In addition to the iterator movement operators, such as -operator++, the traversal concepts also include requirements on -position comparison such as operator== and operator<. The -reason for the fine grain slicing of the concepts into the -Incrementable and Single Pass is to provide concepts that are exact -matches with the original input and output iterator requirements.

-

The relationship between the new iterator concepts and the old are -given in the following diagram.

-

oldeqnew.png

-

Like the old iterator requirements, we provide tags for purposes of -dispatching based on the traversal concepts. The tags are related via -inheritance so that a tag is convertible to another tag if the concept -associated with the first tag is a refinement of the second tag.

-

Our design reuses iterator_traits<Iter>::iterator_category to -indicate an iterator's traversal capability. To specify -capabilities not captured by any old-style iterator category, an -iterator designer can use an iterator_category type that is -convertible to both the the most-derived old iterator category tag -which fits, and the appropriate new iterator traversal tag.

- -

We do not provide tags for the purposes of dispatching based on the -access concepts, in part because we could not find a way to -automatically infer the right access tags for old-style iterators. -An iterator's writability may be dependent on the assignability of -its value_type and there's no known way to detect whether an -arbitrary type is assignable. Fortunately, the need for -dispatching based on access capability is not as great as the need -for dispatching based on traversal capability.

-

A difficult design decision concerned the operator[]. The direct -approach for specifying operator[] would have a return type of -reference; the same as operator*. However, going in this -direction would mean that an iterator satisfying the old Random Access -Iterator requirements would not necessarily be a model of Readable or -Writable Lvalue Iterator. Instead we have chosen a design that -matches the preferred resolution of issue 299: operator[] is -only required to return something convertible to the value_type -(for a Readable Iterator), and is required to support assignment -i[n] = t (for a Writable Iterator).

-
-
-

Proposed Text

-
-

Addition to [lib.iterator.requirements]

-
-

Iterator Value Access Concepts [lib.iterator.value.access]

-

In the tables below, X is an iterator type, a is a constant -object of type X, R is -std::iterator_traits<X>::reference, T is -std::iterator_traits<X>::value_type, and v is a constant -object of type T.

-
-

Readable Iterators [lib.readable.iterators]

-

A class or built-in type X models the Readable Iterator concept -for the value type T if the following expressions are valid and -respect the stated semantics. U is the type of any specified -member of type T.

- ----- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Readable Iterator Requirements (in addition to CopyConstructible)
ExpressionReturn TypeNote/Precondition
iterator_traits<X>::value_typeTAny non-reference, -non-cv-qualified type
iterator_traits<X>::referenceR, Convertible to -T 
*aConvertible to R, -Convertible to Tpre: a is -dereferenceable. If a -== b then *a is -equivalent to *b
static_cast<T>( -static_cast<R>(*a) )Tequivalent to -static_cast<T>(*a)
a->mU&pre: (*a).m is -well-defined. Equivalent -to (*a).m
- -
-
-

Writable Iterators [lib.writable.iterators]

-

A class or built-in type X models the Writable Iterator concept -if the following expressions are valid and respect the stated -semantics. Writable Iterators have an associated set of value types.

- ----- - - - - - - - - - - - - - - -
Writable Iterator Requirements (in addition to CopyConstructible)
ExpressionReturn TypePrecondition
*a = o pre: The type of o -is in the set of -value types of X
-
-
-

Swappable Iterators [lib.swappable.iterators]

-

A class or built-in type X models the Swappable Iterator concept -if the following expressions are valid and respect the stated -semantics.

- ----- - - - - - - - - - - - - - - -
Swappable Iterator Requirements (in addition to CopyConstructible)
ExpressionReturn TypePostcondition
iter_swap(a, b)voidthe pointed to values are -exchanged
-
-
[Note: An iterator that is a model of the Readable and Writable Iterator concepts
-
is also a model of Swappable Iterator. --end note]
-
-
-
-

Lvalue Iterators [lib.lvalue.iterators]

-

The Lvalue Iterator concept adds the requirement that the -reference type be a reference to the value type of the iterator.

- ----- - - - - - - - - - - - - - - -
Lvalue Iterator Requirements
ExpressionReturn TypeAssertion
iterator_traits<X>::referenceT&T is cv -iterator_traits<X>::value_type -where cv is an optional -cv-qualification
-
-
-
-

Iterator Traversal Concepts [lib.iterator.traversal]

-

In the tables below, X is an iterator type, a and b are -constant objects of type X, r and s are mutable objects of -type X, T is std::iterator_traits<X>::value_type, and -v is a constant object of type T.

-
-

Incrementable Iterators [lib.incrementable.iterators]

-

A class or built-in type X models the Incrementable Iterator -concept if the following expressions are valid and respect the stated -semantics.

- ----- - - - - - - - - - - - - - - - - - - - - - - -
Incrementable Iterator Requirements (in addition to Assignable, Copy Constructible)
ExpressionReturn TypeAssertion/Semantics
++rX&&r == &++r
r++X
-{
-   X tmp = r;
-   ++r;
-   return tmp;
-}
-
-
traversal_category<X>::typeConvertible to -incrementable_traversal_tag 
- -
-
-

Single Pass Iterators [lib.single.pass.iterators]

-

A class or built-in type X models the Single Pass Iterator -concept if the following expressions are valid and respect the stated -semantics.

- ----- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Single Pass Iterator Requirements (in addition to Incrementable Iterator and Equality -Comparable)
ExpressionReturn TypeAssertion/Semantics / -Pre-/Post-condition
++rX&pre: r is -dereferenceable; post: -r is dereferenceable or -r is past-the-end
a == bconvertible to bool== is an equivalence -relation over its domain
a != bconvertible to bool!(a == b)
traversal_category<X>::typeConvertible to -single_pass_traversal_tag 
- -
-
-

Forward Traversal Iterators [lib.forward.traversal.iterators]

-

A class or built-in type X models the Forward Traversal Iterator -concept if the following expressions are valid and respect the stated -semantics.

- ----- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Forward Traversal Iterator Requirements (in addition to Single Pass Iterator)
ExpressionReturn TypeAssertion/Note
X u;X&note: u may -have a singular -value.
++rX&r == s and -r is -dereferenceable -implies ++r -== ++s.
iterator_traits<X>::difference_typeA signed integral type representing -the distance between iterators 
traversal_category<X>::typeConvertible to -forward_traversal_tag 
- -
-
-

Bidirectional Traversal Iterators [lib.bidirectional.traversal.iterators]

-

A class or built-in type X models the Bidirectional Traversal -Iterator concept if the following expressions are valid and respect -the stated semantics.

- ----- - - - - - - - - - - - - - - - - - - - - - - -
Bidirectional Traversal Iterator Requirements (in addition to Forward Traversal Iterator)
ExpressionReturn TypeAssertion/Semantics / -Pre-/Post-condition
--rX&pre: there exists -s such that r -== ++s. post: -s is -dereferenceable. ---(++r) == r. ---r == --s -implies r == -s. &r == &--r.
r--convertible to const X&
-{
-  X tmp = r;
-  --r;
-  return tmp;
-}
-
-
traversal_category<X>::typeConvertible to -bidirectional_traversal_tag 
- -
-
-

Random Access Traversal Iterators [lib.random.access.traversal.iterators]

-

A class or built-in type X models the Random Access Traversal -Iterator concept if the following expressions are valid and respect -the stated semantics. In the table below, Distance is -iterator_traits<X>::difference_type and n represents a -constant object of type Distance.

- ------ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Random Access Traversal Iterator Requirements (in addition to Bidirectional Traversal Iterator)
ExpressionReturn TypeOperational SemanticsAssertion/ -Precondition
r += nX&
-{
-  Distance m = n;
-  if (m >= 0)
-    while (m--)
-      ++r;
-  else
-    while (m++)
-      --r;
-  return r;
-}
-
-
 
a + n, n + aX{ X tmp = a; return tmp -+= n; } 
r -= nX&return r += -n 
a - nX{ X tmp = a; return tmp --= n; } 
b - aDistancea < b ?  distance(a,b) -: -distance(b,a)pre: there exists a -value n of -Distance such that -a + n == b. b -== a + (b - a).
a[n]convertible to T*(a + n)pre: a is a readable -iterator
a[n] = vconvertible to T*(a + n) = vpre: a is a writable -iterator
a < bconvertible to boolb - a > 0< is a total -ordering relation
a > bconvertible to boolb < a> is a total -ordering relation
a >= bconvertible to bool!(a < b) 
a <= bconvertible to bool!(a > b) 
traversal_category<X>::typeConvertible to -random_access_traversal_tag  
- -
-
-
-
-

Addition to [lib.iterator.synopsis]

-
-// lib.iterator.traits, traits and tags
-template <class Iterator> struct is_readable_iterator;
-template <class Iterator> struct iterator_traversal;
-
-struct incrementable_traversal_tag { };
-struct single_pass_traversal_tag : incrementable_traversal_tag { };
-struct forward_traversal_tag : single_pass_traversal_tag { };
-struct bidirectional_traversal_tag : forward_traversal_tag { };
-struct random_access_traversal_tag : bidirectional_traversal_tag { };
-
-
-
-

Addition to [lib.iterator.traits]

-

The is_readable_iterator and iterator_traversal class -templates satisfy the UnaryTypeTrait requirements.

-

Given an iterator type X, is_readable_iterator<X>::value -yields true if, for an object a of type X, *a is -convertible to iterator_traits<X>::value_type, and false -otherwise.

-

iterator_traversal<X>::value_type is defined to be:

-
-traversal-category(X) =
-    cat = iterator_traits<X>::iterator_category;
-    if (cat is convertible to incrementable_traversal_tag)
-        return cat;
-    else if (cat is convertible to random_access_iterator_tag)
-        return random_access_traversal_tag;
-    else if (cat is convertible to bidirectional_iterator_tag)
-        return bidirectional_traversal_tag;
-    else if (cat is convertible to forward_iterator_tag)
-        return forward_traversal_tag;
-    else if (cat is convertible to input_iterator_tag)
-        return single_pass_traversal_tag;
-    else if (cat is convertible to output_iterator_tag)
-        return incrementable_traversal_tag;
-    else
-        the program is ill-formed
-
-
-
-
-

Footnotes

-

The UnaryTypeTrait concept is defined in n1519; the LWG added the -requirement that specializations are derived from their nested -::type.

- -
-
- - - - diff --git a/doc/new-iter-concepts.rst b/doc/new-iter-concepts.rst deleted file mode 100644 index 027e13d..0000000 --- a/doc/new-iter-concepts.rst +++ /dev/null @@ -1,730 +0,0 @@ -++++++++++++++++++++++ - New Iterator Concepts -++++++++++++++++++++++ - -.. Version 1.25 of this ReStructuredText document is the same as - n1550_, the paper accepted by the LWG. - -:Author: David Abrahams, Jeremy Siek, Thomas Witt -:Contact: dave@boost-consulting.com, jsiek@osl.iu.edu, witt@acm.org -:organization: `Boost Consulting`_, Indiana University `Open - Systems Lab`_, University of Hanover `Institute for - Transport Railway Operation and Construction`_ -:date: $Date$ - -:Number: This is a revised version of n1550_\ =03-0133, which was - accepted for Technical Report 1 by the C++ standard - committee's library working group. This proposal is a - revision of paper n1297_, n1477_, and n1531_. - -:copyright: Copyright David Abrahams, Jeremy Siek, and Thomas Witt - 2003. All rights reserved - -.. _`Boost Consulting`: http://www.boost-consulting.com -.. _`Open Systems Lab`: http://www.osl.iu.edu - -.. _`Institute for Transport Railway Operation and Construction`: - http://www.ive.uni-hannover.de - -:Abstract: We propose a new system of iterator concepts that treat - access and positioning independently. This allows the - concepts to more closely match the requirements - of algorithms and provides better categorizations - of iterators that are used in practice. - -.. contents:: Table of Contents - -.. _n1297: http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2001/n1297.html -.. _n1477: http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1477.html -.. _n1531: http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1531.html -.. _n1550: http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1550.html - -============ - Motivation -============ - -The standard iterator categories and requirements are flawed because -they use a single hierarchy of concepts to address two orthogonal -issues: *iterator traversal* and *value access*. As a result, many -algorithms with requirements expressed in terms of the iterator -categories are too strict. Also, many real-world iterators can not be -accurately categorized. A proxy-based iterator with random-access -traversal, for example, may only legally have a category of "input -iterator", so generic algorithms are unable to take advantage of its -random-access capabilities. The current iterator concept hierarchy is -geared towards iterator traversal (hence the category names), while -requirements that address value access sneak in at various places. The -following table gives a summary of the current value access -requirements in the iterator categories. - -+------------------------------------------------------------------------------+ -|Value Access Requirements in Existing Iterator Categories | -+========================+=====================================================+ -|Output Iterator |``*i = a`` | -+------------------------+-----------------------------------------------------+ -|Input Iterator |``*i`` is convertible to ``T`` | -+------------------------+-----------------------------------------------------+ -|Forward Iterator |``*i`` is ``T&`` (or ``const T&`` once `issue 200`_ | -| |is resolved) | -+------------------------+-----------------------------------------------------+ -|Random Access Iterator |``i[n]`` is convertible to ``T`` (also ``i[n] = t`` | -| |is required for mutable iterators once `issue 299`_ | -| |is resolved) | -+------------------------+-----------------------------------------------------+ - -.. _issue 200: http://anubis.dkuug.dk/JTC1/SC22/WG21/docs/lwg-active.html#200 -.. _issue 299: http://anubis.dkuug.dk/JTC1/SC22/WG21/docs/lwg-active.html#299 - - -Because iterator traversal and value access are mixed together in a -single hierarchy, many useful iterators can not be appropriately -categorized. For example, ``vector::iterator`` is almost a -random access iterator, but the return type is not ``bool&`` (see -`issue 96`_ and Herb Sutter's paper J16/99-0008 = WG21 -N1185). Therefore, the iterators of ``vector`` only meet the -requirements of input iterator and output iterator. This is so -nonintuitive that the C++ standard contradicts itself on this point. -In paragraph 23.2.4/1 it says that a ``vector`` is a sequence that -supports random access iterators. - -.. _issue 96: http://anubis.dkuug.dk/JTC1/SC22/WG21/docs/lwg-active.html#96 - -Another difficult-to-categorize iterator is the transform iterator, an -adaptor which applies a unary function object to the dereferenced -value of the some underlying iterator (see `transform_iterator`_). -For unary functions such as ``times``, the return type of -``operator*`` clearly needs to be the ``result_type`` of the function -object, which is typically not a reference. Because random access -iterators are required to return lvalues from ``operator*``, if you -wrap ``int*`` with a transform iterator, you do not get a random -access iterator as might be expected, but an input iterator. - -.. _`transform_iterator`: http://www.boost.org/libs/utility/transform_iterator.htm - -A third example is found in the vertex and edge iterators of the -`Boost Graph Library`_. These iterators return vertex and edge -descriptors, which are lightweight handles created on-the-fly. They -must be returned by-value. As a result, their current standard -iterator category is ``input_iterator_tag``, which means that, -strictly speaking, you could not use these iterators with algorithms -like ``min_element()``. As a temporary solution, the concept -`Multi-Pass Input Iterator`_ was introduced to describe the vertex and -edge descriptors, but as the design notes for the concept suggest, a -better solution is needed. - -.. _Boost Graph Library: http://www.boost.org/libs/graph/doc/table_of_contents.html -.. _Multi-Pass Input Iterator: http://www.boost.org/libs/utility/MultiPassInputIterator.html - -In short, there are many useful iterators that do not fit into the -current standard iterator categories. As a result, the following bad -things happen: - -- Iterators are often mis-categorized. - -- Algorithm requirements are more strict than necessary, because they - cannot separate the need for random access or bidirectional - traversal from the need for a true reference return type. - - -======================== - Impact on the Standard -======================== - -This proposal for TR1 is a pure extension. Further, the new iterator -concepts are backward-compatible with the old iterator requirements, -and old iterators are forward-compatible with the new iterator -concepts. That is to say, iterators that satisfy the old requirements -also satisfy appropriate concepts in the new system, and iterators -modeling the new concepts will automatically satisfy the appropriate -old requirements. - -.. I think we need to say something about the resolution to allow - convertibility to any of the old-style tags as a TR issue (hope it - made it). -DWA - -.. Hmm, not sure I understand. Are you talking about whether a - standards conforming input iterator is allowed to have - a tag that is not input_iterator_tag but that - is convertible to input_iterator_tag? -JGS - -Note that as currently specified, ``istreambuf_iterator`` doesn't -meet the Readable Iterator requirements because its ``value_type`` -is not convertible to its ``reference`` type. We believe this to -be a defect in the standard; it should be fixed by changing its -``reference`` type from ``value_type&`` to ``value_type const&``. - -Possible (but not proposed) Changes to the Working Paper -======================================================== - -The extensions in this paper suggest several changes we might make -to the working paper for the next standard. These changes are not -a formal part of this proposal for TR1. - -Changes to Algorithm Requirements -+++++++++++++++++++++++++++++++++ - -The algorithms in the standard library could benefit from the new -iterator concepts because the new concepts provide a more accurate way -to express their type requirements. The result is algorithms that are -usable in more situations and have fewer type requirements. - -For the next working paper (but not for TR1), the committee should -consider the following changes to the type requirements of -algorithms. These changes are phrased as phrased as textual -substitutions, listing the algorithms to which each textual -substitution applies. - -Forward Iterator -> Forward Traversal Iterator and Readable Iterator - - ``find_end, adjacent_find, search, search_n, rotate_copy, - lower_bound, upper_bound, equal_range, binary_search, - min_element, max_element`` - -Forward Iterator (1) -> Single Pass Iterator and Readable Iterator, -Forward Iterator (2) -> Forward Traversal Iterator and Readable Iterator - - ``find_first_of`` - -Forward Iterator -> Readable Iterator and Writable Iterator - - ``iter_swap`` - -Forward Iterator -> Single Pass Iterator and Writable Iterator - - ``fill, generate`` - -Forward Iterator -> Forward Traversal Iterator and Swappable Iterator - - ``rotate`` - -Forward Iterator (1) -> Swappable Iterator and Single Pass Iterator, -Forward Iterator (2) -> Swappable Iterator and Incrementable Iterator - - ``swap_ranges`` - -Forward Iterator -> Forward Traversal Iterator and Readable Iterator and Writable Iterator - ``remove, remove_if, unique`` - -Forward Iterator -> Single Pass Iterator and Readable Iterator and Writable Iterator - - ``replace, replace_if`` - -Bidirectional Iterator -> Bidirectional Traversal Iterator and Swappable Iterator - ``reverse`` - -Bidirectional Iterator -> Bidirectional Traversal Iterator and Readable and Swappable Iterator - ``partition`` - -Bidirectional Iterator (1) -> Bidirectional Traversal Iterator and Readable Iterator, -Bidirectional Iterator (2) -> Bidirectional Traversal Iterator and Writable Iterator - - ``copy_backwards`` - -Bidirectional Iterator -> Bidirectional Traversal Iterator and Swappable Iterator and Readable Iterator - ``next_permutation, prev_permutation`` - -Bidirectional Iterator -> Bidirectional Traversal Iterator and Readable Iterator and Writable Iterator - ``stable_partition, inplace_merge`` - -Bidirectional Iterator -> Bidirectional Traversal Iterator and Readable Iterator - ``reverse_copy`` - -Random Access Iterator -> Random Access Traversal Iterator and Readable and Writable Iterator - ``random_shuffle, sort, stable_sort, partial_sort, nth_element, push_heap, pop_heap - make_heap, sort_heap`` - -Input Iterator (2) -> Incrementable Iterator and Readable Iterator - ``equal, mismatch`` - -Input Iterator (2) -> Incrementable Iterator and Readable Iterator - ``transform`` - -Deprecations -++++++++++++ - -For the next working paper (but not for TR1), the committee should -consider deprecating the old iterator tags, and -std::iterator_traits, since it will be superceded by individual -traits metafunctions. - -``vector`` -++++++++++++++++ - -For the next working paper (but not for TR1), the committee should -consider reclassifying ``vector::iterator`` as a Random -Access Traversal Iterator and Readable Iterator and Writable -Iterator. - -======== - Design -======== - -The iterator requirements are to be separated into two groups. One set -of concepts handles the syntax and semantics of value access: - -- Readable Iterator -- Writable Iterator -- Swappable Iterator -- Lvalue Iterator - -The access concepts describe requirements related to ``operator*`` and -``operator->``, including the ``value_type``, ``reference``, and -``pointer`` associated types. - -The other set of concepts handles traversal: - -- Incrementable Iterator -- Single Pass Iterator -- Forward Traversal Iterator -- Bidirectional Traversal Iterator -- Random Access Traversal Iterator - -The refinement relationships for the traversal concepts are in the -following diagram. - -.. image:: traversal.png - -In addition to the iterator movement operators, such as -``operator++``, the traversal concepts also include requirements on -position comparison such as ``operator==`` and ``operator<``. The -reason for the fine grain slicing of the concepts into the -Incrementable and Single Pass is to provide concepts that are exact -matches with the original input and output iterator requirements. - -The relationship between the new iterator concepts and the old are -given in the following diagram. - -.. image:: oldeqnew.png - -Like the old iterator requirements, we provide tags for purposes of -dispatching based on the traversal concepts. The tags are related via -inheritance so that a tag is convertible to another tag if the concept -associated with the first tag is a refinement of the second tag. - -Our design reuses ``iterator_traits::iterator_category`` to -indicate an iterator's traversal capability. To specify -capabilities not captured by any old-style iterator category, an -iterator designer can use an ``iterator_category`` type that is -convertible to both the the most-derived old iterator category tag -which fits, and the appropriate new iterator traversal tag. - -.. dwa2003/1/2: Note that we are not *requiring* convertibility to - a new-style traversal tag in order to meet new concepts. - Old-style iterators still fit, after all. - -We do not provide tags for the purposes of dispatching based on the -access concepts, in part because we could not find a way to -automatically infer the right access tags for old-style iterators. -An iterator's writability may be dependent on the assignability of -its ``value_type`` and there's no known way to detect whether an -arbitrary type is assignable. Fortunately, the need for -dispatching based on access capability is not as great as the need -for dispatching based on traversal capability. - -A difficult design decision concerned the ``operator[]``. The direct -approach for specifying ``operator[]`` would have a return type of -``reference``; the same as ``operator*``. However, going in this -direction would mean that an iterator satisfying the old Random Access -Iterator requirements would not necessarily be a model of Readable or -Writable Lvalue Iterator. Instead we have chosen a design that -matches the preferred resolution of `issue 299`_: ``operator[]`` is -only required to return something convertible to the ``value_type`` -(for a Readable Iterator), and is required to support assignment -``i[n] = t`` (for a Writable Iterator). - - -=============== - Proposed Text -=============== - -Addition to [lib.iterator.requirements] -======================================= - -Iterator Value Access Concepts [lib.iterator.value.access] -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -In the tables below, ``X`` is an iterator type, ``a`` is a constant -object of type ``X``, ``R`` is -``std::iterator_traits::reference``, ``T`` is -``std::iterator_traits::value_type``, and ``v`` is a constant -object of type ``T``. - -.. _Readable Iterator: - -Readable Iterators [lib.readable.iterators] -------------------------------------------- - -A class or built-in type ``X`` models the *Readable Iterator* concept -for the value type ``T`` if the following expressions are valid and -respect the stated semantics. ``U`` is the type of any specified -member of type ``T``. - -+--------------------------------------------------------------------------------------+ -|Readable Iterator Requirements (in addition to CopyConstructible) | -+-----------------------------------+------------------------+-------------------------+ -|Expression |Return Type |Note/Precondition | -+===================================+========================+=========================+ -|``iterator_traits::value_type`` |``T`` |Any non-reference, | -| | |non-cv-qualified type | -+-----------------------------------+------------------------+-------------------------+ -|``iterator_traits::reference`` |``R``, Convertible to | | -| |``T`` | | -+-----------------------------------+------------------------+-------------------------+ -|``*a`` |Convertible to ``R``, |pre: ``a`` is | -| |Convertible to ``T`` |dereferenceable. If ``a | -| | |== b`` then ``*a`` is | -| | |equivalent to ``*b`` | -+-----------------------------------+------------------------+-------------------------+ -|``static_cast( |``T`` |equivalent to | -|static_cast(*a) )`` | |``static_cast(*a)`` | -+-----------------------------------+------------------------+-------------------------+ -|``a->m`` |``U&`` |pre: ``(*a).m`` is | -| | |well-defined. Equivalent| -| | |to ``(*a).m`` | -+-----------------------------------+------------------------+-------------------------+ - -.. TR1: the originally-proposed requirement that typeof(*a) == R - was too restrictive. Now we just require that it's - convertible to R and that accessing a T through that conversion - is equivalent to accessing a T directly. - -.. _Writable Iterator: - -Writable Iterators [lib.writable.iterators] -------------------------------------------- - -A class or built-in type ``X`` models the *Writable Iterator* concept -if the following expressions are valid and respect the stated -semantics. Writable Iterators have an associated *set of value types*. - -+---------------------------------------------------------------------+ -|Writable Iterator Requirements (in addition to CopyConstructible) | -+-------------------------+--------------+----------------------------+ -|Expression |Return Type |Precondition | -+=========================+==============+============================+ -|``*a = o`` | | pre: The type of ``o`` | -| | | is in the set of | -| | | value types of ``X`` | -+-------------------------+--------------+----------------------------+ - -Swappable Iterators [lib.swappable.iterators] ---------------------------------------------- - -A class or built-in type ``X`` models the *Swappable Iterator* concept -if the following expressions are valid and respect the stated -semantics. - -+---------------------------------------------------------------------+ -|Swappable Iterator Requirements (in addition to CopyConstructible) | -+-------------------------+-------------+-----------------------------+ -|Expression |Return Type |Postcondition | -+=========================+=============+=============================+ -|``iter_swap(a, b)`` |``void`` |the pointed to values are | -| | |exchanged | -+-------------------------+-------------+-----------------------------+ - -[*Note:* An iterator that is a model of the *Readable* and *Writable Iterator* concepts - is also a model of *Swappable Iterator*. *--end note*] - - -Lvalue Iterators [lib.lvalue.iterators] ---------------------------------------- - -The *Lvalue Iterator* concept adds the requirement that the -``reference`` type be a reference to the value type of the iterator. - -+---------------------------------------------------------------------------------+ -| Lvalue Iterator Requirements | -+---------------------------------+-----------+-----------------------------------+ -|Expression |Return Type|Assertion | -+=================================+===========+===================================+ -|``iterator_traits::reference``|``T&`` |``T`` is *cv* | -| | |``iterator_traits::value_type`` | -| | |where *cv* is an optional | -| | |cv-qualification | -+---------------------------------+-----------+-----------------------------------+ - - -Iterator Traversal Concepts [lib.iterator.traversal] -++++++++++++++++++++++++++++++++++++++++++++++++++++ - -In the tables below, ``X`` is an iterator type, ``a`` and ``b`` are -constant objects of type ``X``, ``r`` and ``s`` are mutable objects of -type ``X``, ``T`` is ``std::iterator_traits::value_type``, and -``v`` is a constant object of type ``T``. - - -Incrementable Iterators [lib.incrementable.iterators] ------------------------------------------------------ - -A class or built-in type ``X`` models the *Incrementable Iterator* -concept if the following expressions are valid and respect the stated -semantics. - - -+-------------------------------------------------------------------------------------+ -|Incrementable Iterator Requirements (in addition to Assignable, Copy Constructible) | -| | -+--------------------------------+-------------------------------+--------------------+ -|Expression |Return Type |Assertion/Semantics | -+================================+===============================+====================+ -|``++r`` |``X&`` |``&r == &++r`` | -+--------------------------------+-------------------------------+--------------------+ -|``r++`` |``X`` |:: | -| | | | -| | | { | -| | | X tmp = r; | -| | | ++r; | -| | | return tmp; | -| | | } | -+--------------------------------+-------------------------------+--------------------+ -|``traversal_category::type`` |Convertible to | | -| |``incrementable_traversal_tag``| | -+--------------------------------+-------------------------------+--------------------+ - -.. TR1: incrementable_iterator_tag changed to - incrementable_traversal_tag for consistency. - -Single Pass Iterators [lib.single.pass.iterators] -------------------------------------------------- - -A class or built-in type ``X`` models the *Single Pass Iterator* -concept if the following expressions are valid and respect the stated -semantics. - - -+------------------------------------------------------------------------------------------+ -|Single Pass Iterator Requirements (in addition to Incrementable Iterator and Equality | -|Comparable) | -+--------------------------------+-----------------------------+---------------------------+ -|Expression |Return Type |Assertion/Semantics / | -| | |Pre-/Post-condition | -+================================+=============================+===========================+ -|``++r`` |``X&`` |pre: ``r`` is | -| | |dereferenceable; post: | -| | |``r`` is dereferenceable or| -| | |``r`` is past-the-end | -+--------------------------------+-----------------------------+---------------------------+ -|``a == b`` |convertible to ``bool`` |``==`` is an equivalence | -| | |relation over its domain | -+--------------------------------+-----------------------------+---------------------------+ -|``a != b`` |convertible to ``bool`` |``!(a == b)`` | -+--------------------------------+-----------------------------+---------------------------+ -|``traversal_category::type`` |Convertible to | | -| |``single_pass_traversal_tag``| | -+--------------------------------+-----------------------------+---------------------------+ - -.. TR1: single_pass_iterator_tag changed to - single_pass_traversal_tag for consistency - - -Forward Traversal Iterators [lib.forward.traversal.iterators] -------------------------------------------------------------- - -A class or built-in type ``X`` models the *Forward Traversal Iterator* -concept if the following expressions are valid and respect the stated -semantics. - -+-------------------------------------------------------------------------------------------+ -|Forward Traversal Iterator Requirements (in addition to Single Pass Iterator) | -+---------------------------------------+-----------------------------------+---------------+ -|Expression |Return Type |Assertion/Note | -+=======================================+===================================+===============+ -|``X u;`` |``X&`` |note: ``u`` may| -| | |have a singular| -| | |value. | -+---------------------------------------+-----------------------------------+---------------+ -|``++r`` |``X&`` |``r == s`` and | -| | |``r`` is | -| | |dereferenceable| -| | |implies ``++r | -| | |== ++s.`` | -+---------------------------------------+-----------------------------------+---------------+ -|``iterator_traits::difference_type``|A signed integral type representing| | -| |the distance between iterators | | -| | | | -+---------------------------------------+-----------------------------------+---------------+ -|``traversal_category::type`` |Convertible to | | -| |``forward_traversal_tag`` | | -+---------------------------------------+-----------------------------------+---------------+ - -.. TR1: forward_traversal_iterator_tag changed to - forward_traversal_tag for consistency - - -Bidirectional Traversal Iterators [lib.bidirectional.traversal.iterators] -------------------------------------------------------------------------- - -A class or built-in type ``X`` models the *Bidirectional Traversal -Iterator* concept if the following expressions are valid and respect -the stated semantics. - -+--------------------------------------------------------------------------------------------------------+ -|Bidirectional Traversal Iterator Requirements (in addition to Forward Traversal Iterator) | -+------------------------------------+---------------------------------------------+---------------------+ -|Expression |Return Type |Assertion/Semantics /| -| | |Pre-/Post-condition | -+====================================+=============================================+=====================+ -|``--r`` |``X&`` |pre: there exists | -| | |``s`` such that ``r | -| | |== ++s``. post: | -| | |``s`` is | -| | |dereferenceable. | -| | |``--(++r) == r``. | -| | |``--r == --s`` | -| | |implies ``r == | -| | |s``. ``&r == &--r``. | -+------------------------------------+---------------------------------------------+---------------------+ -|``r--`` |convertible to ``const X&`` |:: | -| | | | -| | | { | -| | | X tmp = r; | -| | | --r; | -| | | return tmp; | -| | | } | -+------------------------------------+---------------------------------------------+---------------------+ -|``traversal_category::type`` |Convertible to | | -| |``bidirectional_traversal_tag`` | | -| | | | -+------------------------------------+---------------------------------------------+---------------------+ - -.. TR1: bidirectional_traversal_iterator_tag changed to - bidirectional_traversal_tag for consistency - -Random Access Traversal Iterators [lib.random.access.traversal.iterators] -------------------------------------------------------------------------- - -A class or built-in type ``X`` models the *Random Access Traversal -Iterator* concept if the following expressions are valid and respect -the stated semantics. In the table below, ``Distance`` is -``iterator_traits::difference_type`` and ``n`` represents a -constant object of type ``Distance``. - -+----------------------------------------------------------------------------------------------------------------------------------------------+ -|Random Access Traversal Iterator Requirements (in addition to Bidirectional Traversal Iterator) | -+-------------------------------------------+-------------------------------------------------+-------------------------+----------------------+ -|Expression |Return Type |Operational Semantics |Assertion/ | -| | | |Precondition | -+===========================================+=================================================+=========================+======================+ -|``r += n`` |``X&`` |:: | | -| | | | | -| | | { | | -| | | Distance m = n; | | -| | | if (m >= 0) | | -| | | while (m--) | | -| | | ++r; | | -| | | else | | -| | | while (m++) | | -| | | --r; | | -| | | return r; | | -| | | } | | -+-------------------------------------------+-------------------------------------------------+-------------------------+----------------------+ -|``a + n``, ``n + a`` |``X`` |``{ X tmp = a; return tmp| | -| | |+= n; }`` | | -| | | | | -+-------------------------------------------+-------------------------------------------------+-------------------------+----------------------+ -|``r -= n`` |``X&`` |``return r += -n`` | | -+-------------------------------------------+-------------------------------------------------+-------------------------+----------------------+ -|``a - n`` |``X`` |``{ X tmp = a; return tmp| | -| | |-= n; }`` | | -| | | | | -+-------------------------------------------+-------------------------------------------------+-------------------------+----------------------+ -|``b - a`` |``Distance`` |``a < b ? distance(a,b) |pre: there exists a | -| | |: -distance(b,a)`` |value ``n`` of | -| | | |``Distance`` such that| -| | | |``a + n == b``. ``b | -| | | |== a + (b - a)``. | -+-------------------------------------------+-------------------------------------------------+-------------------------+----------------------+ -|``a[n]`` |convertible to T |``*(a + n)`` |pre: a is a `readable | -| | | |iterator`_ | -+-------------------------------------------+-------------------------------------------------+-------------------------+----------------------+ -|``a[n] = v`` |convertible to T |``*(a + n) = v`` |pre: a is a `writable | -| | | |iterator`_ | -+-------------------------------------------+-------------------------------------------------+-------------------------+----------------------+ -|``a < b`` |convertible to ``bool`` |``b - a > 0`` |``<`` is a total | -| | | |ordering relation | -+-------------------------------------------+-------------------------------------------------+-------------------------+----------------------+ -|``a > b`` |convertible to ``bool`` |``b < a`` |``>`` is a total | -| | | |ordering relation | -+-------------------------------------------+-------------------------------------------------+-------------------------+----------------------+ -|``a >= b`` |convertible to ``bool`` |``!(a < b)`` | | -+-------------------------------------------+-------------------------------------------------+-------------------------+----------------------+ -|``a <= b`` |convertible to ``bool`` |``!(a > b)`` | | -+-------------------------------------------+-------------------------------------------------+-------------------------+----------------------+ -|``traversal_category::type`` |Convertible to | | | -| |``random_access_traversal_tag`` | | | -+-------------------------------------------+-------------------------------------------------+-------------------------+----------------------+ - -.. TR1: random_access_traversal_iterator_tag changed to - random_access_traversal_tag for consistency - - -Addition to [lib.iterator.synopsis] -=================================== - - -:: - - // lib.iterator.traits, traits and tags - template struct is_readable_iterator; - template struct iterator_traversal; - - struct incrementable_traversal_tag { }; - struct single_pass_traversal_tag : incrementable_traversal_tag { }; - struct forward_traversal_tag : single_pass_traversal_tag { }; - struct bidirectional_traversal_tag : forward_traversal_tag { }; - struct random_access_traversal_tag : bidirectional_traversal_tag { }; - -Addition to [lib.iterator.traits] -================================= - -The ``is_readable_iterator`` and ``iterator_traversal`` class -templates satisfy the UnaryTypeTrait_ requirements. - -Given an iterator type ``X``, ``is_readable_iterator::value`` -yields ``true`` if, for an object ``a`` of type ``X``, ``*a`` is -convertible to ``iterator_traits::value_type``, and ``false`` -otherwise. - -``iterator_traversal::value_type`` is defined to be: - -.. parsed-literal:: - - traversal-category(X) = - cat = iterator_traits::iterator_category; - if (cat is convertible to incrementable_traversal_tag) - return cat; - else if (cat is convertible to random_access_iterator_tag) - return random_access_traversal_tag; - else if (cat is convertible to bidirectional_iterator_tag) - return bidirectional_traversal_tag; - else if (cat is convertible to forward_iterator_tag) - return forward_traversal_tag; - else if (cat is convertible to input_iterator_tag) - return single_pass_traversal_tag; - else if (cat is convertible to output_iterator_tag) - return incrementable_traversal_tag; - else - *the program is ill-formed* - - -=========== - Footnotes -=========== - -.. _UnaryTypeTrait: n1519_ - -The UnaryTypeTrait concept is defined in n1519_; the LWG added the -requirement that specializations are derived from their nested -``::type``. - -.. _n1519: http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1519.htm - -.. - LocalWords: Abrahams Siek Witt const bool Sutter's WG int UL LI href Lvalue - LocalWords: ReadableIterator WritableIterator SwappableIterator cv pre iter - LocalWords: ConstantLvalueIterator MutableLvalueIterator CopyConstructible TR - LocalWords: ForwardTraversalIterator BidirectionalTraversalIterator lvalue - LocalWords: RandomAccessTraversalIterator dereferenceable Incrementable tmp - LocalWords: incrementable xxx min prev inplace png oldeqnew AccessTag struct - LocalWords: TraversalTag typename lvalues DWA Hmm JGS mis enum diff --git a/doc/oldeqnew.png b/doc/oldeqnew.png deleted file mode 100644 index 30cd159..0000000 Binary files a/doc/oldeqnew.png and /dev/null differ diff --git a/doc/permutation_iterator.html b/doc/permutation_iterator.html deleted file mode 100644 index ad043b2..0000000 --- a/doc/permutation_iterator.html +++ /dev/null @@ -1,320 +0,0 @@ - - - - - - -Permutation Iterator - - - - - - - -
-

Permutation Iterator

- --- - - - - - - - - - - - -
Author:Toon Knapen, David Abrahams, Roland Richter, Jeremy Siek
Contact:dave@boost-consulting.com, jsiek@osl.iu.edu
Organization:Boost Consulting, Indiana University Open Systems -Lab
Date:2003-09-14
Copyright:Copyright Toon Knapen, David Abrahams, Roland Richter, and Jeremy Siek 2003. All rights reserved
- --- - - - -
abstract:
-

The permutation iterator adaptor provides a permuted view of a given -range. That is, the view includes every element of the given range but -in a potentially different order.

- -
-

Introduction

-

The adaptor takes two arguments:

-
-
    -
  • an iterator to the range V on which the permutation -will be applied
  • -
  • the reindexing scheme that defines how the -elements of V will be permuted.
  • -
-
-

Note that the permutation iterator is not limited to strict -permutations of the given range V. The distance between begin and end -of the reindexing iterators is allowed to be smaller compared to the -size of the range V, in which case the permutation iterator only -provides a permutation of a subrange of V. The indexes neither need -to be unique. In this same context, it must be noted that the past the -end permutation iterator is completely defined by means of the -past-the-end iterator to the indices.

-
-
-

Reference

-
-template< class ElementIterator
-        , class IndexIterator
-        , class ValueT        = use_default
-    , unsigned access     = use_default_access
-        , class Traversal     = use_default
-        , class ReferenceT    = use_default
-        , class DifferenceT   = use_default >
-class permutation_iterator
-  : public iterator_adaptor<...>
-{
-  typedef iterator_adaptor<...>
-  friend class iterator_core_access;
-public:
-  permutation_iterator();
-  explicit permutation_iterator(ElementIterator x, IndexIterator y);
-
-  template< class OEIter, class OIIter, class V, class C, class R, class D >
-  permutation_iterator(
-      permutation_iterator<OEIter, OIIter, V, C, R, D> const& r
-      , typename enable_if_convertible<OEIter, ElementIterator>::type* = 0
-      , typename enable_if_convertible<OIIter, IndexIterator>::type* = 0
-      );
-};
-
-
-

permutation_iterator requirements

-

ElementIterator must be a model of RandomAccessIterator. -IndexIterator must at least be a model ForwardIterator. The -value type of the IndexIterator must be convertible to the -difference type of ElementIterator.

-
-
-

permutation_iterator operations

-

The permutation iterator implements the member functions and operators -required for the Random Access Iterator concept. However, the -permutation iterator can only meet the complexity guarantees of the -same concept as the IndexIterator. Thus for instance, although the -permutation iterator provides operator+=(distance), this operation -will take linear time in case the IndexIterator is a model of -ForwardIterator instead of amortized constant time.

-
-
-
- - - - diff --git a/doc/permutation_iterator.rst b/doc/permutation_iterator.rst deleted file mode 100644 index d506b78..0000000 --- a/doc/permutation_iterator.rst +++ /dev/null @@ -1,31 +0,0 @@ -++++++++++++++++++++++ - Permutation Iterator -++++++++++++++++++++++ - -:Author: Toon Knapen, David Abrahams, Roland Richter, Jeremy Siek -:Contact: dave@boost-consulting.com, jsiek@osl.iu.edu -:organization: `Boost Consulting`_, Indiana University `Open Systems - Lab`_ -:date: $Date$ -:copyright: Copyright Toon Knapen, David Abrahams, Roland Richter, and Jeremy Siek 2003. All rights reserved - -.. _`Boost Consulting`: http://www.boost-consulting.com -.. _`Open Systems Lab`: http://www.osl.iu.edu - -:abstract: - -.. include:: permutation_iterator_abstract.rst - -.. contents:: Table of Contents - - -Introduction -============ - -.. include:: permutation_iterator_body.rst - - -Reference -========= - -.. include:: permutation_iterator_ref.rst diff --git a/doc/permutation_iterator_abstract.rst b/doc/permutation_iterator_abstract.rst deleted file mode 100644 index 578b3ed..0000000 --- a/doc/permutation_iterator_abstract.rst +++ /dev/null @@ -1,4 +0,0 @@ -The permutation iterator adaptor provides a permuted view of a given -range. That is, the view includes every element of the given range but -in a potentially different order. - diff --git a/doc/permutation_iterator_body.rst b/doc/permutation_iterator_body.rst deleted file mode 100644 index 0f838e7..0000000 --- a/doc/permutation_iterator_body.rst +++ /dev/null @@ -1,15 +0,0 @@ -The adaptor takes two arguments: - - * an iterator to the range V on which the permutation - will be applied - * the reindexing scheme that defines how the - elements of V will be permuted. - -Note that the permutation iterator is not limited to strict -permutations of the given range V. The distance between begin and end -of the reindexing iterators is allowed to be smaller compared to the -size of the range V, in which case the permutation iterator only -provides a permutation of a subrange of V. The indexes neither need -to be unique. In this same context, it must be noted that the past the -end permutation iterator is completely defined by means of the -past-the-end iterator to the indices. diff --git a/doc/permutation_iterator_ref.rst b/doc/permutation_iterator_ref.rst deleted file mode 100644 index ab82271..0000000 --- a/doc/permutation_iterator_ref.rst +++ /dev/null @@ -1,55 +0,0 @@ -.. parsed-literal:: - - template< class ElementIterator - , class IndexIterator - , class ValueT = use_default - , unsigned access = use_default_access - , class Traversal = use_default - , class ReferenceT = use_default - , class DifferenceT = use_default > - class permutation_iterator - : public iterator_adaptor<...> - { - typedef iterator_adaptor<...> - friend class iterator_core_access; - public: - permutation_iterator(); - explicit permutation_iterator(ElementIterator x, IndexIterator y); - - template< class OEIter, class OIIter, class V, class C, class R, class D > - permutation_iterator( - permutation_iterator const& r - , typename enable_if_convertible::type* = 0 - , typename enable_if_convertible::type* = 0 - ); - }; - - - -``permutation_iterator`` requirements -------------------------------------- - -``ElementIterator`` must be a model of RandomAccessIterator__. -``IndexIterator`` must at least be a model ForwardIterator__. The -value type of the ``IndexIterator`` must be convertible to the -difference type of ``ElementIterator``. - -__ http://www.sgi.com/tech/stl/RandomAccessIterator.html - -__ http://www.sgi.com/tech/stl/ForwardIterator.html - - - - -``permutation_iterator`` operations ------------------------------------ - -The permutation iterator implements the member functions and operators -required for the `Random Access Iterator`__ concept. However, the -permutation iterator can only meet the complexity guarantees of the -same concept as the IndexIterator. Thus for instance, although the -permutation iterator provides ``operator+=(distance)``, this operation -will take linear time in case the IndexIterator is a model of -ForwardIterator instead of amortized constant time. - -__ http://www.sgi.com/tech/stl/RandomAccessIterator.html diff --git a/doc/ref_problem.rst b/doc/ref_problem.rst deleted file mode 100644 index 2f2908a..0000000 --- a/doc/ref_problem.rst +++ /dev/null @@ -1,63 +0,0 @@ -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - Problem with ``reference`` and old/new iterator category correspondance -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -.. _N1550: http://www.boost-consulting.com/writing/n1550.html -.. _N1530: http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1530.html - -:Author: David Abrahams and Jeremy Siek -:Contact: dave@boost-consulting.com, jsiek@osl.iu.edu -:Organization: `Boost Consulting`_, Indiana University Bloomington -:date: $Date$ -:Copyright: Copyright David Abrahams, Jeremy Siek 2003. Use, modification and - distribution is subject to the Boost Software License, - Version 1.0. (See accompanying file LICENSE_1_0.txt or copy - at http://www.boost.org/LICENSE_1_0.txt) - -.. _`Boost Consulting`: http://www.boost-consulting.com - -============== - Introduction -============== - -The new iterator categories are intended to correspond to the old -iterator categories, as specified in a diagram in N1550_. For example, -an iterator categorized as a mutable Forward Iterator under the old -scheme is now a Writable, Lvalue, and Foward Traversal iterator. -However, there is a problem with this correspondance, the new iterator -categories place requirements on the ``iterator_traits::reference`` -type whereas the standard iterator requirements say nothing about the -``reference`` type . In particular, the new Readable Iterator -requirements say that the return type of ``*a`` must be -``iterator_traits::reference`` and the Lvalue Iterator requirements -says that ``iterator_traits::reference`` must be ``T&`` or ``const -T&``. - - -==================== - Proposed Resolution -==================== - -Change the standard requirements to match the requirements of the new -iterators. (more details to come) - - -========== - Rationale -========== - -The lack of specification in the standard of the ``reference`` type is -certainly a defect. Without specification, it is entirely useless in a -generic function. The current practice in the community is generally -to assume there are requirements on the ``reference`` type, such as -those proposed in the new iterator categories. - -There is some danger in *adding* requirements to existing concepts. -This will mean that some existing iterator types will no longer meet -the iterator requirements. However, we feel that the impact of this is -small enough to warrant going ahead with this change. - -An alternative solution would be to leave the standard requirements as -is, and to remove the requirements for the ``reference`` type in the -new iterator concepts. We are not in favor of this approach because it -extends what we see as a defect further into the future. diff --git a/doc/reverse_iterator.html b/doc/reverse_iterator.html deleted file mode 100644 index ac3ceaf..0000000 --- a/doc/reverse_iterator.html +++ /dev/null @@ -1,143 +0,0 @@ - - - - - - -Reverse Iterator - - - - - - - -
-

Reverse Iterator

- --- - - - - - - - - - - - -
Author:David Abrahams, Jeremy Siek, Thomas Witt
Contact:dave@boost-consulting.com, jsiek@osl.iu.edu, witt@ive.uni-hannover.de
Organization:Boost Consulting, Indiana University Open Systems -Lab, University of Hanover Institute for Transport -Railway Operation and Construction
Date:2003-09-14
Copyright:Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved
- --- - - - -
abstract:
- -

The reverse iterator adaptor flips the direction of a base iterator's -motion. Invoking operator++() moves the base iterator backward and -invoking operator--() moves the base iterator forward.

- -
-template <class Iterator>
-class reverse_iterator :
-  public iterator_adaptor< reverse_iterator<Iterator>, Iterator >
-{
-  friend class iterator_core_access;
-public:
-  reverse_iterator() {}
-  explicit reverse_iterator(Iterator x) ;
-
-  template<class OtherIterator>
-  reverse_iterator(
-      reverse_iterator<OtherIterator> const& r
-    , typename enable_if_convertible<OtherIterator, Iterator>::type* = 0 // exposition
-  );
-
-private: // as-if specification
-  typename reverse_iterator::reference dereference() const { return *prior(this->base()); }
-
-  void increment() { --this->base_reference(); }
-  void decrement() { ++this->base_reference(); }
-
-  void advance(typename reverse_iterator::difference_type n)
-  {
-      this->base_reference() += -n;
-  }
-
-  template <class OtherIterator>
-  typename reverse_iterator::difference_type
-  distance_to(reverse_iterator<OtherIterator> const& y) const
-  {
-      return this->base_reference() - y.base();
-  }
-
-};
-
-
-

reverse_iterator requirements

-

The base Iterator must be a model of Bidirectional Traversal -Iterator. The resulting reverse_iterator will be a model of the -most refined standard traversal and access concepts that are modeled -by Iterator.

-

reverse_iterator();

- --- - - - - - -
Requires:Iterator must be Default Constructible.
Returns:An instance of reverse_iterator with a -default constructed base object.
-

explicit reverse_iterator(Iterator x);

- --- - - - -
Returns:An instance of reverse_iterator with a -base object copy constructed from x.
-
-template<class OtherIterator>
-reverse_iterator(
-    reverse_iterator<OtherIterator> const& r
-  , typename enable_if_convertible<OtherIterator, Iterator>::type* = 0 // exposition
-);
-
- --- - - - - - -
Requires:OtherIterator is implicitly convertible to Iterator.
Returns:An instance of reverse_iterator that is a copy of r.
-
-
- - - - diff --git a/doc/reverse_iterator.rst b/doc/reverse_iterator.rst deleted file mode 100644 index 5265076..0000000 --- a/doc/reverse_iterator.rst +++ /dev/null @@ -1,23 +0,0 @@ -++++++++++++++++++ - Reverse Iterator -++++++++++++++++++ - -:Author: David Abrahams, Jeremy Siek, Thomas Witt -:Contact: dave@boost-consulting.com, jsiek@osl.iu.edu, witt@ive.uni-hannover.de -:organization: `Boost Consulting`_, Indiana University `Open Systems - Lab`_, University of Hanover `Institute for Transport - Railway Operation and Construction`_ -:date: $Date$ -:copyright: Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved - -.. _`Boost Consulting`: http://www.boost-consulting.com -.. _`Open Systems Lab`: http://www.osl.iu.edu -.. _`Institute for Transport Railway Operation and Construction`: http://www.ive.uni-hannover.de - -:abstract: - -.. include:: reverse_iterator_abstract.rst - -.. contents:: Table of Contents - -.. include:: reverse_iterator_ref.rst diff --git a/doc/reverse_iterator_abstract.rst b/doc/reverse_iterator_abstract.rst deleted file mode 100644 index 0574988..0000000 --- a/doc/reverse_iterator_abstract.rst +++ /dev/null @@ -1,6 +0,0 @@ -.. I think we'd better strike the old reverse_iterator text from the standard, eh? - -The reverse iterator adaptor flips the direction of a base iterator's -motion. Invoking ``operator++()`` moves the base iterator backward and -invoking ``operator--()`` moves the base iterator forward. - diff --git a/doc/reverse_iterator_ref.rst b/doc/reverse_iterator_ref.rst deleted file mode 100644 index c0acc2b..0000000 --- a/doc/reverse_iterator_ref.rst +++ /dev/null @@ -1,69 +0,0 @@ -:: - - template - class reverse_iterator : - public iterator_adaptor< reverse_iterator, Iterator > - { - friend class iterator_core_access; - public: - reverse_iterator() {} - explicit reverse_iterator(Iterator x) ; - - template - reverse_iterator( - reverse_iterator const& r - , typename enable_if_convertible::type* = 0 // exposition - ); - - private: // as-if specification - typename reverse_iterator::reference dereference() const { return *prior(this->base()); } - - void increment() { --this->base_reference(); } - void decrement() { ++this->base_reference(); } - - void advance(typename reverse_iterator::difference_type n) - { - this->base_reference() += -n; - } - - template - typename reverse_iterator::difference_type - distance_to(reverse_iterator const& y) const - { - return this->base_reference() - y.base(); - } - - }; - - -``reverse_iterator`` requirements -................................. - -The base ``Iterator`` must be a model of Bidirectional Traversal -Iterator. The resulting ``reverse_iterator`` will be a model of the -most refined standard traversal and access concepts that are modeled -by ``Iterator``. - - -``reverse_iterator();`` - -:Requires: ``Iterator`` must be Default Constructible. -:Returns: An instance of ``reverse_iterator`` with a - default constructed base object. - -``explicit reverse_iterator(Iterator x);`` - -:Returns: An instance of ``reverse_iterator`` with a - base object copy constructed from ``x``. - - -:: - - template - reverse_iterator( - reverse_iterator const& r - , typename enable_if_convertible::type* = 0 // exposition - ); - -:Requires: ``OtherIterator`` is implicitly convertible to ``Iterator``. -:Returns: An instance of ``reverse_iterator`` that is a copy of ``r``. diff --git a/doc/sources.py b/doc/sources.py deleted file mode 100644 index a69b4a7..0000000 --- a/doc/sources.py +++ /dev/null @@ -1,18 +0,0 @@ -# This is where we list the ReStructuredText source files that form -# the book. When you're ready to expose a new chapter, add the -# filename here and put links in index.rst - -sources = [ -'counting_iterator.rst', -'facade-and-adaptor.rst', -'filter_iterator.rst', -'function_output_iterator.rst', -'index.rst', -'indirect_iterator.rst', -'iterator_adaptor.rst', -'iterator_facade.rst', -'new-iter-concepts.rst', -'permutation_iterator.rst', -'reverse_iterator.rst' - ] - diff --git a/doc/style.tex b/doc/style.tex deleted file mode 100755 index a4fe2f9..0000000 --- a/doc/style.tex +++ /dev/null @@ -1,41 +0,0 @@ -% donot indent first line. -\setlength{\parindent}{0pt} -\setlength{\parskip}{5pt plus 2pt minus 1pt} - -% sloppy -% ------ -% Less strict (opposite to default fussy) space size between words. Therefore -% less hyphenation. -\sloppy - -% fonts -% ----- -% times for pdf generation, gives smaller pdf files. -% -% But in standard postscript fonts: courier and times/helvetica do not fit. -% Maybe use pslatex. -\usepackage{times} -\usepackage{pslatex} - -% pagestyle -% \usepackage{fancyhdr} -\pagestyle{headings} -\setlength{\paperwidth}{7.375in} -\setlength{\paperheight}{9.25in} - -\setlength{\oddsidemargin}{0.375in} -\setlength{\evensidemargin}{0.375in} -\setlength{\textwidth}{5in} -\setlength{\textheight}{7.125in} - -\setlength{\topmargin}{-0.375in} -\setlength{\headheight}{0.25in} -\setlength{\headsep}{0.25in} -\setlength{\footskip}{0.25in} - -\setlength{\admonitionwidth}{0.9\textwidth} -\setlength{\docinfowidth}{0.9\textwidth} - - - - diff --git a/doc/transform_iterator.html b/doc/transform_iterator.html deleted file mode 100644 index 685d240..0000000 --- a/doc/transform_iterator.html +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - -Transform Iterator - - - - - - - -
-

Transform Iterator

- --- - - - - - - - - - - - -
Author:David Abrahams, Jeremy Siek, Thomas Witt
Contact:dave@boost-consulting.com, jsiek@osl.iu.edu, witt@ive.uni-hannover.de
Organization:Boost Consulting, Indiana University Open Systems -Lab, University of Hanover Institute for Transport -Railway Operation and Construction
Date:2003-08-05
Copyright:Copyright Dave Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved
- --- - - - -
abstract:
-

The transform iterator adapts an iterator by applying some function -object to the result of dereferencing the iterator. In other words, -the operator* of the transform iterator first dereferences the -base iterator, passes the result of this to the function object, and -then returns the result.

- -
-template <class AdaptableUnaryFunction,
-          class Iterator, 
-          class Reference = use_default, 
-          class Value = use_default>
-class transform_iterator
-  : public iterator_adaptor</* see discussion */>
-{
-  friend class iterator_core_access;
-public:
-  transform_iterator();
-  transform_iterator(Iterator const& x, AdaptableUnaryFunction f);
-
-  template<class OtherIterator, class R2, class V2>
-  transform_iterator(
-        transform_iterator<AdaptableUnaryFunction, OtherIterator, R2, V2> const& t
-      , typename enable_if_convertible<OtherIterator, Iterator>::type* = 0 // exposition
-  );
-
-  AdaptableUnaryFunction functor() const;
-private:
-  typename transform_iterator::value_type dereference() const;
-  AdaptableUnaryFunction m_f;
-};
-
-
-

transform_iterator requirements

-

The type AdaptableUnaryFunction must be Assignable, Copy -Constructible, and the expression f(x) must be valid where f -is an object of type AdaptableUnaryFunction, x is an object of -type AdaptableUnaryFunction::argument_type, and where the type of -f(x) must be AdaptableUnaryFunction::result_type.

-

The type Iterator must at least model Readable Iterator. The -resulting transform_iterator models the most refined of the -following options that is also modeled by Iterator.

-
-
    -
  • Writable Lvalue Iterator if the result_type of the -AdaptableUnaryFunction is a non-const reference.
  • -
  • Readable Lvalue Iterator if the result_type is a const -reference.
  • -
  • Readable Iterator otherwise.
  • -
-
-

The transform_iterator models the most refined standard traversal -concept that is modeled by Iterator.

-

The value_type of transform_iterator is -remove_reference<result_type>::type. The reference type is -result_type.

-
-
-

transform_iterator public operations

-

transform_iterator();

- --- - - - -
Returns:An instance of transform_iterator with m_f -and m_iterator default constructed.
-

transform_iterator(Iterator const& x, AdaptableUnaryFunction f);

- --- - - - -
Returns:An instance of transform_iterator with m_f -initialized to f and m_iterator initialized to x.
-
-template<class OtherIterator, class R2, class V2>
-transform_iterator(
-      transform_iterator<AdaptableUnaryFunction, OtherIterator, R2, V2> const& t
-    , typename enable_if_convertible<OtherIterator, Iterator>::type* = 0 // exposition
-);
-
- --- - - - - - -
Returns:An instance of transform_iterator that is a copy of t.
Requires:OtherIterator is implicitly convertible to Iterator.
-

AdaptableUnaryFunction functor() const;

- --- - - - -
Returns:m_f
-
-
-

transform_iterator private operations

-

typename transform_iterator::value_type dereference() const;

- --- - - - -
Returns:m_f(transform_iterator::dereference());
-
-
- - diff --git a/doc/transform_iterator.rst b/doc/transform_iterator.rst deleted file mode 100644 index 021532d..0000000 --- a/doc/transform_iterator.rst +++ /dev/null @@ -1,23 +0,0 @@ -++++++++++++++++++++ - Transform Iterator -++++++++++++++++++++ - -:Author: David Abrahams, Jeremy Siek, Thomas Witt -:Contact: dave@boost-consulting.com, jsiek@osl.iu.edu, witt@ive.uni-hannover.de -:organization: `Boost Consulting`_, Indiana University `Open Systems - Lab`_, University of Hanover `Institute for Transport - Railway Operation and Construction`_ -:date: $Date$ -:copyright: Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved - -.. _`Boost Consulting`: http://www.boost-consulting.com -.. _`Open Systems Lab`: http://www.osl.iu.edu -.. _`Institute for Transport Railway Operation and Construction`: http://www.ive.uni-hannover.de - -:abstract: - -.. include:: transform_iterator_abstract.rst - -.. contents:: Table of Contents - -.. include:: transform_iterator_ref.rst diff --git a/doc/transform_iterator_abstract.rst b/doc/transform_iterator_abstract.rst deleted file mode 100644 index 6a7534e..0000000 --- a/doc/transform_iterator_abstract.rst +++ /dev/null @@ -1,5 +0,0 @@ -The transform iterator adapts an iterator by applying some function -object to the result of dereferencing the iterator. In other words, -the ``operator*`` of the transform iterator first dereferences the -base iterator, passes the result of this to the function object, and -then returns the result. diff --git a/doc/transform_iterator_ref.rst b/doc/transform_iterator_ref.rst deleted file mode 100644 index 40eaaad..0000000 --- a/doc/transform_iterator_ref.rst +++ /dev/null @@ -1,96 +0,0 @@ -.. Version 1.3 of this document was accepted for TR1 - -:: - - template - class transform_iterator - : public iterator_adaptor - { - friend class iterator_core_access; - public: - transform_iterator(); - transform_iterator(Iterator const& x, UnaryFunction f); - - template - transform_iterator( - transform_iterator const& t - , typename enable_if_convertible::type* = 0 // exposition - , typename enable_if_convertible::type* = 0 // exposition - ); - - UnaryFunction functor() const; - private: - typename transform_iterator::value_type dereference() const; - UnaryFunction m_f; - }; - - -``transform_iterator`` requirements -................................... - -The type ``UnaryFunction`` must be Assignable, Copy Constructible, and -the expression ``f(*i)`` must be valid where ``f`` is an object of -type ``UnaryFunction``, ``i`` is an object of type ``Iterator``, and -where the type of ``f(*i)`` must be -``result_of::reference)>::type``. - -The type ``Iterator`` must at least model Readable Iterator. The -resulting ``transform_iterator`` models the most refined of the -following options that is also modeled by ``Iterator``. - - * Writable Lvalue Iterator if ``result_of::reference)>::type`` is a non-const reference. - - * Readable Lvalue Iterator if ``result_of::reference)>::type`` is a const - reference. - - * Readable Iterator otherwise. - - -The ``transform_iterator`` models the most refined standard traversal -concept that is modeled by ``Iterator``. - -The ``reference`` type of ``transform_iterator`` is -``result_of::reference)>::type``. -The ``value_type`` is ``remove_cv >::type``. - -``transform_iterator`` public operations -........................................ - - -``transform_iterator();`` - -:Returns: An instance of ``transform_iterator`` with ``m_f`` - and ``m_iterator`` default constructed. - - -``transform_iterator(Iterator const& x, UnaryFunction f);`` - -:Returns: An instance of ``transform_iterator`` with ``m_f`` - initialized to ``f`` and ``m_iterator`` initialized to ``x``. - - -:: - - template - transform_iterator( - transform_iterator const& t - , typename enable_if_convertible::type* = 0 // exposition - ); - -:Returns: An instance of ``transform_iterator`` that is a copy of ``t``. -:Requires: ``OtherIterator`` is implicitly convertible to ``Iterator``. - -``UnaryFunction functor() const;`` - -:Returns: ``m_f`` - -``transform_iterator`` private operations -......................................... - -``typename transform_iterator::value_type dereference() const;`` - -:Returns: ``m_f(transform_iterator::dereference());`` - diff --git a/doc/traversal.png b/doc/traversal.png deleted file mode 100644 index a9bbe98..0000000 Binary files a/doc/traversal.png and /dev/null differ diff --git a/example/Jamfile b/example/Jamfile deleted file mode 100644 index fce5509..0000000 --- a/example/Jamfile +++ /dev/null @@ -1,9 +0,0 @@ -subproject libs/iterator/example ; - -import testing ; - -test-suite iterator_examples - : [ run reverse_iterator.cpp ] - [ run node_iterator1.cpp ] - [ run node_iterator2.cpp ] - ; diff --git a/example/node.hpp b/example/node.hpp deleted file mode 100755 index b9e482c..0000000 --- a/example/node.hpp +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright David Abrahams 2004. Use, modification and distribution is -// subject to the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#ifndef NODE_DWA2004110_HPP -# define NODE_DWA2004110_HPP - -# include - -// Polymorphic list node base class - -struct node_base -{ - node_base() : m_next(0) {} - - virtual ~node_base() - { - delete m_next; - } - - node_base* next() const - { - return m_next; - } - - virtual void print(std::ostream& s) const = 0; - virtual void twice() = 0; - - void append(node_base* p) - { - if (m_next) - m_next->append(p); - else - m_next = p; - } - - private: - node_base* m_next; -}; - -inline std::ostream& operator<<(std::ostream& s, node_base const& n) -{ - n.print(s); - return s; -} - -template -struct node : node_base -{ - node(T x) - : m_value(x) - {} - - void print(std::ostream& s) const { s << this->m_value; } - void twice() { m_value += m_value; } - - private: - T m_value; -}; - -#endif // NODE_DWA2004110_HPP diff --git a/example/node_iterator1.cpp b/example/node_iterator1.cpp deleted file mode 100755 index 2b3ac00..0000000 --- a/example/node_iterator1.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright David Abrahams 2004. Use, modification and distribution is -// subject to the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include "node_iterator1.hpp" -#include -#include -#include -#include -#include - -int main() -{ - std::auto_ptr > nodes(new node(42)); - nodes->append(new node(" is greater than ")); - nodes->append(new node(13)); - - std::copy( - node_iterator(nodes.get()), node_iterator() - , std::ostream_iterator(std::cout, " ") - ); - std::cout << std::endl; - - std::for_each( - node_iterator(nodes.get()), node_iterator() - , std::mem_fun_ref(&node_base::twice) - ); - - std::copy( - node_iterator(nodes.get()), node_iterator() - , std::ostream_iterator(std::cout, "/") - ); - std::cout << std::endl; -} diff --git a/example/node_iterator1.hpp b/example/node_iterator1.hpp deleted file mode 100755 index 281f30a..0000000 --- a/example/node_iterator1.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright David Abrahams 2004. Use, modification and distribution is -// subject to the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#ifndef NODE_ITERATOR1_DWA2004110_HPP -# define NODE_ITERATOR1_DWA2004110_HPP - -# include "node.hpp" -# include - -class node_iterator - : public boost::iterator_facade< - node_iterator - , node_base - , boost::forward_traversal_tag - > -{ - public: - node_iterator() - : m_node(0) - {} - - explicit node_iterator(node_base* p) - : m_node(p) - {} - - friend class boost::iterator_core_access; - - private: - void increment() - { m_node = m_node->next(); } - - bool equal(node_iterator const& other) const - { return this->m_node == other.m_node; } - - node_base& dereference() const - { return *m_node; } - - node_base* m_node; -}; - - -#endif // NODE_ITERATOR1_DWA2004110_HPP diff --git a/example/node_iterator2.cpp b/example/node_iterator2.cpp deleted file mode 100755 index 9985c6f..0000000 --- a/example/node_iterator2.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright David Abrahams 2004. Use, modification and distribution is -// subject to the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include "node_iterator2.hpp" -#include -#include -#include -#include -#include -#include - -int main() -{ - std::auto_ptr > nodes(new node(42)); - nodes->append(new node(" is greater than ")); - nodes->append(new node(13)); - - // Check interoperability - assert(node_iterator(nodes.get()) == node_const_iterator(nodes.get())); - assert(node_const_iterator(nodes.get()) == node_iterator(nodes.get())); - - assert(node_iterator(nodes.get()) != node_const_iterator()); - assert(node_const_iterator(nodes.get()) != node_iterator()); - - std::copy( - node_iterator(nodes.get()), node_iterator() - , std::ostream_iterator(std::cout, " ") - ); - std::cout << std::endl; - - std::for_each( - node_iterator(nodes.get()), node_iterator() - , boost::mem_fn(&node_base::twice) - ); - - std::copy( - node_const_iterator(nodes.get()), node_const_iterator() - , std::ostream_iterator(std::cout, "/") - ); - std::cout << std::endl; - return 0; -} diff --git a/example/node_iterator2.hpp b/example/node_iterator2.hpp deleted file mode 100755 index 194cf95..0000000 --- a/example/node_iterator2.hpp +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright David Abrahams 2004. Use, modification and distribution is -// subject to the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#ifndef NODE_ITERATOR2_DWA2004110_HPP -# define NODE_ITERATOR2_DWA2004110_HPP - -# include "node.hpp" -# include - -# ifndef BOOST_NO_SFINAE -# include -# include -# endif - -namespace impl -{ - template - class node_iterator - : public boost::iterator_facade< - node_iterator - , Value - , boost::forward_traversal_tag - > - { - private: - enum enabler {}; - - public: - node_iterator() - : m_node(0) - {} - - explicit node_iterator(Value* p) - : m_node(p) - {} - - template - node_iterator( - node_iterator const& other -# ifndef BOOST_NO_SFINAE - , typename boost::enable_if,enabler*>::type = 0 -# endif - ) - : m_node(other.m_node) - { - } - - - friend class boost::iterator_core_access; -# if !BOOST_WORKAROUND(__GNUC__, == 2) - private: // GCC2 can't even grant that friendship to template member functions -# endif - template - bool equal(node_iterator const& other) const - { return this->m_node == other.m_node; } - - public: - void increment() - { m_node = m_node->next(); } - - Value& dereference() const - { return *m_node; } - -# ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS - public: -# else - template friend class node_iterator; -# endif - Value* m_node; - }; -} - -typedef impl::node_iterator node_iterator; -typedef impl::node_iterator node_const_iterator; - -#endif // NODE_ITERATOR2_DWA2004110_HPP diff --git a/example/reverse_iterator.cpp b/example/reverse_iterator.cpp deleted file mode 100644 index 522cb9f..0000000 --- a/example/reverse_iterator.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -#include -#include -#include - -int main() -{ - int x[] = { 1, 2, 3, 4 }; - boost::reverse_iterator first(x + 4), last(x); - std::copy(first, last, std::ostream_iterator(std::cout, " ")); - std::cout << std::endl; - return 0; -} diff --git a/include/boost/function_output_iterator.hpp b/include/boost/function_output_iterator.hpp deleted file mode 100644 index 764c118..0000000 --- a/include/boost/function_output_iterator.hpp +++ /dev/null @@ -1,55 +0,0 @@ -// (C) Copyright Jeremy Siek 2001. Permission to copy, use, modify, -// sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. - -// Revision History: - -// 27 Feb 2001 Jeremy Siek -// Initial checkin. - -#ifndef BOOST_FUNCTION_OUTPUT_ITERATOR_HPP -#define BOOST_FUNCTION_OUTPUT_ITERATOR_HPP - -#include - -namespace boost { - - template - class function_output_iterator { - typedef function_output_iterator self; - public: - typedef std::output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - explicit function_output_iterator(const UnaryFunction& f = UnaryFunction()) - : m_f(f) {} - - struct output_proxy { - output_proxy(UnaryFunction& f) : m_f(f) { } - template output_proxy& operator=(const T& value) { - m_f(value); - return *this; - } - UnaryFunction& m_f; - }; - output_proxy operator*() { return output_proxy(m_f); } - self& operator++() { return *this; } - self& operator++(int) { return *this; } - private: - UnaryFunction m_f; - }; - - template - inline function_output_iterator - make_function_output_iterator(const UnaryFunction& f = UnaryFunction()) { - return function_output_iterator(f); - } - -} // namespace boost - -#endif // BOOST_FUNCTION_OUTPUT_ITERATOR_HPP diff --git a/include/boost/half_open_range.hpp b/include/boost/half_open_range.hpp deleted file mode 100644 index c281846..0000000 --- a/include/boost/half_open_range.hpp +++ /dev/null @@ -1,426 +0,0 @@ -// (C) Copyright Jeremy Siek and David Abrahams 2000-2001. Permission to copy, -// use, modify, sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided "as is" -// without express or implied warranty, and with no claim as to its suitability -// for any purpose. -// -// Revision History: -// 11 Feb 2001 Use new iterator_adaptor interface, Fixes for Borland. -// (Dave Abrahams) -// 04 Feb 2001 Support for user-defined iterator categories (Dave Abrahams) -// 30 Jan 2001 Initial Checkin (Dave Abrahams) - -#ifndef BOOST_HALF_OPEN_RANGE_HPP_ -# define BOOST_HALF_OPEN_RANGE_HPP_ - -# include -# include -# include -# include -# include -# include -# include - -namespace boost { - -namespace detail { - - // Template class choose_finish -- allows us to maintain the invariant that - // start() <= finish() on half_open_range specializations that support random - // access. -#ifdef __MWERKS__ - template - const T& choose_finish(const T&, const T& finish, std::input_iterator_tag) - { - return finish; - } - - template - const T& choose_finish(const T&, const T& finish, std::output_iterator_tag) - { - return finish; - } - - template - const T& choose_finish(const T& start, const T& finish, std::random_access_iterator_tag) - { - return finish < start ? start : finish; - } -#else - template struct finish_chooser; - - template <> - struct finish_chooser - { - template - struct rebind - { - static T choose(const T&, const T& finish) - { return finish; } - }; - }; - - template <> - struct finish_chooser - { - template - struct rebind - { - static T choose(const T& start, const T& finish) - { return finish < start ? start : finish; } - }; - }; - - template - struct choose_finish - { - static const Incrementable choose(const Incrementable& start, const Incrementable& finish) - { - return finish_chooser<( - ::boost::is_convertible::value - )>::template rebind::choose(start, finish); - } - }; -#endif -} - -template -struct half_open_range -{ - typedef typename counting_iterator_generator::type iterator; - - private: // utility type definitions - // Using iter_t prevents compiler confusion with boost::iterator - typedef typename counting_iterator_generator::type iter_t; - - typedef std::less less_value; - typedef typename iter_t::iterator_category category; - typedef half_open_range self; - - public: - typedef iter_t const_iterator; - 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 iterator::difference_type size_type; - - half_open_range(Incrementable start, Incrementable finish) - : m_start(start), - m_finish( -#ifndef __MWERKS__ - detail::choose_finish::choose(start, finish) -#else - detail::choose_finish(start, finish, category()) -#endif - ) - {} - - // Implicit conversion from std::pair allows us - // to accept the results of std::equal_range(), for example. - half_open_range(const std::pair& x) - : m_start(x.first), - m_finish( -#ifndef __MWERKS__ - detail::choose_finish::choose(x.first, x.second) -#else - detail::choose_finish(x.first, x.second, category()) -#endif - ) - {} - - half_open_range& operator=(const self& x) - { - m_start = x.m_start; - m_finish = x.m_finish; - return *this; - } - - half_open_range& operator=(const std::pair& x) - { - m_start = x.first; - m_finish = -#ifndef __MWERKS__ - detail::choose_finish::choose(x.first, x.second); -#else - detail::choose_finish(x.first, x.second, category(); -#endif - } - - iterator begin() const { return iterator(m_start); } - iterator end() const { return iterator(m_finish); } - - Incrementable front() const { assert(!this->empty()); return m_start; } - Incrementable back() const { assert(!this->empty()); return boost::prior(m_finish); } - - Incrementable start() const { return m_start; } - Incrementable finish() const { return m_finish; } - - size_type size() const { return boost::detail::distance(begin(), end()); } - - bool empty() const - { - return m_finish == m_start; - } - - void swap(half_open_range& x) { - std::swap(m_start, x.m_start); - std::swap(m_finish, x.m_finish); - } - - public: // functions requiring random access elements - - // REQUIRES: x is reachable from this->front() - bool contains(const value_type& x) const - { - BOOST_STATIC_ASSERT((boost::is_same::value)); - return !less_value()(x, m_start) && less_value()(x, m_finish); - } - - bool contains(const half_open_range& x) const - { - BOOST_STATIC_ASSERT((boost::is_same::value)); - return x.empty() || !less_value()(x.m_start, m_start) && !less_value()(m_finish, x.m_finish); - } - - bool intersects(const half_open_range& x) const - { - BOOST_STATIC_ASSERT((boost::is_same::value)); - return less_value()( - less_value()(this->m_start, x.m_start) ? x.m_start : this->m_start, - less_value()(this->m_finish, x.m_finish) ? this->m_finish : x.m_finish); - } - - half_open_range& operator&=(const half_open_range& x) - { - BOOST_STATIC_ASSERT((boost::is_same::value)); - - if (less_value()(this->m_start, x.m_start)) - this->m_start = x.m_start; - - if (less_value()(x.m_finish, this->m_finish)) - this->m_finish = x.m_finish; - - if (less_value()(this->m_finish, this->m_start)) - this->m_start = this->m_finish; - - return *this; - } - - half_open_range& operator|=(const half_open_range& x) - { - BOOST_STATIC_ASSERT((boost::is_same::value)); - - if (!x.empty()) - { - if (this->empty()) - { - *this = x; - } - else - { - if (less_value()(x.m_start, this->m_start)) - this->m_start = x.m_start; - - if (less_value()(this->m_finish, x.m_finish)) - this->m_finish = x.m_finish; - } - } - return *this; - } - - // REQUIRES: x is reachable from this->front() - const_iterator find(const value_type& x) const - { - BOOST_STATIC_ASSERT((boost::is_same::value)); - - return const_iterator(this->contains(x) ? x : m_finish); - } - - // REQUIRES: index >= 0 && index < size() - value_type operator[](size_type index) const - { - assert(index >= 0 && index < size()); - return m_start + index; - } - - value_type at(size_type index) const - { - if (index < 0 || index >= size()) - throw std::out_of_range(std::string("half_open_range")); - return m_start + index; - } - - private: // data members - Incrementable m_start, m_finish; -}; - -template -half_open_range operator|( - half_open_range x, - const half_open_range& y) -{ - return x |= y; -} - -template -half_open_range operator&( - half_open_range x, - const half_open_range& y) -{ - return x &= y; -} - -template -inline bool operator==( - const half_open_range& x, - const half_open_range& y) -{ - const bool y_empty = y.empty(); - return x.empty() ? y_empty : !y_empty && x.start() == y.start() && x.finish() == y.finish(); -} - -template -inline bool operator!=( - const half_open_range& x, - const half_open_range& y) -{ - return !(x == y); -} - -template -inline half_open_range -make_half_open_range(Incrementable first, Incrementable last) -{ - return half_open_range(first, last); -} - -template -bool intersects( - const half_open_range& x, - const half_open_range& y) -{ - return x.intersects(y); -} - -template -bool contains( - const half_open_range& x, - const half_open_range& y) -{ - return x.contains(y); -} - -} // namespace boost - -#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - -namespace std { -template struct less > - : binary_function< - boost::half_open_range, - boost::half_open_range,bool> -{ - bool operator()( - const boost::half_open_range& x, - const boost::half_open_range& y) const - { - less cmp; - return !y.empty() && ( - cmp(x.start(), y.start()) - || !cmp(y.start(), x.start()) - && cmp(x.finish(), y.finish())); - } -}; - -template struct less_equal > - : binary_function< - boost::half_open_range, - boost::half_open_range,bool> -{ - bool operator()( - const boost::half_open_range& x, - const boost::half_open_range& y) const - { - typedef boost::half_open_range range; - less cmp; - return !cmp(y,x); - } -}; -template struct greater > - : binary_function< - boost::half_open_range, - boost::half_open_range,bool> -{ - bool operator()( - const boost::half_open_range& x, - const boost::half_open_range& y) const - { - typedef boost::half_open_range range; - less cmp; - return cmp(y,x); - } -}; - -template struct greater_equal > - : binary_function< - boost::half_open_range, - boost::half_open_range,bool> -{ - bool operator()( - const boost::half_open_range& x, - const boost::half_open_range& y) const - { - typedef boost::half_open_range range; - less cmp; - return !cmp(x,y); - } -}; -} // namespace std - -#else - -namespace boost { -// Can't partially specialize std::less et al, so we must provide the operators -template -bool operator<(const half_open_range& x, - const half_open_range& y) -{ - return !y.empty() && ( - x.empty() || std::less()(x.start(), y.start()) - || !std::less()(y.start(), x.start()) - && std::less()(x.finish(), y.finish())); -} - -template -bool operator>(const half_open_range& x, - const half_open_range& y) -{ - return y < x; -} - -template -bool operator<=(const half_open_range& x, - const half_open_range& y) -{ - return !(y < x); -} - -template -bool operator>=(const half_open_range& x, - const half_open_range& y) -{ - return !(x < y); -} -} // namespace boost - -#endif - - -#endif // BOOST_HALF_OPEN_RANGE_HPP_ diff --git a/include/boost/iterator.hpp b/include/boost/iterator.hpp deleted file mode 100644 index 8b82097..0000000 --- a/include/boost/iterator.hpp +++ /dev/null @@ -1,60 +0,0 @@ -// interator.hpp workarounds for non-conforming standard libraries ---------// - -// (C) Copyright Boost.org 2000. Permission to copy, use, modify, sell and -// distribute this software is granted provided this copyright notice appears -// in all copies. This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. - -// See http://www.boost.org/libs/utility for documentation. - -// Revision History -// 12 Jan 01 added for std::ptrdiff_t (Jens Maurer) -// 28 Jun 00 Workarounds to deal with known MSVC bugs (David Abrahams) -// 26 Jun 00 Initial version (Jeremy Siek) - -#ifndef BOOST_ITERATOR_HPP -#define BOOST_ITERATOR_HPP - -#include -#include // std::ptrdiff_t -#include - -namespace boost -{ -# if defined(BOOST_NO_STD_ITERATOR) && !defined(BOOST_MSVC_STD_ITERATOR) - template - struct iterator - { - typedef T value_type; - typedef Distance difference_type; - typedef Pointer pointer; - typedef Reference reference; - typedef Category iterator_category; - }; -# else - - // declare iterator_base in namespace detail to work around MSVC bugs which - // prevent derivation from an identically-named class in a different namespace. - namespace detail { - template -# if !defined(BOOST_MSVC_STD_ITERATOR) - struct iterator_base : std::iterator {}; -# else - struct iterator_base : std::iterator - { - typedef Reference reference; - typedef Pointer pointer; - typedef Distance difference_type; - }; -# endif - } - - template - struct iterator : detail::iterator_base {}; -# endif -} // namespace boost - -#endif // BOOST_ITERATOR_HPP diff --git a/include/boost/iterator/counting_iterator.hpp b/include/boost/iterator/counting_iterator.hpp deleted file mode 100644 index 0a55967..0000000 --- a/include/boost/iterator/counting_iterator.hpp +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright David Abrahams 2003. Permission to copy, use, -// modify, sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. -#ifndef COUNTING_ITERATOR_DWA200348_HPP -# define COUNTING_ITERATOR_DWA200348_HPP - -# include -# include -# include -# include -# include -# include - -namespace boost { - -template < - class Incrementable - , class CategoryOrTraversal - , class Difference -> -class counting_iterator; - -namespace detail -{ - // Try to detect numeric types at compile time in ways compatible - // with the limitations of the compiler and library. - template - struct is_numeric_impl - { - // For a while, this wasn't true, but we rely on it below. This is a regression assert. - BOOST_STATIC_ASSERT(::boost::is_integral::value); - -# ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS - - BOOST_STATIC_CONSTANT(bool, value = std::numeric_limits::is_specialized); - -# else - -# if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) - BOOST_STATIC_CONSTANT( - bool, value = ( - boost::is_convertible::value - && boost::is_convertible::value - )); -# else - BOOST_STATIC_CONSTANT(bool, value = ::boost::is_arithmetic::value); -# endif - -# endif - }; - - template - struct is_numeric - : mpl::bool_<(::boost::detail::is_numeric_impl::value)> - {}; - -# if defined(BOOST_HAS_LONG_LONG) - template <> - struct is_numeric - : mpl::true_ {}; - - template <> - struct is_numeric - : mpl::true_ {}; -# endif - - // Some compilers fail to have a numeric_limits specialization - template <> - struct is_numeric - : mpl::true_ {}; - - template - struct numeric_difference - { - typedef typename boost::detail::numeric_traits::difference_type type; - }; - - BOOST_STATIC_ASSERT(is_numeric::value); - - template - struct counting_iterator_base - { - typedef typename detail::ia_dflt_help< - CategoryOrTraversal - , mpl::apply_if< - is_numeric - , mpl::identity - , iterator_traversal - > - >::type traversal; - - typedef typename detail::ia_dflt_help< - Difference - , mpl::apply_if< - is_numeric - , numeric_difference - , iterator_difference - > - >::type difference; - - typedef iterator_adaptor< - counting_iterator // self - , Incrementable // Base - , Incrementable // Value -# ifndef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY - const // MSVC won't strip this. Instead we enable Thomas' - // criterion (see boost/iterator/detail/facade_iterator_category.hpp) -# endif - , traversal - , Incrementable const& // reference - , difference - > type; - }; - - // Template class distance_policy_select -- choose a policy for computing the - // distance between counting_iterators at compile-time based on whether or not - // the iterator wraps an integer or an iterator, using "poor man's partial - // specialization". - - template struct distance_policy_select; - - // A policy for wrapped iterators - template - struct iterator_distance - { - static Difference distance(Incrementable1 x, Incrementable2 y) - { - return boost::detail::distance(x, y); - } - }; - - // A policy for wrapped numbers - template - struct number_distance - { - static Difference distance(Incrementable1 x, Incrementable2 y) - { - return numeric_distance(x, y); - } - }; -} - -template < - class Incrementable - , class CategoryOrTraversal = use_default - , class Difference = use_default -> -class counting_iterator - : public detail::counting_iterator_base< - Incrementable, CategoryOrTraversal, Difference - >::type -{ - typedef typename detail::counting_iterator_base< - Incrementable, CategoryOrTraversal, Difference - >::type super_t; - - friend class iterator_core_access; - - public: - typedef typename super_t::difference_type difference_type; - - counting_iterator() { } - - counting_iterator(counting_iterator const& rhs) : super_t(rhs.base()) {} - - counting_iterator(Incrementable x) - : super_t(x) - { - } - -# if 0 - template - counting_iterator( - counting_iterator const& t - , typename enable_if_convertible::type* = 0 - ) - : super_t(t.base()) - {} -# endif - - private: - - typename super_t::reference dereference() const - { - return this->base_reference(); - } - - template - difference_type - distance_to(counting_iterator const& y) const - { - typedef typename mpl::if_< - detail::is_numeric - , detail::number_distance - , detail::iterator_distance - >::type d; - - return d::distance(this->base(), y.base()); - } -}; - -// Manufacture a counting iterator for an arbitrary incrementable type -template -inline counting_iterator -make_counting_iterator(Incrementable x) -{ - typedef counting_iterator result_t; - return result_t(x); -} - - -} // namespace boost::iterator - -#endif // COUNTING_ITERATOR_DWA200348_HPP diff --git a/include/boost/iterator/detail/any_conversion_eater.hpp b/include/boost/iterator/detail/any_conversion_eater.hpp deleted file mode 100755 index 25fa644..0000000 --- a/include/boost/iterator/detail/any_conversion_eater.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright David Abrahams 2003. Use, modification and distribution is -// subject to the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#ifndef ANY_CONVERSION_EATER_DWA20031117_HPP -# define ANY_CONVERSION_EATER_DWA20031117_HPP - -namespace boost { namespace detail { - -// This type can be used in traits to "eat" up the one user-defined -// implicit conversion allowed. -struct any_conversion_eater -{ - template - any_conversion_eater(T const&); -}; - -}} // namespace boost::detail - -#endif // ANY_CONVERSION_EATER_DWA20031117_HPP diff --git a/include/boost/iterator/detail/categories.hpp b/include/boost/iterator/detail/categories.hpp deleted file mode 100644 index 841ac4c..0000000 --- a/include/boost/iterator/detail/categories.hpp +++ /dev/null @@ -1 +0,0 @@ -#error obsolete diff --git a/include/boost/iterator/detail/config_def.hpp b/include/boost/iterator/detail/config_def.hpp deleted file mode 100644 index 37cdf6d..0000000 --- a/include/boost/iterator/detail/config_def.hpp +++ /dev/null @@ -1,125 +0,0 @@ -// (C) Copyright David Abrahams 2002. -// (C) Copyright Jeremy Siek 2002. -// (C) Copyright Thomas Witt 2002. -// Permission to copy, use, modify, -// sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. - -// no include guard multiple inclusion intended - -// -// This is a temporary workaround until the bulk of this is -// available in boost config. -// 23/02/03 thw -// - -#include // for prior -#include - -#ifdef BOOST_ITERATOR_CONFIG_DEF -# error you have nested config_def #inclusion. -#else -# define BOOST_ITERATOR_CONFIG_DEF -#endif - -#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ - || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x531)) - -// Recall that in general, compilers without partial specialization -// can't strip constness. Consider counting_iterator, which normally -// passes a const Value to iterator_facade. As a result, any code -// which makes a std::vector of the iterator's value_type will fail -// when its allocator declares functions overloaded on reference and -// const_reference (the same type). -// -// Furthermore, Borland 5.5.1 drops constness in enough ways that we -// end up using a proxy for operator[] when we otherwise shouldn't. -// Using reference constness gives it an extra hint that it can -// return the value_type from operator[] directly, but is not -// strictly neccessary. Not sure how best to resolve this one. - -# define BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY 1 - -#endif - -#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) \ - || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x531)) \ - || (BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 700) && defined(_MSC_VER)) -# define BOOST_NO_LVALUE_RETURN_DETECTION - -# if 0 // test code - struct v {}; - - typedef char (&no)[3]; - - template - no foo(T const&, ...); - - template - char foo(T&, int); - - - struct value_iterator - { - v operator*() const; - }; - - template - struct lvalue_deref_helper - { - static T& x; - enum { value = (sizeof(foo(*x,0)) == 1) }; - }; - - int z2[(lvalue_deref_helper::value == 1) ? 1 : -1]; - int z[(lvalue_deref_helper::value) == 1 ? -1 : 1 ]; -# endif - -#endif - -#if BOOST_WORKAROUND(__MWERKS__, <=0x2407) -# define BOOST_NO_IS_CONVERTIBLE // "is_convertible doesn't work for simple types" -#endif - -#if BOOST_WORKAROUND(__GNUC__, == 2) \ - || BOOST_WORKAROUND(__GNUC__, == 3) && BOOST_WORKAROUND(__GNUC_MINOR__, < 4) && !defined(__EDG_VERSION__) \ - || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) -# define BOOST_NO_IS_CONVERTIBLE_TEMPLATE // The following program fails to compile: - -# if 0 // test code - #include - template - struct foo - { - foo(T); - - template - foo(foo const& other) : p(other.p) { } - - T p; - }; - - bool x = boost::is_convertible, foo >::value; -# endif - -#endif - -#if BOOST_WORKAROUND(__GNUC__, == 2 && __GNUC_MINOR__ == 95) \ - || BOOST_WORKAROUND(__MWERKS__, <= 0x2407) \ - || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) -# define BOOST_ITERATOR_NO_MPL_AUX_HAS_XXX // "MPL's has_xxx facility doesn't work" -#endif - -#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_IS_CONVERTIBLE) || defined(BOOST_NO_IS_CONVERTIBLE_TEMPLATE) -# define BOOST_NO_STRICT_ITERATOR_INTEROPERABILITY -#endif - -# if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) -# define BOOST_ARG_DEPENDENT_TYPENAME typename -# else -# define BOOST_ARG_DEPENDENT_TYPENAME -# endif - -// no include guard multiple inclusion intended diff --git a/include/boost/iterator/detail/config_undef.hpp b/include/boost/iterator/detail/config_undef.hpp deleted file mode 100644 index 535b486..0000000 --- a/include/boost/iterator/detail/config_undef.hpp +++ /dev/null @@ -1,26 +0,0 @@ -// (C) Copyright Thomas Witt 2002. -// Permission to copy, use, modify, -// sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. - -// no include guard multiple inclusion intended - -// -// This is a temporary workaround until the bulk of this is -// available in boost config. -// 23/02/03 thw -// - -#undef BOOST_NO_IS_CONVERTIBLE -#undef BOOST_NO_IS_CONVERTIBLE_TEMPLATE -#undef BOOST_NO_STRICT_ITERATOR_INTEROPERABILITY -#undef BOOST_ARG_DEPENDENT_TYPENAME -#undef BOOST_NO_LVALUE_RETURN_DETECTION - -#ifdef BOOST_ITERATOR_CONFIG_DEF -# undef BOOST_ITERATOR_CONFIG_DEF -#else -# error missing or nested #include config_def -#endif diff --git a/include/boost/iterator/detail/enable_if.hpp b/include/boost/iterator/detail/enable_if.hpp deleted file mode 100644 index f0a7bc7..0000000 --- a/include/boost/iterator/detail/enable_if.hpp +++ /dev/null @@ -1,88 +0,0 @@ -// (C) Copyright David Abrahams 2002. -// (C) Copyright Jeremy Siek 2002. -// (C) Copyright Thomas Witt 2002. -// Permission to copy, use, modify, -// sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. -#ifndef BOOST_ENABLE_IF_23022003THW_HPP -#define BOOST_ENABLE_IF_23022003THW_HPP - -#include -#include - -#include - -// -// Boost iterators uses its own enable_if cause we need -// special semantics for deficient compilers. -// 23/02/03 thw -// - -namespace boost -{ - - namespace iterators - { - // - // Base machinery for all kinds of enable if - // - template - struct enabled - { - template - struct base - { - typedef T type; - }; - }; - - // - // For compilers that don't support "Substitution Failure Is Not An Error" - // enable_if falls back to always enabled. See comments - // on operator implementation for consequences. - // - template<> - struct enabled - { - template - struct base - { -#ifdef BOOST_NO_SFINAE - - typedef T type; - - // This way to do it would give a nice error message containing - // invalid overload, but has the big disadvantage that - // there is no reference to user code in the error message. - // - // struct invalid_overload; - // typedef invalid_overload type; - // -#endif - }; - }; - - - template - struct enable_if -# if !defined(BOOST_NO_SFINAE) && !defined(BOOST_NO_IS_CONVERTIBLE) - : enabled<(Cond::value)>::template base -# else - : mpl::identity -# endif - { -# if BOOST_WORKAROUND(BOOST_MSVC, <= 1200) - typedef Return type; -# endif - }; - - } // namespace iterators - -} // namespace boost - -#include - -#endif // BOOST_ENABLE_IF_23022003THW_HPP diff --git a/include/boost/iterator/detail/facade_iterator_category.hpp b/include/boost/iterator/detail/facade_iterator_category.hpp deleted file mode 100755 index dd7de98..0000000 --- a/include/boost/iterator/detail/facade_iterator_category.hpp +++ /dev/null @@ -1,214 +0,0 @@ -// Copyright David Abrahams 2003. Use, modification and distribution is -// subject to the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#ifndef FACADE_ITERATOR_CATEGORY_DWA20031118_HPP -# define FACADE_ITERATOR_CATEGORY_DWA20031118_HPP - -# include - -# include - -# include // used in iterator_tag inheritance logic -# include -# include -# include -# include - -# include -# include -# include -# include - -# include - -# include // try to keep this last - -# ifdef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY -# include -# endif - -// -// iterator_category deduction for iterator_facade -// - -// forward declaration -namespace boost { struct use_default; } - -namespace boost { namespace detail { - -struct input_output_iterator_tag - : std::input_iterator_tag -{ - // Using inheritance for only input_iterator_tag helps to avoid - // ambiguities when a stdlib implementation dispatches on a - // function which is overloaded on both input_iterator_tag and - // output_iterator_tag, as STLPort does, in its __valid_range - // function. I claim it's better to avoid the ambiguity in these - // cases. - operator std::output_iterator_tag() const - { - return std::output_iterator_tag(); - } -}; - -// -// True iff the user has explicitly disabled writability of this -// iterator. Pass the iterator_facade's Value parameter and its -// nested ::reference type. -// -template -struct iterator_writability_disabled -# ifdef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY // Adding Thomas' logic? - : mpl::or_< - is_const - , python::detail::is_reference_to_const - , is_const - > -# else - : is_const -# endif -{}; - - -// -// Convert an iterator_facade's traversal category, Value parameter, -// and ::reference type to an appropriate old-style category. -// -// If writability has been disabled per the above metafunction, the -// result will not be convertible to output_iterator_tag. -// -// Otherwise, if Traversal == single_pass_traversal_tag, the following -// conditions will result in a tag that is convertible both to -// input_iterator_tag and output_iterator_tag: -// -// 1. Reference is a reference to non-const -// 2. Reference is not a reference and is convertible to Value -// -template -struct iterator_facade_default_category - : mpl::apply_if< - mpl::and_< - is_reference - , is_convertible - > - , mpl::apply_if< - is_convertible - , mpl::identity - , mpl::if_< - is_convertible - , std::bidirectional_iterator_tag - , std::forward_iterator_tag - > - > - , typename mpl::apply_if< - mpl::and_< - is_convertible - - // check for readability - , is_convertible - > - , mpl::if_< - iterator_writability_disabled - , std::input_iterator_tag - , input_output_iterator_tag - > - - , mpl::identity - > - > -{ -}; - -// True iff T is convertible to an old-style iterator category. -template -struct is_iterator_category - : mpl::or_< - is_convertible - , is_convertible - > -{ -}; - -template -struct is_iterator_traversal - : is_convertible -{}; - -// -// A composite iterator_category tag convertible to Category (a pure -// old-style category) and Traversal (a pure traversal tag). -// Traversal must be a strict increase of the traversal power given by -// Category. -// -template -struct iterator_category_with_traversal - : Category, Traversal -{ -# if 0 - // Because of limitations on multiple user-defined conversions, - // this should be a good test of whether convertibility is enough - // in the spec, or whether we need to specify inheritance. - operator Category() const { return Category(); } - operator Traversal() const { return Traversal(); } -# endif - -# if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) - // Make sure this isn't used to build any categories where - // convertibility to Traversal is redundant. Should just use the - // Category element in that case. - BOOST_STATIC_ASSERT( - !(is_convertible< - typename iterator_category_to_traversal::type - , Traversal - >::value)); - - BOOST_STATIC_ASSERT(is_iterator_category::value); - BOOST_STATIC_ASSERT(!is_iterator_category::value); - BOOST_STATIC_ASSERT(!is_iterator_traversal::value); -# if !BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310)) - BOOST_STATIC_ASSERT(is_iterator_traversal::value); -# endif -# endif -}; - -// Computes an iterator_category tag whose traversal is Traversal and -// which is appropriate for an iterator -template -struct facade_iterator_category_impl -{ -# if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) - BOOST_STATIC_ASSERT(!is_iterator_category::value); -# endif - - typedef typename iterator_facade_default_category< - Traversal,ValueParam,Reference - >::type category; - - typedef typename mpl::if_< - is_same< - Traversal - , typename iterator_category_to_traversal::type - > - , category - , iterator_category_with_traversal - >::type type; -}; - -// -// Compute an iterator_category for iterator_facade -// -template -struct facade_iterator_category - : mpl::apply_if< - is_iterator_category - , mpl::identity // old-style categories are fine as-is - , facade_iterator_category_impl - > -{ -}; - -}} // namespace boost::detail - -# include - -#endif // FACADE_ITERATOR_CATEGORY_DWA20031118_HPP diff --git a/include/boost/iterator/detail/minimum_category.hpp b/include/boost/iterator/detail/minimum_category.hpp deleted file mode 100755 index 89d79db..0000000 --- a/include/boost/iterator/detail/minimum_category.hpp +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright David Abrahams 2003. Use, modification and distribution is -// subject to the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#ifndef MINIMUM_CATEGORY_DWA20031119_HPP -# define MINIMUM_CATEGORY_DWA20031119_HPP - -# include -# include - -# include - -namespace boost { namespace detail { -// -// Returns the minimum category type or error_type -// if T1 and T2 are unrelated. -// -// For compilers not supporting is_convertible this only -// works with the new boost return and traversal category -// types. The exact boost _types_ are required. No derived types -// will work. -// -// -template -struct minimum_category_impl -# if BOOST_WORKAROUND(BOOST_MSVC, == 1200) -{ - typedef void type; -} -# endif -; - -template -struct error_not_related_by_convertibility; - -template <> -struct minimum_category_impl -{ - template struct apply - { - typedef T2 type; - }; -}; - -template <> -struct minimum_category_impl -{ - template struct apply - { - typedef T1 type; - }; -}; - -template <> -struct minimum_category_impl -{ - template struct apply - { - BOOST_STATIC_ASSERT((is_same::value)); - typedef T1 type; - }; -}; - -template <> -struct minimum_category_impl -{ - template struct apply - : error_not_related_by_convertibility - { - }; -}; - -template -struct minimum_category -{ - typedef minimum_category_impl< -# if BOOST_WORKAROUND(BOOST_MSVC, == 1200) // ETI workaround - is_same::value || -# endif - ::boost::is_convertible::value - , ::boost::is_convertible::value -# if BOOST_WORKAROUND(BOOST_MSVC, == 1200) // ETI workaround - || is_same::value -# endif - > outer; - - typedef typename outer::template apply inner; - typedef typename inner::type type; - - BOOST_MPL_AUX_LAMBDA_SUPPORT(2,minimum_category,(T1,T2)) -}; - -template <> -struct minimum_category -{ - template - struct apply : minimum_category - {}; -}; - -# if BOOST_WORKAROUND(BOOST_MSVC, == 1200) // ETI workaround -template <> -struct minimum_category -{ - typedef int type; -}; -# endif - -}} // namespace boost::detail - -#endif // MINIMUM_CATEGORY_DWA20031119_HPP diff --git a/include/boost/iterator/filter_iterator.hpp b/include/boost/iterator/filter_iterator.hpp deleted file mode 100644 index fee0184..0000000 --- a/include/boost/iterator/filter_iterator.hpp +++ /dev/null @@ -1,137 +0,0 @@ -// (C) Copyright David Abrahams 2002. -// (C) Copyright Jeremy Siek 2002. -// (C) Copyright Thomas Witt 2002. -// Permission to copy, use, modify, -// sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. -#ifndef BOOST_FILTER_ITERATOR_23022003THW_HPP -#define BOOST_FILTER_ITERATOR_23022003THW_HPP - -#include -#include -#include - -#include -#include - -namespace boost -{ - template - class filter_iterator; - - namespace detail - { - template - struct filter_iterator_base - { - typedef iterator_adaptor< - filter_iterator - , Iterator - , use_default - , typename mpl::if_< - is_convertible< - typename iterator_traversal::type - , bidirectional_traversal_tag - > - , forward_traversal_tag - , use_default - >::type - > type; - }; - } - - template - class filter_iterator - : public detail::filter_iterator_base::type - { - typedef typename detail::filter_iterator_base< - Predicate, Iterator - >::type super_t; - - friend class iterator_core_access; - - public: - filter_iterator() { } - - filter_iterator(Predicate f, Iterator x, Iterator end = Iterator()) - : super_t(x), m_predicate(f), m_end(end) - { - satisfy_predicate(); - } - - filter_iterator(Iterator x, Iterator end = Iterator()) - : super_t(x), m_predicate(), m_end(end) - { - // Pro8 is a little too aggressive about instantiating the - // body of this function. -#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) - // Don't allow use of this constructor if Predicate is a - // function pointer type, since it will be 0. - BOOST_STATIC_ASSERT(is_class::value); -#endif - satisfy_predicate(); - } - - template - filter_iterator( - filter_iterator const& t - , typename enable_if_convertible::type* = 0 - ) - : super_t(t.base()), m_predicate(t.predicate()), m_end(t.end()) {} - - Predicate predicate() const { return m_predicate; } - - Iterator end() const { return m_end; } - - private: - void increment() - { - ++(this->base_reference()); - satisfy_predicate(); - } - - void decrement() - { - while(!this->m_predicate(*--(this->base_reference()))){}; - } - - void satisfy_predicate() - { - while (this->base() != this->m_end && !this->m_predicate(*this->base())) - ++(this->base_reference()); - } - - // Probably should be the initial base class so it can be - // optimized away via EBO if it is an empty class. - Predicate m_predicate; - Iterator m_end; - }; - - template - filter_iterator - make_filter_iterator(Predicate f, Iterator x, Iterator end = Iterator()) - { - return filter_iterator(f,x,end); - } - - template - filter_iterator - make_filter_iterator( - typename iterators::enable_if< - is_class - , Iterator - >::type x - , Iterator end = Iterator() -#if BOOST_WORKAROUND(BOOST_MSVC, == 1200) - , Predicate* = 0 -#endif - ) - { - return filter_iterator(x,end); - } - -} // namespace boost - -#endif // BOOST_FILTER_ITERATOR_23022003THW_HPP diff --git a/include/boost/iterator/indirect_iterator.hpp b/include/boost/iterator/indirect_iterator.hpp deleted file mode 100644 index 91c4283..0000000 --- a/include/boost/iterator/indirect_iterator.hpp +++ /dev/null @@ -1,141 +0,0 @@ -// (C) Copyright David Abrahams 2002. -// (C) Copyright Jeremy Siek 2002. -// (C) Copyright Thomas Witt 2002. -// Permission to copy, use, modify, -// sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. -#ifndef BOOST_INDIRECT_ITERATOR_23022003THW_HPP -#define BOOST_INDIRECT_ITERATOR_23022003THW_HPP - -#include -#include - -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#ifdef BOOST_MPL_NO_AUX_HAS_XXX -# include -# include -# include -# include -#endif - -#include // must be last #include - -namespace boost -{ - template - class indirect_iterator; - - namespace detail - { - template - struct indirect_base - { - typedef typename iterator_traits::value_type dereferenceable; - - typedef iterator_adaptor< - indirect_iterator - , Iter - , typename ia_dflt_help< - Value, pointee - >::type - , Category - , typename ia_dflt_help< - Reference - , mpl::apply_if< - is_same - , indirect_reference - , add_reference - > - >::type - , Difference - > type; - }; - - template <> - struct indirect_base {}; - } // namespace detail - - - template < - class Iterator - , class Value = use_default - , class Category = use_default - , class Reference = use_default - , class Difference = use_default - > - class indirect_iterator - : public detail::indirect_base< - Iterator, Value, Category, Reference, Difference - >::type - { - typedef typename detail::indirect_base< - Iterator, Value, Category, Reference, Difference - >::type super_t; - - friend class iterator_core_access; - - public: - indirect_iterator() {} - - indirect_iterator(Iterator iter) - : super_t(iter) {} - - template < - class Iterator2, class Value2, class Category2 - , class Reference2, class Difference2 - > - indirect_iterator( - indirect_iterator< - Iterator2, Value2, Category2, Reference2, Difference2 - > const& y - , typename enable_if_convertible::type* = 0 - ) - : super_t(y.base()) - {} - - private: - typename super_t::reference dereference() const - { -# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) - return const_cast(**this->base()); -# else - return **this->base(); -# endif - } - }; - - template - inline - indirect_iterator make_indirect_iterator(Iter x) - { - return indirect_iterator(x); - } - - template - inline - indirect_iterator make_indirect_iterator(Iter x, Traits* = 0) - { - return indirect_iterator(x); - } - -} // namespace boost - -#include - -#endif // BOOST_INDIRECT_ITERATOR_23022003THW_HPP diff --git a/include/boost/iterator/interoperable.hpp b/include/boost/iterator/interoperable.hpp deleted file mode 100644 index b326250..0000000 --- a/include/boost/iterator/interoperable.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// (C) Copyright David Abrahams 2002. -// (C) Copyright Jeremy Siek 2002. -// (C) Copyright Thomas Witt 2002. -// Permission to copy, use, modify, -// sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. -#ifndef BOOST_INTEROPERABLE_23022003THW_HPP -# define BOOST_INTEROPERABLE_23022003THW_HPP - -# include -# include - -# include - -# include // must appear last - -namespace boost -{ - - // - // Meta function that determines whether two - // iterator types are considered interoperable. - // - // Two iterator types A,B are considered interoperable if either - // A is convertible to B or vice versa. - // This interoperability definition is in sync with the - // standards requirements on constant/mutable container - // iterators (23.1 [lib.container.requirements]). - // - // For compilers that don't support is_convertible - // is_interoperable gives false positives. See comments - // on operator implementation for consequences. - // - template - struct is_interoperable -# ifdef BOOST_NO_STRICT_ITERATOR_INTEROPERABILITY - : mpl::true_ -# else - : mpl::or_< - is_convertible< A, B > - , is_convertible< B, A > > -# endif - { - }; - -} // namespace boost - -# include - -#endif // BOOST_INTEROPERABLE_23022003THW_HPP diff --git a/include/boost/iterator/is_lvalue_iterator.hpp b/include/boost/iterator/is_lvalue_iterator.hpp deleted file mode 100755 index 4938151..0000000 --- a/include/boost/iterator/is_lvalue_iterator.hpp +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright David Abrahams 2003. Use, modification and distribution is -// subject to the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#ifndef IS_LVALUE_ITERATOR_DWA2003112_HPP -# define IS_LVALUE_ITERATOR_DWA2003112_HPP - -#include - -#include -#include - -#include - -// should be the last #includes -#include -#include - -#ifndef BOOST_NO_IS_CONVERTIBLE - -namespace boost { - -namespace detail -{ -#ifndef BOOST_NO_LVALUE_RETURN_DETECTION - // Calling lvalue_preserver( , 0 ) returns a reference - // to the expression's result if is an lvalue, or - // not_an_lvalue() otherwise. - struct not_an_lvalue {}; - - template - T& lvalue_preserver(T&, int); - - template - not_an_lvalue lvalue_preserver(U const&, ...); - -# define BOOST_LVALUE_PRESERVER(expr) lvalue_preserver(expr,0) - -#else - -# define BOOST_LVALUE_PRESERVER(expr) expr - -#endif - - // Guts of is_lvalue_iterator. Value is the iterator's value_type - // and the result is computed in the nested rebind template. - template - struct is_lvalue_iterator_impl - { - // Eat implicit conversions so we don't report true for things - // convertible to Value const& - struct conversion_eater - { - conversion_eater(Value&); - }; - - static char tester(conversion_eater, int); - static char (& tester(any_conversion_eater, ...) )[2]; - - template - struct rebind - { - static It& x; - - BOOST_STATIC_CONSTANT( - bool - , value = ( - sizeof( - is_lvalue_iterator_impl::tester( - BOOST_LVALUE_PRESERVER(*x), 0 - ) - ) == 1 - ) - ); - }; - }; - -#undef BOOST_LVALUE_PRESERVER - - // - // void specializations to handle std input and output iterators - // - template <> - struct is_lvalue_iterator_impl - { - template - struct rebind : boost::mpl::false_ - {}; - }; - -#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS - template <> - struct is_lvalue_iterator_impl - { - template - struct rebind : boost::mpl::false_ - {}; - }; - - template <> - struct is_lvalue_iterator_impl - { - template - struct rebind : boost::mpl::false_ - {}; - }; - - template <> - struct is_lvalue_iterator_impl - { - template - struct rebind : boost::mpl::false_ - {}; - }; -#endif - - // - // This level of dispatching is required for Borland. We might save - // an instantiation by removing it for others. - // - template - struct is_readable_lvalue_iterator_impl - : is_lvalue_iterator_impl< - BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::value_type const - >::template rebind - {}; - - template - struct is_non_const_lvalue_iterator_impl - : is_lvalue_iterator_impl< - BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::value_type - >::template rebind - {}; -} // namespace detail - -// Define the trait with full mpl lambda capability and various broken -// compiler workarounds -BOOST_TT_AUX_BOOL_TRAIT_DEF1( - is_lvalue_iterator,T,::boost::detail::is_readable_lvalue_iterator_impl::value) - -BOOST_TT_AUX_BOOL_TRAIT_DEF1( - is_non_const_lvalue_iterator,T,::boost::detail::is_non_const_lvalue_iterator_impl::value) - -} // namespace boost - -#endif - -#include -#include - -#endif // IS_LVALUE_ITERATOR_DWA2003112_HPP diff --git a/include/boost/iterator/is_readable_iterator.hpp b/include/boost/iterator/is_readable_iterator.hpp deleted file mode 100755 index 60d6ff0..0000000 --- a/include/boost/iterator/is_readable_iterator.hpp +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright David Abrahams 2003. Use, modification and distribution is -// subject to the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#ifndef IS_READABLE_ITERATOR_DWA2003112_HPP -# define IS_READABLE_ITERATOR_DWA2003112_HPP - -#include -#include - -#include -#include - -// should be the last #include -#include - -#ifndef BOOST_NO_IS_CONVERTIBLE - -namespace boost { - -namespace detail -{ - // Guts of is_readable_iterator. Value is the iterator's value_type - // and the result is computed in the nested rebind template. - template - struct is_readable_iterator_impl - { - static char tester(Value&, int); - static char (& tester(any_conversion_eater, ...) )[2]; - - template - struct rebind - { - static It& x; - - BOOST_STATIC_CONSTANT( - bool - , value = ( - sizeof( - is_readable_iterator_impl::tester(*x, 1) - ) == 1 - ) - ); - }; - }; - -#undef BOOST_READABLE_PRESERVER - - // - // void specializations to handle std input and output iterators - // - template <> - struct is_readable_iterator_impl - { - template - struct rebind : boost::mpl::false_ - {}; - }; - -#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS - template <> - struct is_readable_iterator_impl - { - template - struct rebind : boost::mpl::false_ - {}; - }; - - template <> - struct is_readable_iterator_impl - { - template - struct rebind : boost::mpl::false_ - {}; - }; - - template <> - struct is_readable_iterator_impl - { - template - struct rebind : boost::mpl::false_ - {}; - }; -#endif - - // - // This level of dispatching is required for Borland. We might save - // an instantiation by removing it for others. - // - template - struct is_readable_iterator_impl2 - : is_readable_iterator_impl< - BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::value_type const - >::template rebind - {}; -} // namespace detail - -// Define the trait with full mpl lambda capability and various broken -// compiler workarounds -BOOST_TT_AUX_BOOL_TRAIT_DEF1( - is_readable_iterator,T,::boost::detail::is_readable_iterator_impl2::value) - -} // namespace boost - -#endif - -#include - -#endif // IS_READABLE_ITERATOR_DWA2003112_HPP diff --git a/include/boost/iterator/iterator_archetypes.hpp b/include/boost/iterator/iterator_archetypes.hpp deleted file mode 100644 index 5fbdf10..0000000 --- a/include/boost/iterator/iterator_archetypes.hpp +++ /dev/null @@ -1,458 +0,0 @@ -// (C) Copyright Jeremy Siek 2002. Permission to copy, use, modify, -// sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. - -#ifndef BOOST_ITERATOR_ARCHETYPES_HPP -#define BOOST_ITERATOR_ARCHETYPES_HPP - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace boost { - -template -struct access_archetype; - -template -struct traversal_archetype; - -namespace iterator_archetypes -{ - enum { - readable_iterator_bit = 1 - , writable_iterator_bit = 2 - , swappable_iterator_bit = 4 - , lvalue_iterator_bit = 8 - }; - - // Not quite tags, since dispatching wouldn't work. - typedef mpl::int_::type readable_iterator_t; - typedef mpl::int_::type writable_iterator_t; - - typedef mpl::int_< - (readable_iterator_bit|writable_iterator_bit) - >::type readable_writable_iterator_t; - - typedef mpl::int_< - (readable_iterator_bit|lvalue_iterator_bit) - >::type readable_lvalue_iterator_t; - - typedef mpl::int_< - (lvalue_iterator_bit|writable_iterator_bit) - >::type writable_lvalue_iterator_t; - - typedef mpl::int_::type swappable_iterator_t; - typedef mpl::int_::type lvalue_iterator_t; - - template - struct has_access - : mpl::equal_to< - mpl::bitand_ - , Base - > - {}; -} - -namespace detail -{ - template - struct assign_proxy - { - assign_proxy& operator=(T); - }; - - template - struct read_proxy - { - operator T(); - }; - - template - struct read_write_proxy - : read_proxy // Use to inherit from assign_proxy, but that doesn't work. -JGS - { - read_write_proxy& operator=(T); - }; - - template - struct arrow_proxy - { - T const* operator->() const; - }; - - struct no_operator_brackets {}; - - template - struct readable_operator_brackets - { - read_proxy operator[](std::ptrdiff_t n) const; - }; - - template - struct writable_operator_brackets - { - read_write_proxy operator[](std::ptrdiff_t n) const; - }; - - template - struct operator_brackets - : mpl::aux::msvc_eti_base< - typename mpl::apply_if< - is_convertible - , mpl::apply_if< - iterator_archetypes::has_access< - AccessCategory - , iterator_archetypes::writable_iterator_t - > - , mpl::identity > - , mpl::if_< - iterator_archetypes::has_access< - AccessCategory - , iterator_archetypes::readable_iterator_t - > - , readable_operator_brackets - , no_operator_brackets - > - > - , mpl::identity - >::type - >::type - {}; - - template - struct traversal_archetype_impl - { - template struct archetype; - }; - - template - struct traversal_archetype_ - : mpl::aux::msvc_eti_base< - typename traversal_archetype_impl::template archetype - >::type - {}; - - template <> - struct traversal_archetype_impl - { - template - struct archetype - { - typedef void difference_type; - - Derived& operator++(); - Derived operator++(int) const; - }; - }; - - template <> - struct traversal_archetype_impl - { - template - struct archetype - : public equality_comparable< traversal_archetype_ >, - public traversal_archetype_ - { - }; - }; - - template - bool operator==(traversal_archetype_ const&, - traversal_archetype_ const&); - -#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) - // doesn't seem to pick up != from equality_comparable - template - bool operator!=(traversal_archetype_ const&, - traversal_archetype_ const&); -#endif - template <> - struct traversal_archetype_impl - { - template - struct archetype - : public traversal_archetype_ - { - typedef std::ptrdiff_t difference_type; - }; - }; - - template <> - struct traversal_archetype_impl - { - template - struct archetype - : public traversal_archetype_ - { - Derived& operator--(); - Derived operator--(int) const; - }; - }; - - template <> - struct traversal_archetype_impl - { - template - struct archetype - : public partially_ordered >, - public traversal_archetype_ - { - Derived& operator+=(std::ptrdiff_t); - Derived& operator-=(std::ptrdiff_t); - }; - }; - - template - Derived& operator+(traversal_archetype_ const&, - std::ptrdiff_t); - - template - Derived& operator+(std::ptrdiff_t, - traversal_archetype_ const&); - - template - Derived& operator-(traversal_archetype_ const&, - std::ptrdiff_t); - - template - std::ptrdiff_t operator-(traversal_archetype_ const&, - traversal_archetype_ const&); - - template - bool operator<(traversal_archetype_ const&, - traversal_archetype_ const&); - - struct bogus_type; - - template - struct convertible_type - : mpl::if_< is_const, - typename remove_const::type, - bogus_type > - {}; - -} // namespace detail - - -template struct undefined; - -template -struct iterator_access_archetype_impl -{ - template struct archetype; -}; - -template -struct iterator_access_archetype - : mpl::aux::msvc_eti_base< - typename iterator_access_archetype_impl< - AccessCategory - >::template archetype - >::type -{ -}; - -template <> -struct iterator_access_archetype_impl< - iterator_archetypes::readable_iterator_t -> -{ - template - struct archetype - { - typedef typename remove_cv::type value_type; - typedef Value reference; - typedef Value* pointer; - - value_type operator*() const; - - detail::arrow_proxy operator->() const; - }; -}; - -template <> -struct iterator_access_archetype_impl< - iterator_archetypes::writable_iterator_t -> -{ - template - struct archetype - { -# if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) - BOOST_STATIC_ASSERT(!is_const::value); -# endif - typedef void value_type; - typedef void reference; - typedef void pointer; - - detail::assign_proxy operator*() const; - }; -}; - -template <> -struct iterator_access_archetype_impl< - iterator_archetypes::readable_writable_iterator_t -> -{ - template - struct archetype - : public virtual iterator_access_archetype< - Value, iterator_archetypes::readable_iterator_t - > - { - typedef detail::read_write_proxy reference; - - detail::read_write_proxy operator*() const; - }; -}; - -template <> -struct iterator_access_archetype_impl -{ - template - struct archetype - : public virtual iterator_access_archetype< - Value, iterator_archetypes::readable_iterator_t - > - { - typedef Value& reference; - - Value& operator*() const; - Value* operator->() const; - }; -}; - -template <> -struct iterator_access_archetype_impl -{ - template - struct archetype - : public virtual iterator_access_archetype< - Value, iterator_archetypes::readable_lvalue_iterator_t - > - { -# if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) - BOOST_STATIC_ASSERT((!is_const::value)); -# endif - }; -}; - - -template -struct iterator_archetype; - -template -struct traversal_archetype_base - : detail::operator_brackets< - typename remove_cv::type - , AccessCategory - , TraversalCategory - > - , detail::traversal_archetype_< - iterator_archetype - , Value - , TraversalCategory - > -{ -}; - -namespace detail -{ - template - struct iterator_archetype_base - : iterator_access_archetype - , traversal_archetype_base - { - typedef iterator_access_archetype access; - - typedef typename detail::facade_iterator_category< - TraversalCategory - , typename mpl::apply_if< - iterator_archetypes::has_access< - AccessCategory, iterator_archetypes::writable_iterator_t - > - , remove_const - , add_const - >::type - , typename access::reference - >::type iterator_category; - - // Needed for some broken libraries (see below) - typedef boost::iterator< - iterator_category - , Value - , typename traversal_archetype_base< - Value, AccessCategory, TraversalCategory - >::difference_type - , typename access::pointer - , typename access::reference - > workaround_iterator_base; - }; -} - -template -struct iterator_archetype - : public detail::iterator_archetype_base - - // These broken libraries require derivation from std::iterator - // (or related magic) in order to handle iter_swap and other - // iterator operations -# if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, < 310) \ - || BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(0x20101)) - , public detail::iterator_archetype_base< - Value, AccessCategory, TraversalCategory - >::workaround_iterator_base -# endif -{ - // Derivation from std::iterator above caused references to nested - // types to be ambiguous, so now we have to redeclare them all - // here. -# if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, < 310) \ - || BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(0x20101)) - - typedef detail::iterator_archetype_base< - Value,AccessCategory,TraversalCategory - > base; - - typedef typename base::value_type value_type; - typedef typename base::reference reference; - typedef typename base::pointer pointer; - typedef typename base::difference_type difference_type; - typedef typename base::iterator_category iterator_category; -# endif - - iterator_archetype(); - iterator_archetype(iterator_archetype const&); - - iterator_archetype& operator=(iterator_archetype const&); - - // Optional conversion from mutable - // iterator_archetype(iterator_archetype::type, AccessCategory, TraversalCategory> const&); -}; - -} // namespace boost - - -#endif // BOOST_ITERATOR_ARCHETYPES_HPP diff --git a/include/boost/iterator/iterator_categories.hpp b/include/boost/iterator/iterator_categories.hpp deleted file mode 100644 index 0af3714..0000000 --- a/include/boost/iterator/iterator_categories.hpp +++ /dev/null @@ -1,168 +0,0 @@ -// (C) Copyright Jeremy Siek 2002. Permission to copy, use, modify, -// sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. - -#ifndef BOOST_ITERATOR_CATEGORIES_HPP -# define BOOST_ITERATOR_CATEGORIES_HPP - -# include -# include -# include - -# include - -# include -# include -# include -# include - -# include - -# include - -namespace boost { - -// -// Traversal Categories -// - -struct no_traversal_tag {}; - -struct incrementable_traversal_tag {}; - -struct single_pass_traversal_tag - : incrementable_traversal_tag {}; - -struct forward_traversal_tag - : single_pass_traversal_tag {}; - -struct bidirectional_traversal_tag - : forward_traversal_tag {}; - -struct random_access_traversal_tag - : bidirectional_traversal_tag {}; - -namespace detail -{ - // - // Convert a "strictly old-style" iterator category to a traversal - // tag. This is broken out into a separate metafunction to reduce - // the cost of instantiating iterator_category_to_traversal, below, - // for new-style types. - // - template - struct old_category_to_traversal - : mpl::apply_if< - is_convertible - , mpl::identity - , mpl::apply_if< - is_convertible - , mpl::identity - , mpl::apply_if< - is_convertible - , mpl::identity - , mpl::apply_if< - is_convertible - , mpl::identity - , mpl::apply_if< - is_convertible - , mpl::identity - , void - > - > - > - > - > - {}; - -# if BOOST_WORKAROUND(BOOST_MSVC, == 1200) - template <> - struct old_category_to_traversal - { - typedef int type; - }; -# endif - - template - struct pure_traversal_tag - : mpl::apply_if< - is_convertible - , mpl::identity - , mpl::apply_if< - is_convertible - , mpl::identity - , mpl::apply_if< - is_convertible - , mpl::identity - , mpl::apply_if< - is_convertible - , mpl::identity - , mpl::apply_if< - is_convertible - , mpl::identity - , void - > - > - > - > - > - { - }; - -# if BOOST_WORKAROUND(BOOST_MSVC, == 1200) - template <> - struct pure_traversal_tag - { - typedef int type; - }; -# endif - -} // namespace detail - - -// -// Convert an iterator category into a traversal tag -// -template -struct iterator_category_to_traversal - : mpl::apply_if< // if already convertible to a traversal tag, we're done. - is_convertible - , mpl::identity - , detail::old_category_to_traversal - > -{}; - -// Trait to get an iterator's traversal category -template -struct iterator_traversal - : iterator_category_to_traversal< - typename boost::detail::iterator_traits::iterator_category - > -{}; - -# ifdef BOOST_MPL_NO_FULL_LAMBDA_SUPPORT -// Hack because BOOST_MPL_AUX_LAMBDA_SUPPORT doesn't seem to work -// out well. Instantiating the nested apply template also -// requires instantiating iterator_traits on the -// placeholder. Instead we just specialize it as a metafunction -// class. -template <> -struct iterator_traversal -{ - template - struct apply : iterator_traversal - {}; -}; -template <> -struct iterator_traversal - : iterator_traversal -{}; -# endif - -} // namespace boost - -#include - -#endif // BOOST_ITERATOR_CATEGORIES_HPP diff --git a/include/boost/iterator/iterator_concepts.hpp b/include/boost/iterator/iterator_concepts.hpp deleted file mode 100644 index 93e0972..0000000 --- a/include/boost/iterator/iterator_concepts.hpp +++ /dev/null @@ -1,397 +0,0 @@ -// (C) Copyright Jeremy Siek 2002. Permission to copy, use, modify, -// sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. - -#ifndef BOOST_ITERATOR_CONCEPTS_HPP -#define BOOST_ITERATOR_CONCEPTS_HPP - -// Revision History -// 26 Apr 2003 thw -// Adapted to new iterator concepts -// 22 Nov 2002 Thomas Witt -// Added interoperable concept. - -#include -#include - -// Use boost::detail::iterator_traits to work around some MSVC/Dinkumware problems. -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include - -// Use boost/limits to work around missing limits headers on some compilers -#include - -#include - -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. - - // We use this in place of STATIC_ASSERT((is_convertible<...>)) - // because some compilers (CWPro7.x) can't detect convertibility. - // - // Of course, that just gets us a different error at the moment with - // some tests, since new iterator category deduction still depends - // on convertibility detection. We might need some specializations - // to support this compiler. - template - struct static_assert_base_and_derived - { - static_assert_base_and_derived(Target* = (Source*)0) {} - }; - - //=========================================================================== - // Iterator Access Concepts - - template - class ReadableIteratorConcept { - public: - typedef BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::value_type value_type; - typedef BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::reference reference; - - void constraints() { - boost::function_requires< boost::SGIAssignableConcept >(); - boost::function_requires< boost::EqualityComparableConcept >(); - boost::function_requires< - boost::DefaultConstructibleConcept >(); - - reference r = *i; // or perhaps read(x) - value_type v = r; - value_type v2 = *i; - boost::ignore_unused_variable_warning(v); - boost::ignore_unused_variable_warning(v2); - } - Iterator i; - }; - - template < - typename Iterator - , typename ValueType = BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::value_type - > - class WritableIteratorConcept { - public: - - void constraints() { - boost::function_requires< boost::SGIAssignableConcept >(); - boost::function_requires< boost::EqualityComparableConcept >(); - boost::function_requires< - boost::DefaultConstructibleConcept >(); - - *i = v; // a good alternative could be something like write(x, v) - } - ValueType v; - Iterator i; - }; - - template - class SwappableIteratorConcept { - public: - - void constraints() { - std::iter_swap(i1, i2); - } - Iterator i1; - Iterator i2; - }; - - template - class ReadableLvalueIteratorConcept - { - public: - typedef typename boost::detail::iterator_traits::value_type value_type; - typedef typename boost::detail::iterator_traits::reference reference; - - void constraints() - { - boost::function_requires< ReadableIteratorConcept >(); - - typedef boost::mpl::or_< - boost::is_same - , boost::is_same - > correct_reference; - - BOOST_STATIC_ASSERT(correct_reference::value); - - reference v = *i; - boost::ignore_unused_variable_warning(v); - } - Iterator i; - }; - - template - class WritableLvalueIteratorConcept { - public: - typedef typename boost::detail::iterator_traits::value_type value_type; - typedef typename boost::detail::iterator_traits::reference reference; - - void constraints() { - boost::function_requires< - ReadableLvalueIteratorConcept >(); - boost::function_requires< - WritableIteratorConcept >(); - boost::function_requires< - SwappableIteratorConcept >(); - - - BOOST_STATIC_ASSERT((boost::is_same::value)); - } - }; - - //=========================================================================== - // Iterator Traversal Concepts - - template - class IncrementableIteratorConcept { - public: - typedef typename boost::iterator_traversal::type traversal_category; - - void constraints() { - boost::function_requires< boost::SGIAssignableConcept >(); - boost::function_requires< - boost::DefaultConstructibleConcept >(); - - BOOST_STATIC_ASSERT( - (boost::is_convertible< - traversal_category - , boost::incrementable_traversal_tag - >::value - )); - - ++i; - (void)i++; - } - Iterator i; - }; - - template - class SinglePassIteratorConcept { - public: - typedef typename boost::iterator_traversal::type traversal_category; - typedef typename boost::detail::iterator_traits::difference_type difference_type; - - void constraints() { - boost::function_requires< IncrementableIteratorConcept >(); - boost::function_requires< boost::EqualityComparableConcept >(); - - BOOST_STATIC_ASSERT( - (boost::is_convertible< - traversal_category - , boost::single_pass_traversal_tag - >::value - )); - } - }; - - template - class ForwardTraversalConcept { - public: - typedef typename boost::iterator_traversal::type traversal_category; - typedef typename boost::detail::iterator_traits::difference_type difference_type; - - void constraints() { - boost::function_requires< SinglePassIteratorConcept >(); - - typedef boost::mpl::and_< - boost::is_integral, - boost::mpl::bool_< std::numeric_limits::is_signed > - > difference_type_is_signed_integral; - - BOOST_STATIC_ASSERT(difference_type_is_signed_integral::value); - BOOST_STATIC_ASSERT( - (boost::is_convertible< - traversal_category - , boost::forward_traversal_tag - >::value - )); - } - }; - - template - class BidirectionalTraversalConcept { - public: - typedef typename boost::iterator_traversal::type traversal_category; - - void constraints() { - boost::function_requires< ForwardTraversalConcept >(); - - BOOST_STATIC_ASSERT( - (boost::is_convertible< - traversal_category - , boost::bidirectional_traversal_tag - >::value - )); - - --i; - (void)i--; - } - Iterator i; - }; - - template - class RandomAccessTraversalConcept { - public: - typedef typename boost::iterator_traversal::type traversal_category; - typedef typename boost::detail::iterator_traits::difference_type - difference_type; - - void constraints() { - boost::function_requires< BidirectionalTraversalConcept >(); - - 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; - }; - - //=========================================================================== - // Iterator Interoperability Concept - -namespace detail -{ - - template - struct Operations; - - template <> - struct Operations - { - template - static void constraints(Iterator1 const& i1, Iterator2 const& i2) - { - // no interoperability constraints - } - }; - - template <> - struct Operations - { - template - static void constraints(Iterator1 const& i1, Iterator2 const& i2) - { - Operations::constraints(i1, i2); - i1 == i2; - i1 != i2; - - i2 == i1; - i2 != i1; - } - }; - - template <> - struct Operations - { - template - static void constraints(Iterator1 const& i1, Iterator2 const& i2) - { - Operations::constraints(i1, i2); - } - }; - - template <> - struct Operations - { - template - static void constraints(Iterator1 const& i1, Iterator2 const& i2) - { - Operations::constraints(i1, i2); - } - }; - - template <> - struct Operations - { - template - static void constraints(Iterator1 const& i1, Iterator2 const& i2) - { - Operations::constraints(i1, i2); - - i1 < i2; - i1 <= i2; - i1 > i2; - i1 >= i2; - i1 - i2; - - i2 < i1; - i2 <= i1; - i2 > i1; - i2 >= i1; - i2 - i1; - } - }; - - } // namespace detail - - template - class InteroperableConcept - { - public: - typedef typename boost::detail::pure_traversal_tag< - typename boost::iterator_traversal< - Iterator - >::type - >::type traversal_category; - - typedef typename - boost::detail::iterator_traits::difference_type - difference_type; - - typedef typename boost::detail::pure_traversal_tag< - typename boost::iterator_traversal< - ConstIterator - >::type - >::type const_traversal_category; - - typedef typename - boost::detail::iterator_traits::difference_type - const_difference_type; - - void constraints() - { - BOOST_STATIC_ASSERT( - (boost::is_same< difference_type, const_difference_type>::value) - ); - - BOOST_STATIC_ASSERT( - (boost::is_same< traversal_category, const_traversal_category>::value) - ); - - // ToDo check what the std really requires - - // detail::Operations::constraints(i, ci); - - ci = i; - - } - Iterator i; - ConstIterator ci; - }; - -} // namespace boost_concepts - - -#endif // BOOST_ITERATOR_CONCEPTS_HPP diff --git a/include/boost/iterator/iterator_facade.hpp b/include/boost/iterator/iterator_facade.hpp deleted file mode 100644 index 1030eb9..0000000 --- a/include/boost/iterator/iterator_facade.hpp +++ /dev/null @@ -1,600 +0,0 @@ -// (C) Copyright David Abrahams 2002. -// (C) Copyright Jeremy Siek 2002. -// (C) Copyright Thomas Witt 2002. -// Permission to copy, use, modify, -// sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. -#ifndef BOOST_ITERATOR_FACADE_23022003THW_HPP -#define BOOST_ITERATOR_FACADE_23022003THW_HPP - -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include // this goes last - -namespace boost -{ - // This forward declaration is required for the friend declaration - // in iterator_core_access - template class iterator_facade; - - namespace detail - { - // - // enable if for use in operator implementation. - // - // enable_if_interoperable falls back to always enabled for compilers - // that don't support enable_if or is_convertible. - // - template < - class Facade1 - , class Facade2 - , class Return - > - struct enable_if_interoperable -#ifndef BOOST_NO_STRICT_ITERATOR_INTEROPERABILITY - : ::boost::iterators::enable_if< - mpl::or_< - is_convertible - , is_convertible - > - , Return - > -#endif - { -#ifdef BOOST_NO_STRICT_ITERATOR_INTEROPERABILITY - typedef Return type; -#endif - }; - - // - // Generates associated types for an iterator_facade with the - // given parameters. - // - template < - class ValueParam - , class CategoryOrTraversal - , class Reference - , class Difference - > - struct iterator_facade_types - { - typedef typename facade_iterator_category< - CategoryOrTraversal, ValueParam, Reference - >::type iterator_category; - - typedef typename remove_const::type value_type; - - typedef typename mpl::apply_if< - detail::iterator_writability_disabled - , add_pointer::type> - , add_pointer - >::type pointer; - -# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ - && (BOOST_WORKAROUND(_STLPORT_VERSION, BOOST_TESTED_AT(0x452)) \ - || BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, BOOST_TESTED_AT(310))) \ - || BOOST_WORKAROUND(BOOST_RWSTD_VER, BOOST_TESTED_AT(0x20101)) \ - || BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, <= 310) - - // To interoperate with some broken library/compiler - // combinations, user-defined iterators must be derived from - // std::iterator. It is possible to implement a standard - // library for broken compilers without this limitation. -# define BOOST_ITERATOR_FACADE_NEEDS_ITERATOR_BASE 1 - - typedef - iterator - base; -# endif - }; - - - // operator->() needs special support for input iterators to strictly meet the - // standard's requirements. If *i is not a reference type, we must still - // produce a (constant) lvalue to which a pointer can be formed. We do that by - // returning an instantiation of this special proxy class template. - - template - struct operator_arrow_proxy - { - operator_arrow_proxy(T const* px) : m_value(*px) {} - const T* operator->() const { return &m_value; } - // This function is needed for MWCW and BCC, which won't call operator-> - // again automatically per 13.3.1.2 para 8 - operator const T*() const { return &m_value; } - T m_value; - }; - - // A metafunction that gets the result type for operator->. Also - // has a static function make() which builds the result from a - // Reference - template - struct operator_arrow_result - { - // CWPro8.3 won't accept "operator_arrow_result::type", and we - // need that type below, so metafunction forwarding would be a - // losing proposition here. - typedef typename mpl::if_< - is_reference - , Pointer - , operator_arrow_proxy - >::type type; - - static type make(Reference x) - { - return type(&x); - } - }; - -# if BOOST_WORKAROUND(BOOST_MSVC, <= 1200) - // Deal with ETI - template<> - struct operator_arrow_result - { - typedef int type; - }; -# endif - - // - // Iterator is actually an iterator_facade, so we do not have to - // go through iterator_traits to access the traits. - // - template - class operator_brackets_proxy - { - typedef typename Iterator::reference reference; - typedef typename Iterator::value_type value_type; - - public: - operator_brackets_proxy(Iterator const& iter) - : m_iter(iter) - {} - - operator reference() const - { - return *m_iter; - } - - operator_brackets_proxy& operator=(value_type const& val) - { - *m_iter = val; - return *this; - } - - private: - Iterator m_iter; - }; - - template - struct use_operator_brackets_proxy - : mpl::and_< - // Really we want an is_copy_constructible trait here, - // but is_POD will have to suffice in the meantime. - boost::is_POD - , iterator_writability_disabled - > - {}; - - template - struct operator_brackets_result - { - typedef typename mpl::if_< - use_operator_brackets_proxy - , Value - , operator_brackets_proxy - >::type type; - }; - - template - operator_brackets_proxy make_operator_brackets_result(Iterator const& iter, mpl::false_) - { - return operator_brackets_proxy(iter); - } - - template - typename Iterator::value_type make_operator_brackets_result(Iterator const& iter, mpl::true_) - { - return *iter; - } - - } // namespace detail - - - // Macros which describe the declarations of binary operators -# define BOOST_ITERATOR_FACADE_INTEROP_HEAD(prefix, op, result_type) \ - template < \ - class Derived1, class V1, class TC1, class R1, class D1 \ - , class Derived2, class V2, class TC2, class R2, class D2 \ - > \ - prefix typename detail::enable_if_interoperable< \ - Derived1, Derived2, result_type \ - >::type \ - operator op( \ - iterator_facade const& lhs \ - , iterator_facade const& rhs) - -# define BOOST_ITERATOR_FACADE_PLUS_HEAD(prefix,args) \ - template \ - prefix Derived operator+ args - - // - // Helper class for granting access to the iterator core interface. - // - // The simple core interface is used by iterator_facade. The core - // interface of a user/library defined iterator type should not be made public - // so that it does not clutter the public interface. Instead iterator_core_access - // should be made friend so that iterator_facade can access the core - // interface through iterator_core_access. - // - class iterator_core_access - { -# if defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) \ - || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) - // Tasteless as this may seem, making all members public allows member templates - // to work in the absence of member template friends. - public: -# else - - template friend class iterator_facade; - -# define BOOST_ITERATOR_FACADE_RELATION(op) \ - BOOST_ITERATOR_FACADE_INTEROP_HEAD(friend,op, bool); - - BOOST_ITERATOR_FACADE_RELATION(==) - BOOST_ITERATOR_FACADE_RELATION(!=) - - BOOST_ITERATOR_FACADE_RELATION(<) - BOOST_ITERATOR_FACADE_RELATION(>) - BOOST_ITERATOR_FACADE_RELATION(<=) - BOOST_ITERATOR_FACADE_RELATION(>=) -# undef BOOST_ITERATOR_FACADE_RELATION - - BOOST_ITERATOR_FACADE_INTEROP_HEAD( - friend, -, typename Derived1::difference_type) - ; - - BOOST_ITERATOR_FACADE_PLUS_HEAD( - friend - , (iterator_facade const& - , typename Derived::difference_type) - ) - ; - - BOOST_ITERATOR_FACADE_PLUS_HEAD( - friend - , (typename Derived::difference_type - , iterator_facade const&) - ) - ; - -# endif - - template - static typename Facade::reference dereference(Facade const& f) - { - return f.dereference(); - } - - template - static void increment(Facade& f) - { - f.increment(); - } - - template - static void decrement(Facade& f) - { - f.decrement(); - } - - template - static bool equal(Facade1 const& f1, Facade2 const& f2) - { - return f1.equal(f2); - } - - template - static void advance(Facade& f, typename Facade::difference_type n) - { - f.advance(n); - } - - template - static typename Facade1::difference_type distance_to( - Facade1 const& f1, Facade2 const& f2) - { - return f1.distance_to(f2); - } - - private: - // objects of this class are useless - iterator_core_access(); //undefined - }; - - // - // iterator_facade - use as a public base class for defining new - // standard-conforming iterators. - // - template < - class Derived // The derived iterator type being constructed - , class Value - , class CategoryOrTraversal - , class Reference = Value& - , class Difference = std::ptrdiff_t - > - class iterator_facade -# ifdef BOOST_ITERATOR_FACADE_NEEDS_ITERATOR_BASE - : public detail::iterator_facade_types< - Value, CategoryOrTraversal, Reference, Difference - >::base -# undef BOOST_ITERATOR_FACADE_NEEDS_ITERATOR_BASE -# endif - { - private: - // - // Curiously Recurring Template interface. - // - typedef Derived derived_t; - - Derived& derived() - { - return static_cast(*this); - } - - Derived const& derived() const - { - return static_cast(*this); - } - - typedef detail::iterator_facade_types< - Value, CategoryOrTraversal, Reference, Difference - > associated_types; - - public: - - typedef typename associated_types::value_type value_type; - typedef Reference reference; - typedef Difference difference_type; - typedef typename associated_types::pointer pointer; - typedef typename associated_types::iterator_category iterator_category; - - reference operator*() const - { - return iterator_core_access::dereference(this->derived()); - } - - typename detail::operator_arrow_result< - value_type - , reference - , pointer - >::type - operator->() const - { - return detail::operator_arrow_result< - value_type - , reference - , pointer - >::make(*this->derived()); - } - - typename detail::operator_brackets_result::type - operator[](difference_type n) const - { - typedef detail::use_operator_brackets_proxy use_proxy; - - return detail::make_operator_brackets_result( - this->derived() + n - , use_proxy() - ); - } - - Derived& operator++() - { - iterator_core_access::increment(this->derived()); - return this->derived(); - } - - Derived operator++(int) - { - Derived tmp(this->derived()); - ++*this; - return tmp; - } - - Derived& operator--() - { - iterator_core_access::decrement(this->derived()); - return this->derived(); - } - - Derived operator--(int) - { - Derived tmp(this->derived()); - --*this; - return tmp; - } - - Derived& operator+=(difference_type n) - { - iterator_core_access::advance(this->derived(), n); - return this->derived(); - } - - Derived& operator-=(difference_type n) - { - iterator_core_access::advance(this->derived(), -n); - return this->derived(); - } - - Derived operator-(difference_type x) const - { - Derived result(this->derived()); - return result -= x; - } - -# if BOOST_WORKAROUND(BOOST_MSVC, <= 1200) - // There appears to be a bug which trashes the data of classes - // derived from iterator_facade when they are assigned unless we - // define this assignment operator. This bug is only revealed - // (so far) in STLPort debug mode, but it's clearly a codegen - // problem so we apply the workaround for all MSVC6. - iterator_facade& operator=(iterator_facade const&) - { - return *this; - } -# endif - }; - - // - // Operator implementation. The library supplied operators - // enables the user to provide fully interoperable constant/mutable - // iterator types. I.e. the library provides all operators - // for all mutable/constant iterator combinations. - // - // Note though that this kind of interoperability for constant/mutable - // iterators is not required by the standard for container iterators. - // All the standard asks for is a conversion mutable -> constant. - // Most standard library implementations nowadays provide fully interoperable - // iterator implementations, but there are still heavily used implementations - // that do not provide them. (Actually it's even worse, they do not provide - // them for only a few iterators.) - // - // ?? Maybe a BOOST_ITERATOR_NO_FULL_INTEROPERABILITY macro should - // enable the user to turn off mixed type operators - // - // The library takes care to provide only the right operator overloads. - // I.e. - // - // bool operator==(Iterator, Iterator); - // bool operator==(ConstIterator, Iterator); - // bool operator==(Iterator, ConstIterator); - // bool operator==(ConstIterator, ConstIterator); - // - // ... - // - // In order to do so it uses c++ idioms that are not yet widely supported - // by current compiler releases. The library is designed to degrade gracefully - // in the face of compiler deficiencies. In general compiler - // deficiencies result in less strict error checking and more obscure - // error messages, functionality is not affected. - // - // For full operation compiler support for "Substitution Failure Is Not An Error" - // (aka. enable_if) and boost::is_convertible is required. - // - // The following problems occur if support is lacking. - // - // Pseudo code - // - // --------------- - // AdaptorA a1; - // AdaptorA a2; - // - // // This will result in a no such overload error in full operation - // // If enable_if or is_convertible is not supported - // // The instantiation will fail with an error hopefully indicating that - // // there is no operator== for Iterator1, Iterator2 - // // The same will happen if no enable_if is used to remove - // // false overloads from the templated conversion constructor - // // of AdaptorA. - // - // a1 == a2; - // ---------------- - // - // AdaptorA a; - // AdaptorB b; - // - // // This will result in a no such overload error in full operation - // // If enable_if is not supported the static assert used - // // in the operator implementation will fail. - // // This will accidently work if is_convertible is not supported. - // - // a == b; - // ---------------- - // - -# define BOOST_ITERATOR_FACADE_INTEROP(op, result_type, condition, return_prefix, base_op) \ - BOOST_ITERATOR_FACADE_INTEROP_HEAD(inline, op, result_type) \ - { \ - /* For those compilers that do not support enable_if */ \ - BOOST_STATIC_ASSERT(( \ - is_interoperable< Derived1, Derived2 >::value \ - && condition \ - )); \ - return_prefix iterator_core_access::base_op( \ - static_cast(rhs), static_cast(lhs)); \ - } - -# define BOOST_ITERATOR_FACADE_RELATION(op, return_prefix, base_op) \ - BOOST_ITERATOR_FACADE_INTEROP( \ - op \ - , bool \ - , true \ - , return_prefix \ - , base_op \ - ) - - BOOST_ITERATOR_FACADE_RELATION(==, return, equal) - BOOST_ITERATOR_FACADE_RELATION(!=, return !, equal) - - BOOST_ITERATOR_FACADE_RELATION(<, return 0 >, distance_to) - BOOST_ITERATOR_FACADE_RELATION(>, return 0 <, distance_to) - BOOST_ITERATOR_FACADE_RELATION(<=, return 0 >=, distance_to) - BOOST_ITERATOR_FACADE_RELATION(>=, return 0 <=, distance_to) -# undef BOOST_ITERATOR_FACADE_RELATION - - // operator- requires an additional part in the static assertion - BOOST_ITERATOR_FACADE_INTEROP( - - - , typename Derived1::difference_type - , (is_same< - BOOST_DEDUCED_TYPENAME Derived1::difference_type - , BOOST_DEDUCED_TYPENAME Derived2::difference_type - >::value) - , return - , distance_to ) -# undef BOOST_ITERATOR_FACADE_INTEROP -# undef BOOST_ITERATOR_FACADE_INTEROP_HEAD - -# define BOOST_ITERATOR_FACADE_PLUS(args) \ - BOOST_ITERATOR_FACADE_PLUS_HEAD(inline, args) \ - { \ - Derived tmp(static_cast(i)); \ - return tmp += n; \ - } - -BOOST_ITERATOR_FACADE_PLUS(( - iterator_facade const& i - , typename Derived::difference_type n -)) - -BOOST_ITERATOR_FACADE_PLUS(( - typename Derived::difference_type n - , iterator_facade const& i -)) -# undef BOOST_ITERATOR_FACADE_PLUS -# undef BOOST_ITERATOR_FACADE_PLUS_HEAD - -} // namespace boost - -#include - -#endif // BOOST_ITERATOR_FACADE_23022003THW_HPP diff --git a/include/boost/iterator/iterator_traits.hpp b/include/boost/iterator/iterator_traits.hpp deleted file mode 100644 index 4f0d46f..0000000 --- a/include/boost/iterator/iterator_traits.hpp +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright David Abrahams 2003. Permission to copy, use, -// modify, sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. -#ifndef ITERATOR_TRAITS_DWA200347_HPP -# define ITERATOR_TRAITS_DWA200347_HPP - -# include -# include - -namespace boost { - -// Unfortunately, g++ 2.95.x chokes when we define a class template -// iterator_category which has the same name as its -// std::iterator_category() function, probably due in part to the -// "std:: is visible globally" hack it uses. Use -// BOOST_ITERATOR_CATEGORY to write code that's portable to older -// GCCs. - -# if BOOST_WORKAROUND(__GNUC__, <= 2) -# define BOOST_ITERATOR_CATEGORY iterator_category_ -# else -# define BOOST_ITERATOR_CATEGORY iterator_category -# endif - - -template -struct iterator_value -{ - typedef typename detail::iterator_traits::value_type type; -}; - -template -struct iterator_reference -{ - typedef typename detail::iterator_traits::reference type; -}; - - -template -struct iterator_pointer -{ - typedef typename detail::iterator_traits::pointer type; -}; - -template -struct iterator_difference -{ - typedef typename detail::iterator_traits::difference_type type; -}; - -template -struct BOOST_ITERATOR_CATEGORY -{ - typedef typename detail::iterator_traits::iterator_category type; -}; - -# if BOOST_WORKAROUND(BOOST_MSVC, <= 1200) -template <> -struct iterator_value -{ - typedef void type; -}; - -template <> -struct iterator_reference -{ - typedef void type; -}; - -template <> -struct iterator_pointer -{ - typedef void type; -}; - -template <> -struct iterator_difference -{ - typedef void type; -}; - -template <> -struct BOOST_ITERATOR_CATEGORY -{ - typedef void type; -}; -# endif - -} // namespace boost::iterator - -#endif // ITERATOR_TRAITS_DWA200347_HPP diff --git a/include/boost/iterator/new_iterator_tests.hpp b/include/boost/iterator/new_iterator_tests.hpp deleted file mode 100644 index c16b826..0000000 --- a/include/boost/iterator/new_iterator_tests.hpp +++ /dev/null @@ -1,214 +0,0 @@ -#ifndef BOOST_NEW_ITERATOR_TESTS_HPP -# define BOOST_NEW_ITERATOR_TESTS_HPP - -// This is meant to be the beginnings of a comprehensive, generic -// test suite for STL concepts such as iterators and containers. -// -// Revision History: -// 28 Oct 2002 Started update for new iterator categories -// (Jeremy Siek) -// 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) -// 04 Feb 2001 Added lvalue test, corrected preconditions -// (David Abrahams) - -# include -# include -# include -# include -# include // for detail::dummy_constructor -# include -# include -# include -# include - -# include - -namespace boost { - -// Preconditions: *i == v -template -void readable_iterator_test(const Iterator i1, T v) -{ - Iterator i2(i1); // Copy Constructible - typedef typename detail::iterator_traits::reference ref_t; - ref_t r1 = *i1; - ref_t r2 = *i2; - T v1 = r1; - T v2 = r2; - assert(v1 == v); - assert(v2 == v); - -# if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407) - // I think we don't really need this as it checks the same things as - // the above code. - BOOST_STATIC_ASSERT(is_readable_iterator::value); -# endif -} - -template -void writable_iterator_test(Iterator i, T v) -{ - Iterator i2(i); // Copy Constructible - *i2 = v; -} - -template -void swappable_iterator_test(Iterator i, Iterator j) -{ - Iterator i2(i), j2(j); - typename detail::iterator_traits::value_type bi = *i, bj = *j; - iter_swap(i2, j2); - typename detail::iterator_traits::value_type ai = *i, aj = *j; - assert(bi == aj && bj == ai); -} - -template -void constant_lvalue_iterator_test(Iterator i, T v1) -{ - Iterator i2(i); - typedef typename detail::iterator_traits::value_type value_type; - typedef typename detail::iterator_traits::reference reference; - BOOST_STATIC_ASSERT((is_same::value)); - const T& v2 = *i2; - assert(v1 == v2); -# ifndef BOOST_NO_LVALUE_RETURN_DETECTION - BOOST_STATIC_ASSERT(is_lvalue_iterator::value); - BOOST_STATIC_ASSERT(!is_non_const_lvalue_iterator::value); -# endif -} - -template -void non_const_lvalue_iterator_test(Iterator i, T v1, T v2) -{ - Iterator i2(i); - typedef typename detail::iterator_traits::value_type value_type; - typedef typename detail::iterator_traits::reference reference; - BOOST_STATIC_ASSERT((is_same::value)); - T& v3 = *i2; - assert(v1 == v3); - - // A non-const lvalue iterator is not neccessarily writable, but we - // are assuming the value_type is assignable here - *i = v2; - - T& v4 = *i2; - assert(v2 == v4); -# ifndef BOOST_NO_LVALUE_RETURN_DETECTION - BOOST_STATIC_ASSERT(is_lvalue_iterator::value); - BOOST_STATIC_ASSERT(is_non_const_lvalue_iterator::value); -# endif -} - -template -void forward_readable_iterator_test(Iterator i, Iterator j, T val1, T val2) -{ - Iterator i2; - Iterator i3(i); - i2 = i; - assert(i2 == i3); - assert(i != j); - assert(i2 != j); - readable_iterator_test(i, val1); - readable_iterator_test(i2, val1); - readable_iterator_test(i3, val1); - - assert(i == i2++); - assert(i != ++i3); - - readable_iterator_test(i2, val2); - readable_iterator_test(i3, val2); - - readable_iterator_test(i, val1); -} - -template -void forward_swappable_iterator_test(Iterator i, Iterator j, T val1, T val2) -{ - forward_readable_iterator_test(i, j, val1, val2); - Iterator i2 = i; - ++i2; - swappable_iterator_test(i, i2); -} - -// bidirectional -// Preconditions: *i == v1, *++i == v2 -template -void bidirectional_readable_iterator_test(Iterator i, T v1, T v2) -{ - Iterator j(i); - ++j; - forward_readable_iterator_test(i, j, v1, v2); - ++i; - - Iterator i1 = i, i2 = i; - - assert(i == i1--); - assert(i != --i2); - - readable_iterator_test(i, v2); - readable_iterator_test(i1, v1); - readable_iterator_test(i2, v1); - - --i; - assert(i == i1); - assert(i == i2); - ++i1; - ++i2; - - readable_iterator_test(i, v1); - readable_iterator_test(i1, v2); - readable_iterator_test(i2, v2); -} - -// random access -// Preconditions: [i,i+N) is a valid range -template -void random_access_readable_iterator_test(Iterator i, int N, TrueVals vals) -{ - bidirectional_readable_iterator_test(i, vals[0], vals[1]); - const Iterator j = i; - int c; - - for (c = 0; c < N-1; ++c) - { - assert(i == j + c); - assert(*i == vals[c]); - typename detail::iterator_traits::value_type x = j[c]; - assert(*i == x); - assert(*i == *(j + c)); - assert(*i == *(c + j)); - ++i; - assert(i > j); - assert(i >= j); - assert(j <= i); - assert(j < i); - } - - Iterator k = j + N - 1; - for (c = 0; c < N-1; ++c) - { - assert(i == k - c); - assert(*i == vals[N - 1 - c]); - typename detail::iterator_traits::value_type x = j[N - 1 - c]; - assert(*i == x); - Iterator q = k - c; - assert(*i == *q); - assert(i > j); - assert(i >= j); - assert(j <= i); - assert(j < i); - --i; - } -} - -} // namespace boost - -# include - -#endif // BOOST_NEW_ITERATOR_TESTS_HPP diff --git a/include/boost/iterator/permutation_iterator.hpp b/include/boost/iterator/permutation_iterator.hpp deleted file mode 100644 index f41da1a..0000000 --- a/include/boost/iterator/permutation_iterator.hpp +++ /dev/null @@ -1,92 +0,0 @@ -// (C) Copyright Toon Knapen 2001. -// (C) Copyright David Abrahams 2003. -// (C) Copyright Roland Richter 2003. -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. - -#ifndef BOOST_PERMUTATION_ITERATOR_HPP -#define BOOST_PERMUTATION_ITERATOR_HPP - -#include - -#include - - -namespace boost -{ - -template< class ElementIterator - , class IndexIterator - , class ValueT = use_default - , class CategoryT = use_default - , class ReferenceT = use_default - , class DifferenceT = use_default > -class permutation_iterator - : public iterator_adaptor< - permutation_iterator - , ElementIterator, ValueT, CategoryT, ReferenceT, DifferenceT > -{ - typedef iterator_adaptor< - permutation_iterator - , ElementIterator, ValueT, CategoryT, ReferenceT, DifferenceT > super_t; - - friend class iterator_core_access; - -public: - permutation_iterator() : order_it_() {} - - explicit permutation_iterator(ElementIterator x, IndexIterator y) - : super_t(x), order_it_(y) {} - - template - permutation_iterator( - permutation_iterator const& r - , typename enable_if_convertible::type* = 0 - , typename enable_if_convertible::type* = 0 - ) - : super_t(r.base()) - {} - -private: - typename super_t::reference dereference() const - { return *(this->base() + *this->order_it_); } - - void increment() { ++this->order_it_; } - void decrement() { --this->order_it_; } - - void advance(typename super_t::difference_type n) - { - std::advance( order_it_, n ); - } - - template - typename super_t::difference_type - distance_to( permutation_iterator const& y ) const - { - return std::distance( this->order_it_, y.order_it_ ); - } - - template - bool - equal( permutation_iterator const& y ) const - { - return( y.order_it_ == this->order_it_ ); - } - - IndexIterator order_it_; -}; - - -template -permutation_iterator -make_permutation_iterator( ElementIterator e, IndexIterator i ) -{ - return permutation_iterator( e, i ); -} - - -} // namespace boost - -#endif diff --git a/include/boost/iterator/reverse_iterator.hpp b/include/boost/iterator/reverse_iterator.hpp deleted file mode 100644 index 43942eb..0000000 --- a/include/boost/iterator/reverse_iterator.hpp +++ /dev/null @@ -1,71 +0,0 @@ -// (C) Copyright David Abrahams 2002. -// (C) Copyright Jeremy Siek 2002. -// (C) Copyright Thomas Witt 2002. -// Permission to copy, use, modify, -// sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. -#ifndef BOOST_REVERSE_ITERATOR_23022003THW_HPP -#define BOOST_REVERSE_ITERATOR_23022003THW_HPP - -#include -#include -#include - -namespace boost -{ - - // - // - // - template - class reverse_iterator - : public iterator_adaptor< reverse_iterator, Iterator > - { - typedef iterator_adaptor< reverse_iterator, Iterator > super_t; - - friend class iterator_core_access; - - public: - reverse_iterator() {} - - explicit reverse_iterator(Iterator x) - : super_t(x) {} - - template - reverse_iterator( - reverse_iterator const& r - , typename enable_if_convertible::type* = 0 - ) - : super_t(r.base()) - {} - - private: - typename super_t::reference dereference() const { return *boost::prior(this->base()); } - - void increment() { --this->base_reference(); } - void decrement() { ++this->base_reference(); } - - void advance(typename super_t::difference_type n) - { - this->base_reference() += -n; - } - - template - typename super_t::difference_type - distance_to(reverse_iterator const& y) const - { - return this->base_reference() - y.base(); - } - }; - - template - reverse_iterator make_reverse_iterator(BidirectionalIterator x) - { - return reverse_iterator(x); - } - -} // namespace boost - -#endif // BOOST_REVERSE_ITERATOR_23022003THW_HPP diff --git a/include/boost/iterator/transform_iterator.hpp b/include/boost/iterator/transform_iterator.hpp deleted file mode 100644 index 20da1ab..0000000 --- a/include/boost/iterator/transform_iterator.hpp +++ /dev/null @@ -1,183 +0,0 @@ -// (C) Copyright David Abrahams 2002. -// (C) Copyright Jeremy Siek 2002. -// (C) Copyright Thomas Witt 2002. -// Permission to copy, use, modify, -// sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. -#ifndef BOOST_TRANSFORM_ITERATOR_23022003THW_HPP -#define BOOST_TRANSFORM_ITERATOR_23022003THW_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310)) -# include - -#endif -#include - - -namespace boost -{ - template - class transform_iterator; - - namespace detail - { - - template - struct function_object_result - { - typedef typename UnaryFunction::result_type type; - }; - -#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - template - struct function_object_result - { - typedef Return type; - }; -#endif - - // Compute the iterator_adaptor instantiation to be used for transform_iterator - template - struct transform_iterator_base - { - private: - // By default, dereferencing the iterator yields the same as - // the function. Do we need to adjust the way - // function_object_result is computed for the standard - // proposal (e.g. using Doug's result_of)? - typedef typename ia_dflt_help< - Reference - , function_object_result - >::type reference; - - // To get the default for Value: remove any reference on the - // result type, but retain any constness to signal - // non-writability. Note that if we adopt Thomas' suggestion - // to key non-writability *only* on the Reference argument, - // we'd need to strip constness here as well. - typedef typename ia_dflt_help< - Value - , remove_reference - >::type cv_value_type; - - public: - typedef iterator_adaptor< - transform_iterator - , Iterator - , cv_value_type - , use_default // Leave the traversal category alone - , reference - > type; - }; - } - - template - class transform_iterator - : public detail::transform_iterator_base::type - { - typedef typename - detail::transform_iterator_base::type - super_t; - - friend class iterator_core_access; - - public: - transform_iterator() { } - - transform_iterator(Iterator const& x, UnaryFunction f) - : super_t(x), m_f(f) { } - - explicit transform_iterator(Iterator const& x) - : super_t(x) - { - // Pro8 is a little too aggressive about instantiating the - // body of this function. -#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) - // don't provide this constructor if UnaryFunction is a - // function pointer type, since it will be 0. Too dangerous. - BOOST_STATIC_ASSERT(is_class::value); -#endif - } - - template< - class OtherUnaryFunction - , class OtherIterator - , class OtherReference - , class OtherValue> - transform_iterator( - transform_iterator const& t - , typename enable_if_convertible::type* = 0 -#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1310) - , typename enable_if_convertible::type* = 0 -#endif - ) - : super_t(t.base()), m_f(t.functor()) - {} - - UnaryFunction functor() const - { return m_f; } - - private: - typename super_t::reference dereference() const - { return m_f(*this->base()); } - - // Probably should be the initial base class so it can be - // optimized away via EBO if it is an empty class. - UnaryFunction m_f; - }; - - template - transform_iterator - make_transform_iterator(Iterator it, UnaryFunction fun) - { - return transform_iterator(it, fun); - } - - // Version which allows explicit specification of the UnaryFunction - // type. - // - // This generator is not provided if UnaryFunction is a function - // pointer type, because it's too dangerous: the default-constructed - // function pointer in the iterator be 0, leading to a runtime - // crash. - template - typename iterators::enable_if< - is_class // We should probably find a cheaper test than is_class<> - , transform_iterator - >::type - make_transform_iterator(Iterator it) - { - return transform_iterator(it, UnaryFunction()); - } - -#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) - template - transform_iterator< Return (*)(Argument), Iterator, Return> - make_transform_iterator(Iterator it, Return (*fun)(Argument)) - { - return transform_iterator(it, fun); - } -#endif - -} // namespace boost - -#include - -#endif // BOOST_TRANSFORM_ITERATOR_23022003THW_HPP diff --git a/include/boost/iterator/zip_iterator.hpp b/include/boost/iterator/zip_iterator.hpp deleted file mode 100755 index aee58a2..0000000 --- a/include/boost/iterator/zip_iterator.hpp +++ /dev/null @@ -1,613 +0,0 @@ -// (C) Copyright David Abrahams and Thomas Becker 2000. Permission to -// copy, use, modify, sell and distribute this software is granted -// provided this copyright notice appears in all copies. This software -// is provided "as is" without express or implied warranty, and with -// no claim as to its suitability for any purpose. -// -// Compilers Tested: -// ================= -// Metrowerks Codewarrior Pro 7.2, 8.3 -// gcc 2.95.3 -// gcc 3.2 -// Microsoft VC 6sp5 (test fails due to some compiler bug) -// Microsoft VC 7 (works) -// Microsoft VC 7.1 -// Intel 5 -// Intel 6 -// Intel 7.1 -// Intel 8 -// Borland 5.5.1 (broken due to lack of support from Boost.Tuples) - -#ifndef BOOST_ZIP_ITERATOR_TMB_07_13_2003_HPP_ - -#include -#include -#include -#include -#include // for enable_if_convertible -#include -#include - -#include - -#include - -#if BOOST_WORKAROUND(__GNUC__, == 2) || BOOST_WORKAROUND(__MWERKS__, <= 0x2407) -# include -#endif - -#include -#include -#include -#include -#include -#include -#include - -namespace boost { - - // Zip iterator forward declaration for zip_iterator_base - template - class zip_iterator; - - // One important design goal of the zip_iterator is to isolate all - // functionality whose implementation relies on the current tuple - // implementation. This goal has been achieved as follows: Inside - // the namespace detail there is a namespace tuple_impl_specific. - // This namespace encapsulates all functionality that is specific - // to the current Boost tuple implementation. More precisely, the - // namespace tuple_impl_specific provides the following tuple - // algorithms and meta-algorithms for the current Boost tuple - // implementation: - // - // tuple_meta_transform - // tuple_meta_accumulate - // tuple_transform - // tuple_for_each - // - // If the tuple implementation changes, all that needs to be - // replaced is the implementation of these four (meta-)algorithms. - - namespace detail - { - - // Functors to be used with tuple algorithms - // - template - class advance_iterator - { - public: - advance_iterator(DiffType step) : m_step(step) {} - - template - void operator()(Iterator& it) const - { it += m_step; } - - private: - DiffType m_step; - }; - // - struct increment_iterator - { - template - void operator()(Iterator& it) - { ++it; } - }; - // - struct decrement_iterator - { - template - void operator()(Iterator& it) - { --it; } - }; - // - struct dereference_iterator - { - template - struct apply - { -#if BOOST_WORKAROUND(__EDG_VERSION__, != 0) \ - || BOOST_WORKAROUND(__GNUC__, == 2) \ - || BOOST_WORKAROUND(__MWERKS__, <= 0x2407) - typedef typename - iterator_traits< - typename boost::remove_cv::type - >::reference - type; -#else - typedef typename - iterator_traits::reference - type; -#endif - }; - - template - typename apply::type operator()(Iterator& it) - { return *it; } - }; - - - // The namespace tuple_impl_specific provides two meta- - // algorithms and two algorithms for tuples. - // - namespace tuple_impl_specific - { - // Meta-transform algorithm for tuples - // - template - struct tuple_meta_transform; - - template - struct tuple_meta_transform_impl - { - typedef tuples::cons< - typename mpl::apply1< - typename mpl::lambda::type - , typename Tuple::head_type - >::type - , typename tuple_meta_transform< - typename Tuple::tail_type - , UnaryMetaFun - >::type - > type; - }; - - template - struct tuple_meta_transform - : mpl::apply_if< - boost::is_same - , mpl::identity - , tuple_meta_transform_impl - > - { - }; - - // Meta-accumulate algorithm for tuples. Note: The template - // parameter StartType corresponds to the initial value in - // ordinary accumulation. - // - template - struct tuple_meta_accumulate; - - template< - typename Tuple - , class BinaryMetaFun - , typename StartType - > - struct tuple_meta_accumulate_impl - { - typedef typename mpl::apply2< - typename mpl::lambda::type - , typename Tuple::head_type - , typename tuple_meta_accumulate< - typename Tuple::tail_type - , BinaryMetaFun - , StartType - >::type - >::type type; - }; - - template< - typename Tuple - , class BinaryMetaFun - , typename StartType - > - struct tuple_meta_accumulate - : mpl::apply_if< -#if BOOST_WORKAROUND(BOOST_MSVC, == 1200) - mpl::or_< -#endif - boost::is_same -#if BOOST_WORKAROUND(BOOST_MSVC, == 1200) - , boost::is_same - > -#endif - , mpl::identity - , tuple_meta_accumulate_impl< - Tuple - , BinaryMetaFun - , StartType - > - > - { - }; - -#if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \ - || ( \ - BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, != 0) && defined(_MSC_VER) \ - ) -// Not sure why intel's partial ordering fails in this case, but I'm -// assuming int's an MSVC bug-compatibility feature. - -# define BOOST_TUPLE_ALGO_DISPATCH -# define BOOST_TUPLE_ALGO(algo) algo##_impl -# define BOOST_TUPLE_ALGO_TERMINATOR , int -# define BOOST_TUPLE_ALGO_RECURSE , ... -#else -# define BOOST_TUPLE_ALGO(algo) algo -# define BOOST_TUPLE_ALGO_TERMINATOR -# define BOOST_TUPLE_ALGO_RECURSE -#endif - - // transform algorithm for tuples. The template parameter Fun - // must be a unary functor which is also a unary metafunction - // class that computes its return type based on its argument - // type. For example: - // - // struct to_ptr - // { - // template - // struct apply - // { - // typedef Arg* type; - // } - // - // template - // Arg* operator()(Arg x); - // }; - template - tuples::null_type BOOST_TUPLE_ALGO(tuple_transform) - (tuples::null_type const&, Fun BOOST_TUPLE_ALGO_TERMINATOR) - { return tuples::null_type(); } - - template - typename tuple_meta_transform< - Tuple - , Fun - >::type - - BOOST_TUPLE_ALGO(tuple_transform)( - const Tuple& t, - Fun f - BOOST_TUPLE_ALGO_RECURSE - ) - { - typedef typename tuple_meta_transform< - BOOST_DEDUCED_TYPENAME Tuple::tail_type - , Fun - >::type transformed_tail_type; - - return tuples::cons< - BOOST_DEDUCED_TYPENAME mpl::apply1< - Fun, BOOST_DEDUCED_TYPENAME Tuple::head_type - >::type - , transformed_tail_type - >( - f(boost::tuples::get<0>(t)), tuple_transform(t.get_tail(), f) - ); - } - -#ifdef BOOST_TUPLE_ALGO_DISPATCH - template - typename tuple_meta_transform< - Tuple - , Fun - >::type - - tuple_transform( - const Tuple& t, - Fun f - ) - { - return tuple_transform_impl(t, f, 1); - } -#endif - - // for_each algorithm for tuples. - // - template - Fun BOOST_TUPLE_ALGO(tuple_for_each)( - tuples::null_type - , Fun f BOOST_TUPLE_ALGO_TERMINATOR - ) - { return f; } - - - template - Fun BOOST_TUPLE_ALGO(tuple_for_each)( - Tuple& t - , Fun f BOOST_TUPLE_ALGO_RECURSE) - { - f( t.get_head() ); - return tuple_for_each(t.get_tail(), f); - } - -#ifdef BOOST_TUPLE_ALGO_DISPATCH - template - Fun - tuple_for_each( - Tuple& t, - Fun f - ) - { - return tuple_for_each_impl(t, f, 1); - } -#endif - - // Equality of tuples. NOTE: "==" for tuples currently (7/2003) - // has problems under some compilers, so I just do my own. - // No point in bringing in a bunch of #ifdefs here. This is - // going to go away with the next tuple implementation anyway. - // - bool tuple_equal(tuples::null_type, tuples::null_type) - { return true; } - - template - bool tuple_equal( - Tuple1 const& t1, - Tuple2 const& t2 - ) - { - return t1.get_head() == t2.get_head() && - tuple_equal(t1.get_tail(), t2.get_tail()); - } - } - // - // end namespace tuple_impl_specific - - template - struct iterator_reference - { - typedef typename iterator_traits::reference type; - }; - -#ifdef BOOST_MPL_NO_FULL_LAMBDA_SUPPORT - // Hack because BOOST_MPL_AUX_LAMBDA_SUPPORT doesn't seem to work - // out well. Instantiating the nested apply template also - // requires instantiating iterator_traits on the - // placeholder. Instead we just specialize it as a metafunction - // class. - template<> - struct iterator_reference - { - template - struct apply : iterator_reference {}; - }; -#endif - - // Metafunction to obtain the type of the tuple whose element types - // are the reference types of an iterator tuple. - // - template - struct tuple_of_references - : tuple_impl_specific::tuple_meta_transform< - IteratorTuple, - iterator_reference - > - { - }; - - // Metafunction to obtain the minimal traversal tag in a tuple - // of iterators. - // - template - struct minimum_traversal_category_in_iterator_tuple - { - typedef typename tuple_impl_specific::tuple_meta_transform< - IteratorTuple - , iterator_traversal<> - >::type tuple_of_traversal_tags; - - typedef typename tuple_impl_specific::tuple_meta_accumulate< - tuple_of_traversal_tags - , minimum_category<> - , random_access_traversal_tag - >::type type; - }; - -#if BOOST_WORKAROUND(BOOST_MSVC, == 1200) // ETI workaround - template <> - struct minimum_traversal_category_in_iterator_tuple - { - typedef int type; - }; -#endif - - // We need to call tuple_meta_accumulate with mpl::and_ as the - // accumulating functor. To this end, we need to wrap it into - // a struct that has exactly two arguments (that is, template - // parameters) and not five, like mpl::and_ does. - // - template - struct and_with_two_args - : mpl::and_ - { - }; - -# ifdef BOOST_MPL_NO_FULL_LAMBDA_SUPPORT - // Hack because BOOST_MPL_AUX_LAMBDA_SUPPORT doesn't seem to work - // out well. In this case I think it's an MPL bug - template<> - struct and_with_two_args - { - template - struct apply : mpl::and_ - {}; - }; -# endif - - /////////////////////////////////////////////////////////////////// - // - // Class zip_iterator_base - // - // Builds and exposes the iterator facade type from which the zip - // iterator will be derived. - // - template - struct zip_iterator_base - { - private: - // Reference type is the type of the tuple obtained from the - // iterators' reference types. - typedef typename - detail::tuple_of_references::type reference; - - // Value type is the same as reference type. - typedef reference value_type; - - // Difference type is the first iterator's difference type - typedef typename iterator_traits< - typename tuples::element<0, IteratorTuple>::type - >::difference_type difference_type; - - // Traversal catetgory is the minimum traversal category in the - // iterator tuple. - typedef typename - detail::minimum_traversal_category_in_iterator_tuple< - IteratorTuple - >::type traversal_category; - public: - - // The iterator facade type from which the zip iterator will - // be derived. - typedef iterator_facade< - zip_iterator, - value_type, - traversal_category, - reference, - difference_type - > type; - }; - - template <> - struct zip_iterator_base - { - typedef int type; - }; - } - - ///////////////////////////////////////////////////////////////////// - // - // zip_iterator class definition - // - template - class zip_iterator : - public detail::zip_iterator_base::type - { - - // Typedef super_t as our base class. - typedef typename - detail::zip_iterator_base::type super_t; - - // iterator_core_access is the iterator's best friend. - friend class iterator_core_access; - - public: - - // Construction - // ============ - - // Default constructor - zip_iterator() { } - - // Constructor from iterator tuple - zip_iterator(IteratorTuple iterator_tuple) - : m_iterator_tuple(iterator_tuple) - { } - - // Copy constructor - template - zip_iterator( - const zip_iterator& other, - typename enable_if_convertible< - OtherIteratorTuple, - IteratorTuple - >::type* = 0 - ) : m_iterator_tuple(other.get_iterator_tuple()) - {} - - // Get method for the iterator tuple. - const IteratorTuple& get_iterator_tuple() const - { return m_iterator_tuple; } - - private: - - // Implementation of Iterator Operations - // ===================================== - - // Dereferencing returns a tuple built from the dereferenced - // iterators in the iterator tuple. - typename super_t::reference dereference() const - { - return detail::tuple_impl_specific::tuple_transform( - get_iterator_tuple(), - detail::dereference_iterator() - ); - } - - // Two zip iterators are equal if all iterators in the iterator - // tuple are equal. NOTE: It should be possible to implement this - // as - // - // return get_iterator_tuple() == other.get_iterator_tuple(); - // - // but equality of tuples currently (7/2003) does not compile - // under several compilers. No point in bringing in a bunch - // of #ifdefs here. - // - template - bool equal(const zip_iterator& other) const - { - return detail::tuple_impl_specific::tuple_equal( - get_iterator_tuple(), - other.get_iterator_tuple() - ); - } - - // Advancing a zip iterator means to advance all iterators in the - // iterator tuple. - void advance(typename super_t::difference_type n) - { - detail::tuple_impl_specific::tuple_for_each( - m_iterator_tuple, - detail::advance_iterator(n) - ); - } - // Incrementing a zip iterator means to increment all iterators in - // the iterator tuple. - void increment() - { - detail::tuple_impl_specific::tuple_for_each( - m_iterator_tuple, - detail::increment_iterator() - ); - } - - // Decrementing a zip iterator means to decrement all iterators in - // the iterator tuple. - void decrement() - { - detail::tuple_impl_specific::tuple_for_each( - m_iterator_tuple, - detail::decrement_iterator() - ); - } - - // Distance is calculated using the first iterator in the tuple. - template - typename super_t::difference_type distance_to( - const zip_iterator& other - ) const - { - return boost::tuples::get<0>(other.get_iterator_tuple()) - - boost::tuples::get<0>(this->get_iterator_tuple()); - } - - // Data Members - // ============ - - // The iterator tuple. - IteratorTuple m_iterator_tuple; - - }; - - // Make function for zip iterator - // - template - zip_iterator - make_zip_iterator(IteratorTuple t) - { return zip_iterator(t); } - -} - -#endif diff --git a/include/boost/iterator_adaptors.hpp b/include/boost/iterator_adaptors.hpp deleted file mode 100644 index 6d876e7..0000000 --- a/include/boost/iterator_adaptors.hpp +++ /dev/null @@ -1,13 +0,0 @@ -// Permission to copy, use, modify, -// sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. - -#ifndef BOOST_ITERATOR_ADAPTOR_13062003HK_HPP -#define BOOST_ITERATOR_ADAPTOR_13062003HK_HPP - -#define BOOST_ITERATOR_ADAPTORS_VERSION 0x0200 -#include - -#endif // BOOST_ITERATOR_ADAPTOR_13062003HK_HPP diff --git a/include/boost/pending/detail/int_iterator.hpp b/include/boost/pending/detail/int_iterator.hpp deleted file mode 100644 index 2d96185..0000000 --- a/include/boost/pending/detail/int_iterator.hpp +++ /dev/null @@ -1,75 +0,0 @@ -// (C) Copyright Jeremy Siek 1999. Permission to copy, use, modify, -// sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. - -#ifndef BOOST_INT_ITERATOR_H -#define BOOST_INT_ITERATOR_H - -#include -#if !defined BOOST_MSVC -#include -#endif -#include -//using namespace std; - -#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE -namespace boost { -#endif - -// this should use random_access_iterator_helper but I've had -// VC++ portablility problems with that. -JGS -template -class int_iterator -{ - typedef int_iterator self; -public: - typedef std::random_access_iterator_tag iterator_category; - typedef IntT value_type; - typedef IntT& reference; - typedef IntT* pointer; - typedef std::ptrdiff_t difference_type; - - inline int_iterator() : _i(0) { } - inline int_iterator(IntT i) : _i(i) { } - inline int_iterator(const self& x) : _i(x._i) { } - inline self& operator=(const self& x) { _i = x._i; return *this; } - inline IntT operator*() { return _i; } - inline IntT operator[](IntT n) { return _i + n; } - inline self& operator++() { ++_i; return *this; } - inline self operator++(int) { self t = *this; ++_i; return t; } - inline self& operator+=(IntT n) { _i += n; return *this; } - inline self operator+(IntT n) { self t = *this; t += n; return t; } - inline self& operator--() { --_i; return *this; } - inline self operator--(int) { self t = *this; --_i; return t; } - inline self& operator-=(IntT n) { _i -= n; return *this; } - inline IntT operator-(const self& x) const { return _i - x._i; } - inline bool operator==(const self& x) const { return _i == x._i; } - // vc++ had a problem finding != in random_access_iterator_helper - // need to look into this... for now implementing everything here -JGS - inline bool operator!=(const self& x) const { return _i != x._i; } - inline bool operator<(const self& x) const { return _i < x._i; } - inline bool operator<=(const self& x) const { return _i <= x._i; } - inline bool operator>(const self& x) const { return _i > x._i; } - inline bool operator>=(const self& x) const { return _i >= x._i; } -protected: - IntT _i; -}; - -template -inline int_iterator -operator+(IntT n, int_iterator t) { t += n; return t; } - -#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE -} /* namespace boost */ -#endif - -#ifdef BOOST_NO_OPERATORS_IN_NAMESPACE -namespace boost { - using ::int_iterator; -} -#endif - - -#endif /* BOOST_INT_ITERATOR_H */ diff --git a/include/boost/pending/integer_range.hpp b/include/boost/pending/integer_range.hpp deleted file mode 100644 index 81ecf4d..0000000 --- a/include/boost/pending/integer_range.hpp +++ /dev/null @@ -1,59 +0,0 @@ -// (C) Copyright David Abrahams and Jeremy Siek 2000-2001. Permission to copy, -// use, modify, sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided "as is" -// without express or implied warranty, and with no claim as to its suitability -// for any purpose. -// -// Revision History: -// 04 Jan 2001 Factored counting_iterator stuff into -// boost/counting_iterator.hpp (David Abrahams) - -#ifndef BOOST_INTEGER_RANGE_HPP_ -#define BOOST_INTEGER_RANGE_HPP_ - -#include -#include - -namespace boost { - -//============================================================================= -// Counting Iterator and Integer Range Class - -template -struct integer_range { - typedef counting_iterator iterator; - - typedef iterator const_iterator; - typedef IntegerType value_type; - typedef std::ptrdiff_t difference_type; - typedef IntegerType reference; - typedef IntegerType const_reference; - typedef const IntegerType* pointer; - typedef const IntegerType* const_pointer; - typedef IntegerType size_type; - - integer_range(IntegerType start, IntegerType finish) - : m_start(start), m_finish(finish) { } - - iterator begin() const { return iterator(m_start); } - iterator end() const { return iterator(m_finish); } - size_type size() const { return m_finish - m_start; } - bool empty() const { return m_finish == m_start; } - void swap(integer_range& x) { - std::swap(m_start, x.m_start); - std::swap(m_finish, x.m_finish); - } -protected: - IntegerType m_start, m_finish; -}; - -template -inline integer_range -make_integer_range(IntegerType first, IntegerType last) -{ - return integer_range(first, last); -} - -} // namespace boost - -#endif // BOOST_INTEGER_RANGE_HPP_ diff --git a/include/boost/pending/iterator_adaptors.hpp b/include/boost/pending/iterator_adaptors.hpp deleted file mode 100644 index 4a3159b..0000000 --- a/include/boost/pending/iterator_adaptors.hpp +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright David Abrahams 2003. Permission to copy, use, -// modify, sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. - -#include diff --git a/include/boost/pending/iterator_tests.hpp b/include/boost/pending/iterator_tests.hpp deleted file mode 100644 index 5be7b0f..0000000 --- a/include/boost/pending/iterator_tests.hpp +++ /dev/null @@ -1,269 +0,0 @@ -// Copyright David Abrahams and Jeremy Siek 2003. Permission to copy, -// use, modify, sell and distribute this software is granted provided -// this copyright notice appears in all copies. This software is -// provided "as is" without express or implied warranty, and with no -// claim as to its suitability for any purpose. -#ifndef BOOST_ITERATOR_TESTS_HPP -# define BOOST_ITERATOR_TESTS_HPP - -// This is meant to be the beginnings of a comprehensive, generic -// 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) -// 04 Feb 2001 Added lvalue test, corrected preconditions -// (David Abrahams) - -# include -# include -# include -# include -# include // for detail::dummy_constructor -# include -# include - -namespace boost { - - // use this for the value type -struct dummyT { - dummyT() { } - dummyT(detail::dummy_constructor) { } - dummyT(int x) : m_x(x) { } - int foo() const { return m_x; } - bool operator==(const dummyT& d) const { return m_x == d.m_x; } - int m_x; -}; - -} - -BOOST_TT_BROKEN_COMPILER_SPEC(boost::dummyT) - -namespace boost { - -// Tests whether type Iterator satisfies the requirements for a -// TrivialIterator. -// Preconditions: i != j, *i == val -template -void trivial_iterator_test(const Iterator i, const Iterator j, T val) -{ - Iterator k; - assert(i == i); - assert(j == j); - assert(i != j); -#ifdef BOOST_NO_STD_ITERATOR_TRAITS - T v = *i; -#else - typename std::iterator_traits::value_type v = *i; -#endif - assert(v == val); -#if 0 - // hmm, this will give a warning for transform_iterator... perhaps - // this should be separated out into a stand-alone test since there - // are several situations where it can't be used, like for - // integer_range::iterator. - assert(v == i->foo()); -#endif - k = i; - assert(k == k); - assert(k == i); - assert(k != j); - assert(*k == val); -} - - -// Preconditions: i != j -template -void mutable_trivial_iterator_test(const Iterator i, const Iterator j, T val) -{ - *i = val; - trivial_iterator_test(i, j, val); -} - - -// Preconditions: *i == v1, *++i == v2 -template -void input_iterator_test(Iterator i, T v1, T v2) -{ - Iterator i1(i); - - assert(i == i1); - assert(!(i != i1)); - - // 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? - - -template struct lvalue_test -{ - template static void check(Iterator) - { -# ifndef BOOST_NO_STD_ITERATOR_TRAITS - typedef typename std::iterator_traits::reference reference; - typedef typename std::iterator_traits::value_type value_type; -# else - typedef typename Iterator::reference reference; - typedef typename Iterator::value_type value_type; -# endif - BOOST_STATIC_ASSERT(boost::is_reference::value); - BOOST_STATIC_ASSERT((boost::is_same::value - || boost::is_same::value - )); - } -}; - -# ifdef BOOST_NO_STD_ITERATOR_TRAITS -template <> struct lvalue_test { - template static void check(T) {} -}; -#endif - -template -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::value)>::check(i); -#endif -} - -// Preconditions: *i == v1, *++i == v2 -template -void bidirectional_iterator_test(Iterator i, T v1, T v2) -{ - forward_iterator_test(i, v1, v2); - ++i; - - Iterator i1 = i, i2 = i; - - assert(i == i1--); - assert(i != --i2); - - trivial_iterator_test(i, i1, v2); - trivial_iterator_test(i, i2, v2); - - --i; - assert(i == i1); - assert(i == i2); - ++i1; - ++i2; - - trivial_iterator_test(i, i1, v1); - trivial_iterator_test(i, i2, v1); -} - -// mutable_bidirectional_iterator_test - -template struct undefined; - -// Preconditions: [i,i+N) is a valid range -template -void random_access_iterator_test(Iterator i, int N, TrueVals vals) -{ - bidirectional_iterator_test(i, vals[0], vals[1]); - const Iterator j = i; - int c; - - typedef typename boost::detail::iterator_traits::value_type value_type; - - for (c = 0; c < N-1; ++c) { - assert(i == j + c); - assert(*i == vals[c]); - assert(*i == boost::implicit_cast(j[c])); - assert(*i == *(j + c)); - assert(*i == *(c + j)); - ++i; - assert(i > j); - assert(i >= j); - assert(j <= i); - assert(j < i); - } - - Iterator k = j + N - 1; - for (c = 0; c < N-1; ++c) { - assert(i == k - c); - assert(*i == vals[N - 1 - c]); - assert(*i == boost::implicit_cast(j[N - 1 - c])); - Iterator q = k - c; - assert(*i == *q); - assert(i > j); - assert(i >= j); - assert(j <= i); - assert(j < i); - --i; - } -} - -// Precondition: i != j -template -void const_nonconst_iterator_test(Iterator i, ConstIterator j) -{ - assert(i != j); - assert(j != i); - - ConstIterator k(i); - assert(k == i); - assert(i == k); - - k = i; - assert(k == i); - assert(i == k); -} - -} // namespace boost - -#endif // BOOST_ITERATOR_TESTS_HPP diff --git a/include/boost/pointee.hpp b/include/boost/pointee.hpp deleted file mode 100755 index d4339b9..0000000 --- a/include/boost/pointee.hpp +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright David Abrahams 2004. Use, modification and distribution is -// subject to the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#ifndef POINTEE_DWA200415_HPP -# define POINTEE_DWA200415_HPP - -// dereferenceable_traits provides access to the value_type and -// reference of a Dereferenceable type. - -# include -# include -# include -# include -# include -# include - -namespace boost { - -namespace detail -{ - template - struct smart_ptr_pointee - { - typedef typename P::element_type type; - }; - - template - struct iterator_pointee - { - typedef typename iterator_traits::value_type value_type; - - struct impl - { - template - static char test(T const&); - - static char (& test(value_type&) )[2]; - - static Iterator& x; - }; - - BOOST_STATIC_CONSTANT(bool, is_constant = sizeof(impl::test(*impl::x)) == 1); - - typedef typename mpl::if_c< -# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) - ::boost::detail::iterator_pointee::is_constant -# else - is_constant -# endif - , typename add_const::type - , value_type - >::type type; - }; -} - -template -struct pointee -{ - typedef typename remove_cv

::type stripped; - - typedef typename mpl::apply_if< - detail::is_incrementable - , detail::iterator_pointee - , detail::smart_ptr_pointee - >::type type; -}; - -} // namespace boost - -#endif // POINTEE_DWA200415_HPP diff --git a/include/boost/shared_container_iterator.hpp b/include/boost/shared_container_iterator.hpp deleted file mode 100644 index 7d8ecd3..0000000 --- a/include/boost/shared_container_iterator.hpp +++ /dev/null @@ -1,62 +0,0 @@ -// (C) Copyright Ronald Garcia 2002. Permission to copy, use, modify, sell and -// distribute this software is granted provided this copyright notice appears -// in all copies. This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. - -// See http://www.boost.org/libs/utility/shared_container_iterator.html for documentation. - -#ifndef SHARED_CONTAINER_ITERATOR_RG08102002_HPP -#define SHARED_CONTAINER_ITERATOR_RG08102002_HPP - -#include "boost/iterator_adaptors.hpp" -#include "boost/shared_ptr.hpp" -#include - -namespace boost { - -template -class shared_container_iterator : public iterator_adaptor< - shared_container_iterator, - typename Container::iterator> { - - typedef iterator_adaptor< - shared_container_iterator, - typename Container::iterator> super_t; - - typedef typename Container::iterator iterator_t; - typedef boost::shared_ptr container_ref_t; - - container_ref_t container_ref; -public: - shared_container_iterator() { } - - shared_container_iterator(iterator_t const& x,container_ref_t const& c) : - super_t(x), container_ref(c) { } - - -}; - -template -shared_container_iterator -make_shared_container_iterator(typename Container::iterator iter, - boost::shared_ptr const& container) { - typedef shared_container_iterator iterator; - return iterator(iter,container); -} - - - -template -std::pair< - shared_container_iterator, - shared_container_iterator > -make_shared_container_range(boost::shared_ptr const& container) { - return - std::make_pair( - make_shared_container_iterator(container->begin(),container), - make_shared_container_iterator(container->end(),container)); -} - - -} // namespace boost -#endif // SHARED_CONTAINER_ITERATOR_RG08102002_HPP diff --git a/test/Jamfile b/test/Jamfile deleted file mode 100644 index b5629e4..0000000 --- a/test/Jamfile +++ /dev/null @@ -1,58 +0,0 @@ -# Copyright David Abrahams 2003. Permission to copy, use, -# modify, sell and distribute this software is granted provided this -# copyright notice appears in all copies. This software is provided -# "as is" without express or implied warranty, and with no claim as -# to its suitability for any purpose. - -subproject libs/iterator/test ; - -import testing ; - -test-suite iterator - : - # These first two tests will run last, and are expected to fail - # for many less-capable compilers. - - [ compile-fail interoperable_fail.cpp ] - # test uses expected success, so that we catch unrelated - # compilation problems. - [ run is_convertible_fail.cpp ] - - [ run zip_iterator_test.cpp - : : : - - # stlport's debug mode generates long symbols which overwhelm - # vc6 - <*>release - ] - - # These tests should work for just about everything. - [ compile is_lvalue_iterator.cpp ] - [ compile is_readable_iterator.cpp ] - [ compile pointee.cpp ] - - [ run unit_tests.cpp ] - [ run concept_tests.cpp ] - [ run iterator_adaptor_cc.cpp ] - [ run iterator_adaptor_test.cpp ] - [ compile iterator_archetype_cc.cpp ] - [ run transform_iterator_test.cpp ] - [ run indirect_iterator_test.cpp ] - [ compile indirect_iterator_member_types.cpp ] - [ run filter_iterator_test.cpp ] - [ run reverse_iterator_test.cpp ] - [ run counting_iterator_test.cpp ] - [ run permutation_iterator_test.cpp : : : # on - ] - - [ run ../../utility/iterator_adaptor_examples.cpp ] - [ run ../../utility/counting_iterator_example.cpp ] - [ run ../../utility/filter_iterator_example.cpp ] - [ run ../../utility/fun_out_iter_example.cpp ] - [ run ../../utility/indirect_iterator_example.cpp ] - [ run ../../utility/projection_iterator_example.cpp ] - [ run ../../utility/reverse_iterator_example.cpp ] - [ run ../../utility/transform_iterator_example.cpp ] - [ run ../../utility/iterator_traits_test.cpp ] - -; diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 deleted file mode 100644 index 4cdb206..0000000 --- a/test/Jamfile.v2 +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright David Abrahams 2003. Permission to copy, use, -# modify, sell and distribute this software is granted provided this -# copyright notice appears in all copies. This software is provided -# "as is" without express or implied warranty, and with no claim as -# to its suitability for any purpose. - -import testing ; - -test-suite iterator - : - # These first two tests will run last, and are expected to fail - # for many less-capable compilers. - - [ compile-fail interoperable_fail.cpp ] - # test uses expected success, so that we catch unrelated - # compilation problems. - [ run is_convertible_fail.cpp ] - - # These tests should work for just about everything. - [ run unit_tests.cpp ] - [ run concept_tests.cpp ] - [ run iterator_adaptor_cc.cpp ] - [ run iterator_adaptor_test.cpp ] - [ compile iterator_archetype_cc.cpp ] - [ run transform_iterator_test.cpp ] - [ run indirect_iterator_test.cpp ] - [ run filter_iterator_test.cpp ] - [ run reverse_iterator_test.cpp ] - [ run counting_iterator_test.cpp ] - [ run permutation_iterator_test.cpp : : : # on - ] - [ run zip_iterator_test.cpp ] - - [ run ../../utility/iterator_adaptor_examples.cpp ] - [ run ../../utility/counting_iterator_example.cpp ] - [ run ../../utility/filter_iterator_example.cpp ] - [ run ../../utility/fun_out_iter_example.cpp ] - [ run ../../utility/indirect_iterator_example.cpp ] - [ run ../../utility/projection_iterator_example.cpp ] - [ run ../../utility/reverse_iterator_example.cpp ] - [ run ../../utility/transform_iterator_example.cpp ] - [ run ../../utility/iterator_traits_test.cpp ] - -; diff --git a/test/concept_tests.cpp b/test/concept_tests.cpp deleted file mode 100644 index 399911d..0000000 --- a/test/concept_tests.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// (C) Copyright Jeremy Siek 2002. Permission to copy, use, modify, -// sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. - -#include -#include -#include - -struct new_random_access - : std::random_access_iterator_tag - , boost::random_access_traversal_tag -{}; - -struct new_iterator - : public boost::iterator< new_random_access, int > -{ - 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 -{ - 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() -{ - boost::iterator_traversal::type tc; - boost::random_access_traversal_tag derived = tc; - (void)derived; - - boost::function_requires< - boost_concepts::WritableLvalueIteratorConcept >(); - boost::function_requires< - boost_concepts::RandomAccessTraversalConcept >(); - - boost::function_requires< - boost_concepts::ReadableLvalueIteratorConcept >(); - boost::function_requires< - boost_concepts::RandomAccessTraversalConcept >(); - - boost::function_requires< - boost_concepts::WritableLvalueIteratorConcept >(); - boost::function_requires< - boost_concepts::RandomAccessTraversalConcept >(); - - boost::function_requires< - boost_concepts::WritableLvalueIteratorConcept >(); - boost::function_requires< - boost_concepts::RandomAccessTraversalConcept >(); - return 0; -} diff --git a/test/counting_iterator_test.cpp b/test/counting_iterator_test.cpp deleted file mode 100644 index 73f69f9..0000000 --- a/test/counting_iterator_test.cpp +++ /dev/null @@ -1,295 +0,0 @@ -// (C) Copyright David Abrahams 2001. Permission to copy, use, modify, sell and -// distribute this software is granted provided this copyright notice appears in -// all copies. This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -// See http://www.boost.org for most recent version including documentation. -// -// Revision History -// 16 Feb 2001 Added a missing const. Made the tests run (somewhat) with -// plain MSVC again. (David Abrahams) -// 11 Feb 2001 #if 0'd out use of counting_iterator on non-numeric types in -// MSVC without STLport, so that the other tests may proceed -// (David Abrahams) -// 04 Feb 2001 Added use of iterator_tests.hpp (David Abrahams) -// 28 Jan 2001 Removed not_an_iterator detritus (David Abrahams) -// 24 Jan 2001 Initial revision (David Abrahams) - -#include - -#ifdef __BORLANDC__ // Borland mis-detects our custom iterators -# pragma warn -8091 // template argument ForwardIterator passed to '...' is a output iterator -# pragma warn -8071 // Conversion may lose significant digits (due to counting_iterator += n). -#endif - -#ifdef BOOST_MSVC -# pragma warning(disable:4786) // identifier truncated in debug info -#endif - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#ifndef __BORLANDC__ -# include -#endif -#include -#include -#include -#ifndef BOOST_NO_SLIST -# include -#endif - - -#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS -template -struct signed_assert_nonnegative -{ - static void test(T x) { assert(x >= 0); } -}; - -template -struct unsigned_assert_nonnegative -{ - static void test(T x) {} -}; - -template -struct assert_nonnegative - : boost::mpl::if_c< - std::numeric_limits::is_signed - , signed_assert_nonnegative - , unsigned_assert_nonnegative - >::type -{ -}; -#endif - -// Special tests for RandomAccess CountingIterators. -template -void category_test( - CountingIterator start, - CountingIterator finish, - Value, - std::random_access_iterator_tag) -{ - typedef typename - boost::detail::iterator_traits::difference_type - difference_type; - difference_type distance = boost::detail::distance(start, finish); - - // Pick a random position internal to the range - difference_type offset = (unsigned)rand() % distance; - -#ifdef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS - assert(offset >= 0); -#else - assert_nonnegative::test(offset); -#endif - - CountingIterator internal = start; - std::advance(internal, offset); - - // Try some binary searches on the range to show that it's ordered - assert(std::binary_search(start, finish, *internal)); - - // #including tuple crashed borland, so I had to give up on tie(). - std::pair xy( - std::equal_range(start, finish, *internal)); - CountingIterator x = xy.first, y = xy.second; - - assert(boost::detail::distance(x, y) == 1); - - // Show that values outside the range can't be found - assert(!std::binary_search(start, boost::prior(finish), *finish)); - - // Do the generic random_access_iterator_test - typedef typename CountingIterator::value_type value_type; - std::vector v; - for (value_type z = *start; !(z == *finish); ++z) - v.push_back(z); - - // Note that this test requires a that the first argument is - // dereferenceable /and/ a valid iterator prior to the first argument - boost::random_access_iterator_test(start, v.size(), v.begin()); -} - -// Special tests for bidirectional CountingIterators -template -void category_test(CountingIterator start, Value v1, std::bidirectional_iterator_tag) -{ - Value v2 = v1; - ++v2; - - // Note that this test requires a that the first argument is - // dereferenceable /and/ a valid iterator prior to the first argument - boost::bidirectional_iterator_test(start, v1, v2); -} - -template -void category_test(CountingIterator start, CountingIterator finish, Value v1, std::forward_iterator_tag) -{ - Value v2 = v1; - ++v2; - if (finish != start && finish != boost::next(start)) - boost::forward_readable_iterator_test(start, finish, v1, v2); -} - -template -void test_aux(CountingIterator start, CountingIterator finish, Value v1) -{ - typedef typename CountingIterator::iterator_category category; - typedef typename CountingIterator::value_type value_type; - - // If it's a RandomAccessIterator we can do a few delicate tests - category_test(start, finish, v1, category()); - - // Okay, brute force... - for (CountingIterator p = start - ; p != finish && boost::next(p) != finish - ; ++p) - { - assert(boost::next(*p) == *boost::next(p)); - } - - // prove that a reference can be formed to these values - typedef typename CountingIterator::value_type value; - const value* q = &*start; - (void)q; // suppress unused variable warning -} - -template -void test(Incrementable start, Incrementable finish) -{ - test_aux(boost::make_counting_iterator(start), boost::make_counting_iterator(finish), start); -} - -template -void test_integer(Integer* = 0) // default arg works around MSVC bug -{ - Integer start = 0; - Integer finish = 120; - test(start, finish); -} - -template -void test_integer3(Integer* = 0, Category* = 0, Difference* = 0) // default arg works around MSVC bug -{ - Integer start = 0; - Integer finish = 120; - typedef boost::counting_iterator iterator; - test_aux(iterator(start), iterator(finish), start); -} - -template -void test_container(Container* = 0) // default arg works around MSVC bug -{ - Container c(1 + (unsigned)rand() % 1673); - - const typename Container::iterator start = c.begin(); - - // back off by 1 to leave room for dereferenceable value at the end - typename Container::iterator finish = start; - std::advance(finish, c.size() - 1); - - test(start, finish); - - typedef typename Container::const_iterator const_iterator; - test(const_iterator(start), const_iterator(finish)); -} - -class my_int1 { -public: - my_int1() { } - my_int1(int x) : m_int(x) { } - my_int1& operator++() { ++m_int; return *this; } - bool operator==(const my_int1& x) const { return m_int == x.m_int; } -private: - int m_int; -}; - -class my_int2 { -public: - typedef void value_type; - typedef void pointer; - typedef void reference; - typedef std::ptrdiff_t difference_type; - typedef std::bidirectional_iterator_tag iterator_category; - - my_int2() { } - my_int2(int x) : m_int(x) { } - my_int2& operator++() { ++m_int; return *this; } - my_int2& operator--() { --m_int; return *this; } - bool operator==(const my_int2& x) const { return m_int == x.m_int; } -private: - int m_int; -}; - -class my_int3 { -public: - typedef void value_type; - typedef void pointer; - typedef void reference; - typedef std::ptrdiff_t difference_type; - typedef std::random_access_iterator_tag iterator_category; - - my_int3() { } - my_int3(int x) : m_int(x) { } - my_int3& operator++() { ++m_int; return *this; } - my_int3& operator+=(std::ptrdiff_t n) { m_int += n; return *this; } - std::ptrdiff_t operator-(const my_int3& x) const { return m_int - x.m_int; } - my_int3& operator--() { --m_int; return *this; } - bool operator==(const my_int3& x) const { return m_int == x.m_int; } - bool operator!=(const my_int3& x) const { return m_int != x.m_int; } - bool operator<(const my_int3& x) const { return m_int < x.m_int; } -private: - int m_int; -}; - -int main() -{ - // Test the built-in integer types. - test_integer(); - test_integer(); - test_integer(); - test_integer(); - test_integer(); - test_integer(); - test_integer(); - test_integer(); - test_integer(); - test_integer(); -#if defined(BOOST_HAS_LONG_LONG) - test_integer(); - test_integer(); -#endif - - // Test user-defined type. - - test_integer3(); - test_integer(); - test_integer(); - - // Some tests on container iterators, to prove we handle a few different categories - test_container >(); - test_container >(); -# ifndef BOOST_NO_SLIST - test_container >(); -# endif - - // Also prove that we can handle raw pointers. - int array[2000]; - test(boost::make_counting_iterator(array), boost::make_counting_iterator(array+2000-1)); - - return 0; -} diff --git a/test/filter_iterator_test.cpp b/test/filter_iterator_test.cpp deleted file mode 100644 index edf3ccf..0000000 --- a/test/filter_iterator_test.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright David Abrahams 2003. Permission to copy, use, -// modify, sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. - -#include -#include -#include -#include - -#include -#include - -using boost::dummyT; - -struct one_or_four -{ - bool operator()(dummyT x) const - { - return x.foo() == 1 || x.foo() == 4; - } -}; - -template struct undefined; - -// Test filter iterator -int main() -{ - dummyT array[] = { dummyT(0), dummyT(1), dummyT(2), - dummyT(3), dummyT(4), dummyT(5) }; - const int N = sizeof(array)/sizeof(dummyT); - - typedef boost::filter_iterator filter_iter; - - boost::bidirectional_readable_iterator_test( - filter_iter(one_or_four(), array, array+N) - , dummyT(1), dummyT(4)); - - BOOST_STATIC_ASSERT( - (!boost::is_convertible< - boost::iterator_traversal::type - , boost::random_access_traversal_tag - >::value - )); - - //# endif - - // On compilers not supporting partial specialization, we can do more type - // deduction with deque iterators than with pointers... unless the library - // is broken ;-( - std::deque array2; - std::copy(array+0, array+N, std::back_inserter(array2)); - boost::bidirectional_readable_iterator_test( - boost::make_filter_iterator(one_or_four(), array2.begin(), array2.end()), - dummyT(1), dummyT(4)); - - boost::bidirectional_readable_iterator_test( - boost::make_filter_iterator(one_or_four(), array2.begin(), array2.end()), - dummyT(1), dummyT(4)); - - boost::bidirectional_readable_iterator_test( - boost::make_filter_iterator( - one_or_four() - , boost::make_reverse_iterator(array2.end()) - , boost::make_reverse_iterator(array2.begin()) - ), - dummyT(4), dummyT(1)); - - boost::bidirectional_readable_iterator_test( - filter_iter(array+0, array+N), - dummyT(1), dummyT(4)); - - boost::bidirectional_readable_iterator_test( - filter_iter(one_or_four(), array, array + N), - dummyT(1), dummyT(4)); - - std::cout << "test successful " << std::endl; - return 0; -} diff --git a/test/indirect_iterator_member_types.cpp b/test/indirect_iterator_member_types.cpp deleted file mode 100644 index b4013ad..0000000 --- a/test/indirect_iterator_member_types.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// (C) Copyright Jeremy Siek 2004. Permission to copy, use, modify, -// sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. - -// Revision History -// 03 Jan 2004 Jeremy Siek -// First draft. - - -#include -#include - -#include -#include -#include "static_assert_same.hpp" -#include - -struct zow { }; - -struct my_ptr { - typedef zow const element_type; -// typedef const zow& reference; -// typedef const zow* pointer; -// typedef void difference_type; -// typedef boost::no_traversal_tag iterator_category; -}; - -BOOST_TT_BROKEN_COMPILER_SPEC(my_ptr) -BOOST_TT_BROKEN_COMPILER_SPEC(zow) - -// Borland 5.6.4 and earlier drop const all over the place, so this -// test will fail in the lines marked with (**) - -int main() -{ - { - typedef boost::indirect_iterator Iter; - STATIC_ASSERT_SAME(Iter::value_type, int); - STATIC_ASSERT_SAME(Iter::reference, int&); - STATIC_ASSERT_SAME(Iter::pointer, int*); - STATIC_ASSERT_SAME(Iter::difference_type, std::ptrdiff_t); - - BOOST_STATIC_ASSERT((boost::is_convertible::value)); - BOOST_STATIC_ASSERT((boost::is_convertible::type, - boost::random_access_traversal_tag>::value)); - } - { - typedef boost::indirect_iterator Iter; - STATIC_ASSERT_SAME(Iter::value_type, int); - STATIC_ASSERT_SAME(Iter::reference, const int&); - STATIC_ASSERT_SAME(Iter::pointer, const int*); // (**) - } - { - typedef boost::indirect_iterator Iter; - STATIC_ASSERT_SAME(Iter::value_type, int); - STATIC_ASSERT_SAME(Iter::reference, int&); - STATIC_ASSERT_SAME(Iter::pointer, int*); - } - { - typedef boost::indirect_iterator Iter; - STATIC_ASSERT_SAME(Iter::value_type, int); - STATIC_ASSERT_SAME(Iter::reference, const int&); - STATIC_ASSERT_SAME(Iter::pointer, const int*); // (**) - } - { - typedef boost::indirect_iterator Iter; - STATIC_ASSERT_SAME(Iter::value_type, zow); - STATIC_ASSERT_SAME(Iter::reference, const zow&); // (**) - STATIC_ASSERT_SAME(Iter::pointer, const zow*); // (**) - - STATIC_ASSERT_SAME(Iter::difference_type, std::ptrdiff_t); - - BOOST_STATIC_ASSERT((boost::is_convertible::value)); - BOOST_STATIC_ASSERT((boost::is_convertible::type, - boost::random_access_traversal_tag>::value)); - } - { - typedef boost::indirect_iterator Iter; - STATIC_ASSERT_SAME(Iter::value_type, int); - STATIC_ASSERT_SAME(Iter::reference, long&); - STATIC_ASSERT_SAME(Iter::pointer, int*); - STATIC_ASSERT_SAME(Iter::difference_type, short); - } - return 0; -} diff --git a/test/indirect_iterator_test.cpp b/test/indirect_iterator_test.cpp deleted file mode 100644 index 56db69b..0000000 --- a/test/indirect_iterator_test.cpp +++ /dev/null @@ -1,220 +0,0 @@ -// (C) Copyright Jeremy Siek 1999. Permission to copy, use, modify, -// sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. - -// Revision History -// 22 Nov 2002 Thomas Witt -// Added interoperability check. -// 08 Mar 2001 Jeremy Siek -// Moved test of indirect iterator into its own file. It to -// to be in iterator_adaptor_test.cpp. - -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#if !defined(__SGI_STL_PORT) \ - && (defined(BOOST_MSVC_STD_ITERATOR) \ - || BOOST_WORKAROUND(_CPPLIB_VER, <= 310) \ - || BOOST_WORKAROUND(__GNUC__, <= 2)) - -// std container random-access iterators don't support mutable/const -// interoperability (but may support const/mutable interop). -# define NO_MUTABLE_CONST_STD_SET_ITERATOR_INTEROPERABILITY - -#endif - - -template struct see_type; -template struct see_val; - -struct my_iterator_tag : public std::random_access_iterator_tag { }; - -using boost::dummyT; -BOOST_TT_BROKEN_COMPILER_SPEC(boost::shared_ptr) - -typedef std::vector storage; -typedef std::vector pointer_ra_container; -typedef std::set iterator_set; - -template -struct indirect_iterator_pair_generator -{ - typedef boost::indirect_iterator iterator; - - typedef boost::indirect_iterator< - typename Container::iterator - , typename iterator::value_type const - > const_iterator; -}; - -void more_indirect_iterator_tests() -{ - storage store(1000); - std::generate(store.begin(), store.end(), rand); - - pointer_ra_container ptr_ra_container; - iterator_set iter_set; - - for (storage::iterator p = store.begin(); p != store.end(); ++p) - { - ptr_ra_container.push_back(&*p); - iter_set.insert(p); - } - - typedef indirect_iterator_pair_generator indirect_ra_container; - - indirect_ra_container::iterator db(ptr_ra_container.begin()); - indirect_ra_container::iterator de(ptr_ra_container.end()); - assert(static_cast(de - db) == store.size()); - assert(db + store.size() == de); - indirect_ra_container::const_iterator dci = db; - - assert(dci == db); - -#ifndef NO_MUTABLE_CONST_RA_ITERATOR_INTEROPERABILITY - assert(db == dci); -#endif - - assert(dci != de); - assert(dci < de); - assert(dci <= de); - -#ifndef NO_MUTABLE_CONST_RA_ITERATOR_INTEROPERABILITY - assert(de >= dci); - assert(de > dci); -#endif - - dci = de; - assert(dci == de); - - boost::random_access_iterator_test(db + 1, store.size() - 1, boost::next(store.begin())); - - *db = 999; - assert(store.front() == 999); - - // Borland C++ is getting very confused about the typedefs here - typedef boost::indirect_iterator indirect_set_iterator; - typedef boost::indirect_iterator< - iterator_set::iterator - , iterator_set::iterator::value_type const - > const_indirect_set_iterator; - - indirect_set_iterator sb(iter_set.begin()); - indirect_set_iterator se(iter_set.end()); - const_indirect_set_iterator sci(iter_set.begin()); - assert(sci == sb); - -# ifndef NO_MUTABLE_CONST_STD_SET_ITERATOR_INTEROPERABILITY - assert(se != sci); -# endif - - assert(sci != se); - sci = se; - assert(sci == se); - - *boost::prior(se) = 888; - assert(store.back() == 888); - assert(std::equal(sb, se, store.begin())); - - boost::bidirectional_iterator_test(boost::next(sb), store[1], store[2]); - assert(std::equal(db, de, store.begin())); -} - -// element_type detector; defaults to true so the test passes when -// has_xxx isn't implemented -BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_element_type, element_type, true) - -int -main() -{ - dummyT array[] = { dummyT(0), dummyT(1), dummyT(2), - dummyT(3), dummyT(4), dummyT(5) }; - const int N = sizeof(array)/sizeof(dummyT); - -# if BOOST_WORKAROUND(BOOST_MSVC, == 1200) - boost::shared_ptr zz((dummyT*)0); // Why? I don't know, but it suppresses a bad instantiation. -# endif - - typedef std::vector > shared_t; - shared_t shared; - - // Concept checks - { - typedef boost::indirect_iterator iter_t; - - BOOST_STATIC_ASSERT( - has_element_type< - boost::detail::iterator_traits::value_type - >::value - ); - - typedef boost::indirect_iterator< - shared_t::iterator - , boost::iterator_value::type const - > c_iter_t; - -# ifndef NO_MUTABLE_CONST_RA_ITERATOR_INTEROPERABILITY - boost::function_requires< boost_concepts::InteroperableConcept >(); -# endif - } - - // Test indirect_iterator_generator - { - for (int jj = 0; jj < N; ++jj) - shared.push_back(boost::shared_ptr(new dummyT(jj))); - - dummyT* ptr[N]; - for (int k = 0; k < N; ++k) - ptr[k] = array + k; - - typedef boost::indirect_iterator indirect_iterator; - - typedef boost::indirect_iterator - const_indirect_iterator; - - indirect_iterator i(ptr); - boost::random_access_iterator_test(i, N, array); - - boost::random_access_iterator_test( - boost::indirect_iterator(shared.begin()) - , N, array); - - boost::random_access_iterator_test(boost::make_indirect_iterator(ptr), N, array); - - // check operator-> - assert((*i).m_x == i->foo()); - - const_indirect_iterator j(ptr); - boost::random_access_iterator_test(j, N, array); - - dummyT const*const* const_ptr = ptr; - boost::random_access_iterator_test(boost::make_indirect_iterator(const_ptr), N, array); - - boost::const_nonconst_iterator_test(i, ++j); - - more_indirect_iterator_tests(); - } - std::cout << "test successful " << std::endl; - return 0; -} diff --git a/test/interoperable_fail.cpp b/test/interoperable_fail.cpp deleted file mode 100644 index d3d869d..0000000 --- a/test/interoperable_fail.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright Thomas Witt 2003. Permission to copy, use, -// modify, sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. -#include -#include -#include -#include -#include - -int main() -{ - { - typedef boost::reverse_iterator::iterator> rev_iter; - typedef boost::indirect_iterator::iterator> ind_iter; - - ind_iter() == rev_iter(); - } - - return boost::exit_success; -} diff --git a/test/is_convertible_fail.cpp b/test/is_convertible_fail.cpp deleted file mode 100644 index 7d3c9b1..0000000 --- a/test/is_convertible_fail.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include - -int main() -{ - typedef boost::reverse_iterator rev_iter1; - typedef boost::reverse_iterator rev_iter2; - - return boost::is_convertible::value - ? boost::exit_failure : boost::exit_success; -} diff --git a/test/is_lvalue_iterator.cpp b/test/is_lvalue_iterator.cpp deleted file mode 100755 index fdace52..0000000 --- a/test/is_lvalue_iterator.cpp +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright David Abrahams 2003. Use, modification and distribution is -// subject to the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include -#include -#include -#include -#include -#include - -// Last, for BOOST_NO_LVALUE_RETURN_DETECTION -#include - -struct v -{ - v(); - ~v(); -}; - -BOOST_TT_BROKEN_COMPILER_SPEC(v) - -struct value_iterator : boost::iterator -{ - v operator*() const; -}; - -struct noncopyable_iterator : boost::iterator -{ - boost::noncopyable const& operator*() const; -}; - -template -struct proxy_iterator - : boost::iterator -{ - typedef T value_type; - -#if BOOST_WORKAROUND(__GNUC__, == 2) - typedef boost::iterator base; - typedef base::iterator_category iterator_category; - typedef base::difference_type difference_type; - typedef base::pointer pointer; - typedef base::reference reference; -#endif - - struct proxy - { - operator value_type&() const; - proxy& operator=(value_type) const; - }; - - proxy operator*() const; -}; - -template -struct lvalue_iterator -{ - typedef T value_type; - typedef T& reference; - typedef T difference_type; - typedef std::input_iterator_tag iterator_category; - typedef T* pointer; - - T& operator*() const; - lvalue_iterator& operator++(); - lvalue_iterator operator++(int); -}; - -template -struct constant_lvalue_iterator -{ - typedef T value_type; - typedef T const& reference; - typedef T difference_type; - typedef std::input_iterator_tag iterator_category; - typedef T const* pointer; - - T const& operator*() const; - constant_lvalue_iterator& operator++(); - constant_lvalue_iterator operator++(int); -}; - -BOOST_TT_BROKEN_COMPILER_SPEC(proxy_iterator::proxy) -BOOST_TT_BROKEN_COMPILER_SPEC(proxy_iterator::proxy) - -int main() -{ - BOOST_STATIC_ASSERT(boost::is_lvalue_iterator::value); - BOOST_STATIC_ASSERT(boost::is_lvalue_iterator::value); - BOOST_STATIC_ASSERT(boost::is_lvalue_iterator::iterator>::value); - BOOST_STATIC_ASSERT(boost::is_lvalue_iterator::const_iterator>::value); - BOOST_STATIC_ASSERT(!boost::is_lvalue_iterator > >::value); - BOOST_STATIC_ASSERT(!boost::is_lvalue_iterator >::value); - BOOST_STATIC_ASSERT(!boost::is_lvalue_iterator >::value); - BOOST_STATIC_ASSERT(!boost::is_lvalue_iterator >::value); -#ifndef BOOST_NO_LVALUE_RETURN_DETECTION - BOOST_STATIC_ASSERT(!boost::is_lvalue_iterator::value); -#endif - // Make sure inaccessible copy constructor doesn't prevent - // reference binding - BOOST_STATIC_ASSERT(boost::is_lvalue_iterator::value); - - BOOST_STATIC_ASSERT(boost::is_lvalue_iterator >::value); - BOOST_STATIC_ASSERT(boost::is_lvalue_iterator >::value); - BOOST_STATIC_ASSERT(boost::is_lvalue_iterator >::value); - BOOST_STATIC_ASSERT(boost::is_lvalue_iterator >::value); - - - BOOST_STATIC_ASSERT(boost::is_lvalue_iterator >::value); - BOOST_STATIC_ASSERT(boost::is_lvalue_iterator >::value); - BOOST_STATIC_ASSERT(boost::is_lvalue_iterator >::value); - BOOST_STATIC_ASSERT(boost::is_lvalue_iterator >::value); - - - - BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator::value); - BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator::value); - BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator::iterator>::value); - BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator::const_iterator>::value); - BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator > >::value); - BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator >::value); - BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator >::value); - BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator >::value); -#ifndef BOOST_NO_LVALUE_RETURN_DETECTION - BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator::value); -#endif - BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator::value); - - BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator >::value); -#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) - BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator >::value); -#endif - BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator >::value); - BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator >::value); - - BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator >::value); - BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator >::value); - BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator >::value); - BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator >::value); - - return 0; -} diff --git a/test/is_readable_iterator.cpp b/test/is_readable_iterator.cpp deleted file mode 100755 index 15ed099..0000000 --- a/test/is_readable_iterator.cpp +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright David Abrahams 2003. Use, modification and distribution is -// subject to the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include -#include -#include -#include -#include -#include - -// Last, for BOOST_NO_LVALUE_RETURN_DETECTION -#include - -struct v -{ - v(); - ~v(); -}; - -BOOST_TT_BROKEN_COMPILER_SPEC(v) - -struct value_iterator : boost::iterator -{ - v operator*() const; -}; - -struct noncopyable_iterator : boost::iterator -{ - boost::noncopyable const& operator*() const; -}; - -struct proxy_iterator : boost::iterator -{ -#if BOOST_WORKAROUND(__GNUC__, == 2) - typedef boost::iterator base; - typedef base::iterator_category iterator_category; - typedef base::value_type value_type; - typedef base::difference_type difference_type; - typedef base::pointer pointer; - typedef base::reference reference; -#endif - - struct proxy - { - operator v&(); - proxy& operator=(v) const; - }; - - proxy operator*() const; -}; - -struct proxy_iterator2 : boost::iterator -{ -#if BOOST_WORKAROUND(__GNUC__, == 2) - typedef boost::iterator base; - typedef base::iterator_category iterator_category; - typedef base::value_type value_type; - typedef base::difference_type difference_type; - typedef base::pointer pointer; - typedef base::reference reference; -#endif - - struct proxy - { - proxy& operator=(v) const; - }; - - proxy operator*() const; -}; - -BOOST_TT_BROKEN_COMPILER_SPEC(proxy_iterator::proxy) - -int main() -{ - BOOST_STATIC_ASSERT(boost::is_readable_iterator::value); - BOOST_STATIC_ASSERT(boost::is_readable_iterator::value); - BOOST_STATIC_ASSERT(boost::is_readable_iterator::iterator>::value); - BOOST_STATIC_ASSERT(boost::is_readable_iterator::const_iterator>::value); - BOOST_STATIC_ASSERT(!boost::is_readable_iterator > >::value); - BOOST_STATIC_ASSERT(!boost::is_readable_iterator >::value); - BOOST_STATIC_ASSERT(boost::is_readable_iterator::value); - BOOST_STATIC_ASSERT(!boost::is_readable_iterator::value); - BOOST_STATIC_ASSERT(boost::is_readable_iterator::value); - - // Make sure inaccessible copy constructor doesn't prevent - // readability - BOOST_STATIC_ASSERT(boost::is_readable_iterator::value); - - return 0; -} diff --git a/test/iterator_adaptor_cc.cpp b/test/iterator_adaptor_cc.cpp deleted file mode 100644 index ba7e79b..0000000 --- a/test/iterator_adaptor_cc.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include -#include -#include -#include - -int main() -{ - { - typedef boost::reverse_iterator rev_iter; - typedef boost::reverse_iterator c_rev_iter; - - boost::function_requires< boost_concepts::WritableLvalueIteratorConcept >(); - boost::function_requires< boost_concepts::RandomAccessTraversalConcept >(); - boost::function_requires< boost::RandomAccessIteratorConcept >(); - boost::function_requires< boost_concepts::InteroperableConcept >(); - } - { - typedef boost::reverse_iterator::iterator> rev_iter; - typedef boost::reverse_iterator::const_iterator> c_rev_iter; - - boost::function_requires< boost_concepts::ReadableLvalueIteratorConcept >(); - boost::function_requires< boost_concepts::BidirectionalTraversalConcept >(); - boost::function_requires< boost::BidirectionalIteratorConcept >(); - boost::function_requires< boost_concepts::InteroperableConcept >(); - } - - return boost::exit_success; -} diff --git a/test/iterator_adaptor_test.cpp b/test/iterator_adaptor_test.cpp deleted file mode 100644 index 961895f..0000000 --- a/test/iterator_adaptor_test.cpp +++ /dev/null @@ -1,323 +0,0 @@ -// (C) Copyright Thomas Witt 2003. Permission to copy, use, modify, -// sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. - -// See http://www.boost.org for most recent version including documentation. - -#include -#include - -#include -#include -#include - -#include -#if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407) -# include -# include -#endif -#include - -# include - -#include -#include -#include -#include -#include - -#include "static_assert_same.hpp" - -#include - -using boost::dummyT; - -struct mult_functor { - typedef int result_type; - typedef int argument_type; - // Functors used with transform_iterator must be - // DefaultConstructible, as the transform_iterator must be - // DefaultConstructible to satisfy the requirements for - // TrivialIterator. - mult_functor() { } - mult_functor(int aa) : a(aa) { } - int operator()(int b) const { return a * b; } - int a; -}; - -template -struct select1st_ - : public std::unary_function -{ - const typename Pair::first_type& operator()(const Pair& x) const { - return x.first; - } - typename Pair::first_type& operator()(Pair& x) const { - return x.first; - } -}; - -struct one_or_four { - bool operator()(dummyT x) const { - return x.foo() == 1 || x.foo() == 4; - } -}; - -typedef std::deque storage; -typedef std::deque pointer_deque; -typedef std::set iterator_set; - -template struct foo; - -void blah(int) { } - -struct my_gen -{ - typedef int result_type; - my_gen() : n(0) { } - int operator()() { return ++n; } - int n; -}; - -template -struct ptr_iterator - : boost::iterator_adaptor< - ptr_iterator - , V* - , V - , boost::random_access_traversal_tag -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) - , V& -#endif - > -{ -private: - typedef boost::iterator_adaptor< - ptr_iterator - , V* - , V - , boost::random_access_traversal_tag -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) - , V& -#endif - > super_t; - -public: - ptr_iterator() { } - ptr_iterator(V* d) : super_t(d) { } - - template - ptr_iterator( - const ptr_iterator& x - , typename boost::enable_if_convertible::type* = 0 - ) - : super_t(x.base()) - {} -}; - -// Non-functional iterator for category modification checking -template -struct modify_traversal - : boost::iterator_adaptor< - modify_traversal - , Iter - , boost::use_default - , Traversal - > -{}; - -template -struct fwd_iterator - : boost::iterator_adaptor< - fwd_iterator - , boost::forward_iterator_archetype - > -{ -private: - typedef boost::iterator_adaptor< - fwd_iterator - , boost::forward_iterator_archetype - > super_t; - -public: - fwd_iterator() { } - fwd_iterator(boost::forward_iterator_archetype d) : super_t(d) { } -}; - -template -struct in_iterator - : boost::iterator_adaptor< - in_iterator - , boost::input_iterator_archetype - > -{ -private: - typedef boost::iterator_adaptor< - in_iterator - , boost::input_iterator_archetype - > super_t; - -public: - in_iterator() { } - in_iterator(boost::input_iterator_archetype d) : super_t(d) { } -}; - -template -struct constant_iterator - : boost::iterator_adaptor< - constant_iterator - , Iter - , typename std::iterator_traits::value_type const - > -{ - typedef boost::iterator_adaptor< - constant_iterator - , Iter - , typename std::iterator_traits::value_type const - > base_t; - - constant_iterator() {} - constant_iterator(Iter it) - : base_t(it) {} -}; - -char (& traversal2(boost::incrementable_traversal_tag) )[1]; -char (& traversal2(boost::single_pass_traversal_tag ) )[2]; -char (& traversal2(boost::forward_traversal_tag ) )[3]; -char (& traversal2(boost::bidirectional_traversal_tag) )[4]; -char (& traversal2(boost::random_access_traversal_tag) )[5]; - -template -struct traversal3 -{ - static typename boost::iterator_category_to_traversal::type x; - BOOST_STATIC_CONSTANT(std::size_t, value = sizeof(traversal2(x))); - typedef char (&type)[value]; -}; - -template -typename traversal3::type traversal(Cat); - -template -int static_assert_traversal(Iter* = 0, Trav* = 0) -{ - typedef typename boost::iterator_category_to_traversal< - BOOST_DEDUCED_TYPENAME Iter::iterator_category - >::type t2; - - return static_assert_same::value; -} - -int -main() -{ - dummyT array[] = { dummyT(0), dummyT(1), dummyT(2), - dummyT(3), dummyT(4), dummyT(5) }; - const int N = sizeof(array)/sizeof(dummyT); - - // sanity check, if this doesn't pass the test is buggy - boost::random_access_iterator_test(array, N, array); - - // Test the iterator_adaptor - { - ptr_iterator i(array); - boost::random_access_iterator_test(i, N, array); - - ptr_iterator j(array); - boost::random_access_iterator_test(j, N, array); - boost::const_nonconst_iterator_test(i, ++j); - } - - int test; - // Test the iterator_traits - { - // Test computation of defaults - typedef ptr_iterator Iter1; - // don't use std::iterator_traits here to avoid VC++ problems - test = static_assert_same::value; - test = static_assert_same::value; - test = static_assert_same::value; - test = static_assert_same::value; -#if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407) - BOOST_STATIC_ASSERT((boost::is_convertible::value)); -#endif - } - - { - // Test computation of default when the Value is const - typedef ptr_iterator Iter1; - test = static_assert_same::value; - test = static_assert_same::value; - -#if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407) - BOOST_STATIC_ASSERT(boost::is_readable_iterator::value); -# ifndef BOOST_NO_LVALUE_RETURN_DETECTION - BOOST_STATIC_ASSERT(boost::is_lvalue_iterator::value); -# endif -#endif - -#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) // borland drops constness - test = static_assert_same::value; -#endif - } - - { - // Test constant iterator idiom - typedef ptr_iterator BaseIter; - typedef constant_iterator Iter; - - test = static_assert_same::value; - test = static_assert_same::value; -#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) // borland drops constness - test = static_assert_same::value; -#endif - -#ifndef BOOST_NO_LVALUE_RETURN_DETECTION - BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator::value); - BOOST_STATIC_ASSERT(boost::is_lvalue_iterator::value); -#endif - - typedef modify_traversal IncrementableIter; - - static_assert_traversal(); - static_assert_traversal(); - } - - // Test the iterator_adaptor - { - ptr_iterator i(array); - boost::random_access_iterator_test(i, N, array); - - ptr_iterator j(array); - boost::random_access_iterator_test(j, N, array); - boost::const_nonconst_iterator_test(i, ++j); - } - - // check operator-> with a forward iterator - { - boost::forward_iterator_archetype forward_iter; - - typedef fwd_iterator adaptor_type; - - adaptor_type i(forward_iter); - int zero = 0; - if (zero) // don't do this, just make sure it compiles - assert((*i).m_x == i->foo()); - } - - // check operator-> with an input iterator - { - boost::input_iterator_archetype input_iter; - typedef in_iterator adaptor_type; - adaptor_type i(input_iter); - int zero = 0; - if (zero) // don't do this, just make sure it compiles - assert((*i).m_x == i->foo()); - } - - std::cout << "test successful " << std::endl; - (void)test; - return 0; -} diff --git a/test/iterator_archetype_cc.cpp b/test/iterator_archetype_cc.cpp deleted file mode 100644 index d5409ce..0000000 --- a/test/iterator_archetype_cc.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// -// Copyright Thomas Witt 2003. Permission to copy, use, -// modify, sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. -// -#include -#include -#include -#include -#include - -int main() -{ - { - typedef boost::iterator_archetype< - int - , boost::iterator_archetypes::readable_iterator_t - , boost::random_access_traversal_tag - > iter; - - boost::function_requires< boost_concepts::ReadableIteratorConcept >(); - boost::function_requires< boost_concepts::RandomAccessTraversalConcept >(); - } - { - typedef boost::iterator_archetype< - int - , boost::iterator_archetypes::readable_writable_iterator_t - , boost::random_access_traversal_tag - > iter; - - boost::function_requires< boost_concepts::ReadableIteratorConcept >(); - boost::function_requires< boost_concepts::WritableIteratorConcept >(); - boost::function_requires< boost_concepts::RandomAccessTraversalConcept >(); - } - { - typedef boost::iterator_archetype< - const int // I don't like adding const to Value. It is redundant. -JGS - , boost::iterator_archetypes::readable_lvalue_iterator_t - , boost::random_access_traversal_tag - > iter; - - boost::function_requires< boost_concepts::ReadableLvalueIteratorConcept >(); - boost::function_requires< boost_concepts::RandomAccessTraversalConcept >(); - } - { - typedef boost::iterator_archetype< - int - , boost::iterator_archetypes::writable_lvalue_iterator_t - , boost::random_access_traversal_tag - > iter; - - boost::function_requires< boost_concepts::WritableLvalueIteratorConcept >(); - boost::function_requires< boost_concepts::RandomAccessTraversalConcept >(); - } - - return boost::exit_success; -} - diff --git a/test/permutation_iterator_test.cpp b/test/permutation_iterator_test.cpp deleted file mode 100644 index f409698..0000000 --- a/test/permutation_iterator_test.cpp +++ /dev/null @@ -1,84 +0,0 @@ -// (C) Copyright Toon Knapen 2001. -// (C) Copyright Roland Richter 2003. -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. - -#include -#include - -#include -#include - -#include -#include - -#include - - -void permutation_test() -{ - // Example taken from documentation of old permutation_iterator. - typedef std::vector< int > element_range_type; - typedef std::list< int > index_type; - - const int element_range_size = 10; - const int index_size = 7; - - BOOST_STATIC_ASSERT(index_size <= element_range_size); - element_range_type elements( element_range_size ); - for( element_range_type::iterator el_it = elements.begin(); el_it != elements.end(); ++el_it ) - { *el_it = std::distance(elements.begin(), el_it); } - - index_type indices( index_size ); - for( index_type::iterator i_it = indices.begin(); i_it != indices.end(); ++i_it ) - { *i_it = element_range_size - index_size + std::distance(indices.begin(), i_it); } - std::reverse( indices.begin(), indices.end() ); - - typedef boost::permutation_iterator< element_range_type::iterator, index_type::iterator > permutation_type; - permutation_type begin = boost::make_permutation_iterator( elements.begin(), indices.begin() ); - permutation_type it = begin; - permutation_type end = boost::make_permutation_iterator( elements.begin(), indices.end() ); - - BOOST_CHECK( it == begin ); - BOOST_CHECK( it != end ); - - BOOST_CHECK( std::distance( begin, end ) == index_size ); - - for( index_type::iterator i_it1 = indices.begin(); it != end; ++i_it1, ++it ) - { - BOOST_CHECK( *it == elements[ *i_it1 ] ); - } - - it = begin; - for( int i1 = 0; i1 < index_size - 1 ; i1+=2, it+=2 ) - { - index_type::iterator i_it2 = indices.begin(); - std::advance( i_it2, i1 ); - BOOST_CHECK( *it == elements[ *i_it2 ] ); - } - - - it = begin + (index_size); - for( index_type::iterator i_it3 = indices.end(); it != begin; ) - { - BOOST_CHECK( *--it == elements[ *--i_it3 ] ); - } - - it = begin + index_size; - for( int i2 = 0; i2 < index_size - 1; i2+=2, --it ) - { - index_type::iterator i_it4 = --indices.end(); - std::advance( i_it4, -i2 ); - BOOST_CHECK( *--it == elements[ *i_it4 ] ); - } - -} - - -int test_main(int, char *[]) -{ - permutation_test(); - return 0; -} diff --git a/test/pointee.cpp b/test/pointee.cpp deleted file mode 100755 index b39fce1..0000000 --- a/test/pointee.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright David Abrahams 2004. Use, modification and distribution is -// subject to the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include "static_assert_same.hpp" -#include -#include - -template -struct proxy_ptr -{ - typedef T element_type; - struct proxy - { - operator Ref() const; - }; - proxy operator*() const; -}; - -template -struct proxy_ref_ptr : proxy_ptr -{ -}; - -template -struct proxy_value_ptr : proxy_ptr -{ - typedef typename boost::add_const::type element_type; -}; - -struct X { - template X(T const&); - template operator T&() const; -}; - -BOOST_TT_BROKEN_COMPILER_SPEC(X) - -int main() -{ - STATIC_ASSERT_SAME(boost::pointee >::type, int); - STATIC_ASSERT_SAME(boost::pointee >::type, X); - - STATIC_ASSERT_SAME(boost::pointee >::type, int const); - STATIC_ASSERT_SAME(boost::pointee >::type, X const); - - STATIC_ASSERT_SAME(boost::pointee >::type, int const); - STATIC_ASSERT_SAME(boost::pointee >::type, X const); - - STATIC_ASSERT_SAME(boost::pointee >::type, int const); - STATIC_ASSERT_SAME(boost::pointee >::type, X const); - - STATIC_ASSERT_SAME(boost::pointee::type, int); - STATIC_ASSERT_SAME(boost::pointee::type, int const); - - STATIC_ASSERT_SAME(boost::pointee::type, X); - STATIC_ASSERT_SAME(boost::pointee::type, X const); - - STATIC_ASSERT_SAME(boost::pointee >::type, int); - STATIC_ASSERT_SAME(boost::pointee >::type, X); - - STATIC_ASSERT_SAME(boost::pointee >::type, int const); - STATIC_ASSERT_SAME(boost::pointee >::type, X const); - - STATIC_ASSERT_SAME(boost::pointee::iterator >::type, int); - STATIC_ASSERT_SAME(boost::pointee::iterator >::type, X); - - STATIC_ASSERT_SAME(boost::pointee::const_iterator >::type, int const); - STATIC_ASSERT_SAME(boost::pointee::const_iterator >::type, X const); - return 0; -} diff --git a/test/reverse_iterator_test.cpp b/test/reverse_iterator_test.cpp deleted file mode 100644 index eb3d12d..0000000 --- a/test/reverse_iterator_test.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright Thomas Witt 2003. Permission to copy, use, -// modify, sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. - -#include -#include -#include -#include - -using boost::dummyT; - -// Test reverse iterator -int main() -{ - dummyT array[] = { dummyT(0), dummyT(1), dummyT(2), - dummyT(3), dummyT(4), dummyT(5) }; - const int N = sizeof(array)/sizeof(dummyT); - - // Test reverse_iterator_generator - { - dummyT reversed[N]; - std::copy(array, array + N, reversed); - std::reverse(reversed, reversed + N); - - typedef boost::reverse_iterator reverse_iterator; - - reverse_iterator i(reversed + N); - boost::random_access_iterator_test(i, N, array); - - boost::random_access_iterator_test(boost::make_reverse_iterator(reversed + N), N, array); - - typedef boost::reverse_iterator const_reverse_iterator; - - const_reverse_iterator j(reversed + N); - boost::random_access_iterator_test(j, N, array); - - const dummyT* const_reversed = reversed; - - boost::random_access_iterator_test(boost::make_reverse_iterator(const_reversed + N), N, array); - - boost::const_nonconst_iterator_test(i, ++j); - } - - // Test reverse_iterator_generator again, with traits fully deducible on all platforms - { - std::deque reversed_container; - std::reverse_copy(array, array + N, std::back_inserter(reversed_container)); - const std::deque::iterator reversed = reversed_container.begin(); - - - typedef boost::reverse_iterator< - std::deque::iterator> reverse_iterator; - typedef boost::reverse_iterator< - std::deque::const_iterator> const_reverse_iterator; - - // MSVC/STLport gives an INTERNAL COMPILER ERROR when any computation - // (e.g. "reversed + N") is used in the constructor below. - const std::deque::iterator finish = reversed_container.end(); - reverse_iterator i(finish); - - boost::random_access_iterator_test(i, N, array); - boost::random_access_iterator_test(boost::make_reverse_iterator(reversed + N), N, array); - - const_reverse_iterator j = reverse_iterator(finish); - boost::random_access_iterator_test(j, N, array); - - const std::deque::const_iterator const_reversed = reversed; - boost::random_access_iterator_test(boost::make_reverse_iterator(const_reversed + N), N, array); - - // Many compilers' builtin deque iterators don't interoperate well, though - // STLport fixes that problem. -#if defined(__SGI_STL_PORT) \ - || !BOOST_WORKAROUND(__GNUC__, <= 2) \ - && !(BOOST_WORKAROUND(__GNUC__, == 3) && BOOST_WORKAROUND(__GNUC_MINOR__, <= 1)) \ - && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) \ - && !BOOST_WORKAROUND(__LIBCOMO_VERSION__, BOOST_TESTED_AT(29)) \ - && !BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, <= 1) - - boost::const_nonconst_iterator_test(i, ++j); - -#endif - } - return 0; -} diff --git a/test/static_assert_same.hpp b/test/static_assert_same.hpp deleted file mode 100644 index 0b4b04c..0000000 --- a/test/static_assert_same.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright David Abrahams 2003. Permission to copy, use, -// modify, sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. -#ifndef STATIC_ASSERT_SAME_DWA2003530_HPP -# define STATIC_ASSERT_SAME_DWA2003530_HPP - -# include -# include - -#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -template -struct static_assert_same_base; - -template -struct static_assert_same_base -{ - enum { value = 1 }; -}; - -template -struct static_assert_same : static_assert_same_base {}; - -#else -# include -# include -# include - -template -struct static_assert_same - : boost::mpl::if_,boost::mpl::true_,void>::type -{}; -#endif - -#define STATIC_ASSERT_SAME( T1,T2 ) \ - enum { BOOST_JOIN(boost_static_assert_enum_, __LINE__) \ - = static_assert_same::value } - -#endif // STATIC_ASSERT_SAME_DWA2003530_HPP diff --git a/test/transform_iterator_test.cpp b/test/transform_iterator_test.cpp deleted file mode 100644 index 2c9139a..0000000 --- a/test/transform_iterator_test.cpp +++ /dev/null @@ -1,251 +0,0 @@ -// (C) Copyright Jeremy Siek 2002. Permission to copy, use, modify, -// sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. - -// Revision History -// 22 Nov 2002 Thomas Witt -// Added interoperability check. -// 28 Oct 2002 Jeremy Siek -// Updated for new iterator adaptors. -// 08 Mar 2001 Jeremy Siek -// Moved test of transform iterator into its own file. It to -// to be in iterator_adaptor_test.cpp. - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -namespace boost { namespace detail -{ - template<> struct function_object_result - { - typedef int type; - }; -}} -#endif - -struct mult_functor { - // Functors used with transform_iterator must be - // DefaultConstructible, as the transform_iterator must be - // DefaultConstructible to satisfy the requirements for - // TrivialIterator. - mult_functor() { } - mult_functor(int aa) : a(aa) { } - int operator()(int b) const { return a * b; } - int a; -}; - -struct adaptable_mult_functor - : mult_functor -{ - typedef int result_type; - typedef int argument_type; - // Functors used with transform_iterator must be - // DefaultConstructible, as the transform_iterator must be - // DefaultConstructible to satisfy the requirements for - // TrivialIterator. - adaptable_mult_functor() { } - adaptable_mult_functor(int aa) : mult_functor(aa) { } -}; - - -struct const_select_first -{ - typedef int const& result_type; - - int const& operator()(std::pairconst& p) const - { - return p.first; - } -}; - -struct select_first - : const_select_first // derivation to allow conversions -{ - typedef int& result_type; - - int& operator()(std::pair& p) const - { - return p.first; - } -}; - -struct select_second -{ - typedef int& result_type; - - int& operator()(std::pair& p) const - { - return p.second; - } -}; - -struct value_select_first -{ - typedef int result_type; - - int operator()(std::pairconst& p) const - { - return p.first; - } -}; - -int mult_2(int arg) -{ - return arg*2; -} - -int -main() -{ - const int N = 10; - - // Concept checks - { - typedef boost::transform_iterator iter_t; - typedef boost::transform_iterator c_iter_t; - - boost::function_requires< boost_concepts::InteroperableConcept >(); - } - - // Test transform_iterator - { - int x[N], y[N]; - for (int k = 0; k < N; ++k) - x[k] = k; - std::copy(x, x + N, y); - - for (int k2 = 0; k2 < N; ++k2) - x[k2] = x[k2] * 2; - - typedef boost::transform_iterator iter_t; - iter_t i(y, adaptable_mult_functor(2)); - boost::input_iterator_test(i, x[0], x[1]); - boost::input_iterator_test(iter_t(&y[0], adaptable_mult_functor(2)), x[0], x[1]); - - boost::random_access_readable_iterator_test(i, N, x); - } - - // Test transform_iterator non adaptable functor - { - int x[N], y[N]; - for (int k = 0; k < N; ++k) - x[k] = k; - std::copy(x, x + N, y); - - for (int k2 = 0; k2 < N; ++k2) - x[k2] = x[k2] * 2; - - typedef boost::transform_iterator iter_t; - iter_t i(y, mult_functor(2)); - boost::input_iterator_test(i, x[0], x[1]); - boost::input_iterator_test(iter_t(&y[0], mult_functor(2)), x[0], x[1]); - - boost::random_access_readable_iterator_test(i, N, x); - } - - // Test transform_iterator default argument handling - { - { - typedef boost::transform_iterator iter_t; - BOOST_STATIC_ASSERT((boost::is_same::value)); - BOOST_STATIC_ASSERT((boost::is_same::value)); - } - - { - typedef boost::transform_iterator iter_t; - BOOST_STATIC_ASSERT((boost::is_same::value)); - BOOST_STATIC_ASSERT((boost::is_same::value)); - } - - { - typedef boost::transform_iterator iter_t; - BOOST_STATIC_ASSERT((boost::is_same::value)); - BOOST_STATIC_ASSERT((boost::is_same::value)); - } - } - - // Test transform_iterator with function pointers - { - int x[N], y[N]; - for (int k = 0; k < N; ++k) - x[k] = k; - std::copy(x, x + N, y); - - for (int k2 = 0; k2 < N; ++k2) - x[k2] = x[k2] * 2; - - boost::input_iterator_test( - boost::make_transform_iterator(y, mult_2), x[0], x[1]); - - boost::input_iterator_test( - boost::make_transform_iterator(&y[0], mult_2), x[0], x[1]); - - boost::random_access_readable_iterator_test( - boost::make_transform_iterator(y, mult_2), N, x); - - } - - // Test transform_iterator as projection iterator - { - typedef std::pair pair_t; - - int x[N]; - int y[N]; - pair_t values[N]; - - for(int i = 0; i < N; ++i) { - - x[i] = i; - y[i] = N - (i + 1); - - } - - std::copy( - x - , x + N - , boost::make_transform_iterator((pair_t*)values, select_first()) - ); - - std::copy( - y - , y + N - , boost::make_transform_iterator((pair_t*)values, select_second()) - ); - - boost::random_access_readable_iterator_test( - boost::make_transform_iterator((pair_t*)values, value_select_first()) - , N - , x - ); - - boost::random_access_readable_iterator_test( - boost::make_transform_iterator((pair_t*)values, const_select_first()) - , N, x - ); - - boost::constant_lvalue_iterator_test( - boost::make_transform_iterator((pair_t*)values, const_select_first()), x[0]); - - boost::non_const_lvalue_iterator_test( - boost::make_transform_iterator((pair_t*)values, select_first()), x[0], 17); - - boost::const_nonconst_iterator_test( - ++boost::make_transform_iterator((pair_t*)values, select_first()) - , boost::make_transform_iterator((pair_t*)values, const_select_first()) - ); - } - - std::cout << "test successful " << std::endl; - return 0; -} diff --git a/test/unit_tests.cpp b/test/unit_tests.cpp deleted file mode 100644 index c4077eb..0000000 --- a/test/unit_tests.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright David Abrahams 2003. Permission to copy, use, -// modify, sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. -#include -#include - -#include "static_assert_same.hpp" - -#include - -#include - -struct X { int a; }; - -BOOST_TT_BROKEN_COMPILER_SPEC(X) - -struct Xiter : boost::iterator_adaptor -{ - Xiter(); - Xiter(X* p) : boost::iterator_adaptor(p) {} -}; - -void take_xptr(X*) {} -void operator_arrow_test() -{ - // check that the operator-> result is a pointer for lvalue iterators - X x; - take_xptr(Xiter(&x).operator->()); -} - -template -struct static_assert_min_cat - : static_assert_same< - typename boost::detail::minimum_category::type, Min - > -{}; - -void category_test() -{ - using namespace boost; - using namespace boost::detail; - - BOOST_STATIC_ASSERT(( - !boost::is_convertible< - std::input_iterator_tag - , input_output_iterator_tag>::value)); - - BOOST_STATIC_ASSERT(( - !boost::is_convertible< - std::output_iterator_tag - , input_output_iterator_tag>::value)); - - BOOST_STATIC_ASSERT(( - boost::is_convertible< - input_output_iterator_tag - , std::input_iterator_tag>::value)); - - BOOST_STATIC_ASSERT(( - boost::is_convertible< - input_output_iterator_tag - , std::output_iterator_tag>::value)); - -#if 0 // This seems wrong; we're not advertising - // input_output_iterator_tag are we? - BOOST_STATIC_ASSERT(( - boost::is_convertible< - std::forward_iterator_tag - , input_output_iterator_tag>::value)); -#endif - - int test = static_assert_min_cat< - std::input_iterator_tag,input_output_iterator_tag, std::input_iterator_tag - >::value; - - test = static_assert_min_cat< - input_output_iterator_tag,std::input_iterator_tag, std::input_iterator_tag - >::value; - -#if 0 - test = static_assert_min_cat< - input_output_iterator_tag,std::forward_iterator_tag, input_output_iterator_tag - >::value; -#endif - - test = static_assert_min_cat< - std::input_iterator_tag,std::forward_iterator_tag, std::input_iterator_tag - >::value; - - test = static_assert_min_cat< - std::input_iterator_tag,std::random_access_iterator_tag, std::input_iterator_tag - >::value; - -#if 0 // This would be wrong: a random access iterator is not - // neccessarily writable, as is an output iterator. - test = static_assert_min_cat< - std::output_iterator_tag,std::random_access_iterator_tag, std::output_iterator_tag - >::value; -#endif - - (void)test; -} - -int main() -{ - category_test(); - operator_arrow_test(); - return 0; -} - diff --git a/test/zip_iterator_test.cpp b/test/zip_iterator_test.cpp deleted file mode 100755 index 274f7ac..0000000 --- a/test/zip_iterator_test.cpp +++ /dev/null @@ -1,911 +0,0 @@ -// (C) Copyright Dave Abrahams and Thomas Becker 2003. Permission to -// copy, use, modify, sell and distribute this software is granted -// provided this copyright notice appears in all copies. This software -// is provided "as is" without express or implied warranty, and with -// no claim as to its suitability for any purpose. -// - -// File: -// ===== -// zip_iterator_test_main.cpp - -// Author: -// ======= -// Thomas Becker - -// Created: -// ======== -// Jul 15, 2003 - -// Purpose: -// ======== -// Test driver for zip_iterator.hpp - -// Compilers Tested: -// ================= -// Metrowerks Codewarrior Pro 7.2, 8.3 -// gcc 2.95.3 -// gcc 3.2 -// Microsoft VC 6sp5 (test fails due to some compiler bug) -// Microsoft VC 7 (works) -// Microsoft VC 7.1 -// Intel 5 -// Intel 6 -// Intel 7.1 -// Intel 8 -// Borland 5.5.1 (broken due to lack of support from Boost.Tuples) - -///////////////////////////////////////////////////////////////////////////// -// -// Includes -// -///////////////////////////////////////////////////////////////////////////// - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -template -struct pure_traversal - : boost::detail::pure_traversal_tag< - typename boost::iterator_traversal::type - > -{}; - -///////////////////////////////////////////////////////////////////////////// -// -// Das Main Funktion -// -///////////////////////////////////////////////////////////////////////////// - -int main( void ) -{ - - std::cout << "\n" - << "***********************************************\n" - << "* *\n" - << "* Test driver for boost::zip_iterator *\n" - << "* Copyright Thomas Becker 2003 *\n" - << "* *\n" - << "***********************************************\n\n" - << std::flush; - - size_t num_successful_tests = 0; - size_t num_failed_tests = 0; - - ///////////////////////////////////////////////////////////////////////////// - // - // Make sure tuples are supported - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Basic tuple support: " - << std::flush; - - typedef boost::tuples::tuple mytuple; - mytuple t1; - boost::tuples::get<0>(t1) = 42; - boost::tuples::get<1>(t1) = 42.1; - - if( 2 == boost::tuples::length::value && - 42 == boost::tuples::get<0>(t1) && - 42.1 == boost::tuples::get<1>(t1) - ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Make sure iterator adaptor is supported - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Basic iterator adaptor support: " - << std::flush; - - std::set s; - s.insert(42); - s.insert(43); - s.insert(44); - - typedef boost::transform_iterator< - std::binder1st >, - std::set::iterator - > - add_seven_iterator; - - typedef boost::transform_iterator< - std::binder1st >, - std::set::const_iterator - > - const_add_seven_iterator; - - add_seven_iterator set_run(s.begin(), std::bind1st(std::plus(), 7)); - add_seven_iterator set_end(s.end(), std::bind1st(std::plus(), 7)); - - const_add_seven_iterator const_set_run(s.begin(), std::bind1st(std::plus(), 7)); -// set_run = const_set_run; // Error: can't convert from const to non-const - const_set_run = set_run; - - if( 49 == *set_run && - 50 == *++set_run && - 51 == *++set_run && - set_end == ++set_run && - 49 == *const_set_run && - 50 == *++const_set_run && - 51 == *++const_set_run && - set_end == ++const_set_run - ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator construction and dereferencing - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator construction and dereferencing: " - << std::flush; - - std::vector vect1(3); - vect1[0] = 42.; - vect1[1] = 43.; - vect1[2] = 44.; - - std::set intset; - intset.insert(52); - intset.insert(53); - intset.insert(54); - // - - boost::zip_iterator< - boost::tuples::tuple< - std::set::iterator - , std::vector::iterator - > - > - zip_it_mixed( - boost::make_tuple( - intset.begin() - , vect1.begin() - ) - ); - - boost::tuples::tuple val_tuple( - *zip_it_mixed); - - boost::tuples::tuple ref_tuple( - *zip_it_mixed); - - double dblOldVal = boost::tuples::get<1>(ref_tuple); - boost::tuples::get<1>(ref_tuple) -= 41.; - - if( 52 == boost::tuples::get<0>(val_tuple) && - 42. == boost::tuples::get<1>(val_tuple) && - 52 == boost::tuples::get<0>(ref_tuple) && - 1. == boost::tuples::get<1>(ref_tuple) && - 1. == *vect1.begin() - ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - // Undo change to vect1 - boost::tuples::get<1>(ref_tuple) = dblOldVal; - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator with 12 components - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterators with 12 components: " - << std::flush; - - // Declare 12 containers - // - std::list li1; - li1.push_back(1); - std::set se1; - se1.insert(2); - std::vector ve1; - ve1.push_back(3); - // - std::list li2; - li2.push_back(4); - std::set se2; - se2.insert(5); - std::vector ve2; - ve2.push_back(6); - // - std::list li3; - li3.push_back(7); - std::set se3; - se3.insert(8); - std::vector ve3; - ve3.push_back(9); - // - std::list li4; - li4.push_back(10); - std::set se4; - se4.insert(11); - std::vector ve4; - ve4.push_back(12); - - // typedefs for cons lists of iterators. - typedef boost::tuples::cons< - std::set::iterator, - boost::tuples::tuple< - std::vector::iterator, - std::list::iterator, - std::set::iterator, - std::vector::iterator, - std::list::iterator, - std::set::iterator, - std::vector::iterator, - std::list::iterator, - std::set::iterator, - std::vector::const_iterator - >::inherited - > cons_11_its_type; - // - typedef boost::tuples::cons< - std::list::const_iterator, - cons_11_its_type - > cons_12_its_type; - - // typedefs for cons lists for dereferencing the zip iterator - // made from the cons list above. - typedef boost::tuples::cons< - const int&, - boost::tuples::tuple< - int&, - int&, - const int&, - int&, - int&, - const int&, - int&, - int&, - const int&, - const int& - >::inherited - > cons_11_refs_type; - // - typedef boost::tuples::cons< - const int&, - cons_11_refs_type - > cons_12_refs_type; - - // typedef for zip iterator with 12 elements - typedef boost::zip_iterator zip_it_12_type; - - // Declare a 12-element zip iterator. - zip_it_12_type zip_it_12( - cons_12_its_type( - li1.begin(), - cons_11_its_type( - se1.begin(), - boost::make_tuple( - ve1.begin(), - li2.begin(), - se2.begin(), - ve2.begin(), - li3.begin(), - se3.begin(), - ve3.begin(), - li4.begin(), - se4.begin(), - ve4.begin() - ) - ) - ) - ); - - // Dereference, mess with the result a little. - cons_12_refs_type zip_it_12_dereferenced(*zip_it_12); - boost::tuples::get<9>(zip_it_12_dereferenced) = 42; - - // Make a copy and move it a little to force some instantiations. - zip_it_12_type zip_it_12_copy(zip_it_12); - ++zip_it_12_copy; - - if( boost::tuples::get<11>(zip_it_12.get_iterator_tuple()) == ve4.begin() && - boost::tuples::get<11>(zip_it_12_copy.get_iterator_tuple()) == ve4.end() && - 1 == boost::tuples::get<0>(zip_it_12_dereferenced) && - 12 == boost::tuples::get<11>(zip_it_12_dereferenced) && - 42 == *(li4.begin()) - ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator incrementing and dereferencing - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator ++ and *: " - << std::flush; - - std::vector vect2(3); - vect2[0] = 2.2; - vect2[1] = 3.3; - vect2[2] = 4.4; - - boost::zip_iterator< - boost::tuples::tuple< - std::vector::const_iterator, - std::vector::const_iterator - > - > - zip_it_begin( - boost::make_tuple( - vect1.begin(), - vect2.begin() - ) - ); - - boost::zip_iterator< - boost::tuples::tuple< - std::vector::const_iterator, - std::vector::const_iterator - > - > - zip_it_run( - boost::make_tuple( - vect1.begin(), - vect2.begin() - ) - ); - - boost::zip_iterator< - boost::tuples::tuple< - std::vector::const_iterator, - std::vector::const_iterator - > - > - zip_it_end( - boost::make_tuple( - vect1.end(), - vect2.end() - ) - ); - - if( zip_it_run == zip_it_begin && - 42. == boost::tuples::get<0>(*zip_it_run) && - 2.2 == boost::tuples::get<1>(*zip_it_run) && - 43. == boost::tuples::get<0>(*(++zip_it_run)) && - 3.3 == boost::tuples::get<1>(*zip_it_run) && - 44. == boost::tuples::get<0>(*(++zip_it_run)) && - 4.4 == boost::tuples::get<1>(*zip_it_run) && - zip_it_end == ++zip_it_run - ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator decrementing and dereferencing - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator -- and *: " - << std::flush; - - if( zip_it_run == zip_it_end && - zip_it_end == zip_it_run-- && - 44. == boost::tuples::get<0>(*zip_it_run) && - 4.4 == boost::tuples::get<1>(*zip_it_run) && - 43. == boost::tuples::get<0>(*(--zip_it_run)) && - 3.3 == boost::tuples::get<1>(*zip_it_run) && - 42. == boost::tuples::get<0>(*(--zip_it_run)) && - 2.2 == boost::tuples::get<1>(*zip_it_run) && - zip_it_begin == zip_it_run - ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator copy construction and equality - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator copy construction and equality: " - << std::flush; - - boost::zip_iterator< - boost::tuples::tuple< - std::vector::const_iterator, - std::vector::const_iterator - > - > zip_it_run_copy(zip_it_run); - - if(zip_it_run == zip_it_run && zip_it_run == zip_it_run_copy) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator inequality - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator inequality: " - << std::flush; - - if(!(zip_it_run != zip_it_run_copy) && zip_it_run != ++zip_it_run_copy) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator less than - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator less than: " - << std::flush; - - // Note: zip_it_run_copy == zip_it_run + 1 - // - if( zip_it_run < zip_it_run_copy && - !( zip_it_run < --zip_it_run_copy) && - zip_it_run == zip_it_run_copy - ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator less than or equal - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "zip iterator less than or equal: " - << std::flush; - - // Note: zip_it_run_copy == zip_it_run - // - ++zip_it_run; - zip_it_run_copy += 2; - - if( zip_it_run <= zip_it_run_copy && - zip_it_run <= --zip_it_run_copy && - !( zip_it_run <= --zip_it_run_copy) && - zip_it_run <= zip_it_run - ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator greater than - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator greater than: " - << std::flush; - - // Note: zip_it_run_copy == zip_it_run - 1 - // - if( zip_it_run > zip_it_run_copy && - !( zip_it_run > ++zip_it_run_copy) && - zip_it_run == zip_it_run_copy - ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator greater than or equal - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator greater than or equal: " - << std::flush; - - ++zip_it_run; - - // Note: zip_it_run == zip_it_run_copy + 1 - // - if( zip_it_run >= zip_it_run_copy && - --zip_it_run >= zip_it_run_copy && - ! (zip_it_run >= ++zip_it_run_copy) - ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator + int - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator + int: " - << std::flush; - - // Note: zip_it_run == zip_it_run_copy - 1 - // - zip_it_run = zip_it_run + 2; - ++zip_it_run_copy; - - if( zip_it_run == zip_it_run_copy && zip_it_run == zip_it_begin + 3 ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator - int - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator - int: " - << std::flush; - - // Note: zip_it_run == zip_it_run_copy, and both are at end position - // - zip_it_run = zip_it_run - 2; - --zip_it_run_copy; - --zip_it_run_copy; - - if( zip_it_run == zip_it_run_copy && (zip_it_run - 1) == zip_it_begin ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator += - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator +=: " - << std::flush; - - // Note: zip_it_run == zip_it_run_copy, and both are at begin + 1 - // - zip_it_run += 2; - if( zip_it_run == zip_it_begin + 3 ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator -= - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator -=: " - << std::flush; - - // Note: zip_it_run is at end position, zip_it_run_copy is at - // begin plus one. - // - zip_it_run -= 2; - if( zip_it_run == zip_it_run_copy ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator getting member iterators - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator member iterators: " - << std::flush; - - // Note: zip_it_run and zip_it_run_copy are both at - // begin plus one. - // - if( boost::tuples::get<0>(zip_it_run.get_iterator_tuple()) == vect1.begin() + 1 && - boost::tuples::get<1>(zip_it_run.get_iterator_tuple()) == vect2.begin() + 1 - ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Making zip iterators - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Making zip iterators: " - << std::flush; - - std::vector > - vect_of_tuples(3); - - std::copy( - boost::make_zip_iterator( - boost::make_tuple( - vect1.begin(), - vect2.begin() - ) - ), - boost::make_zip_iterator( - boost::make_tuple( - vect1.end(), - vect2.end() - ) - ), - vect_of_tuples.begin() - ); - - if( 42. == boost::tuples::get<0>(*vect_of_tuples.begin()) && - 2.2 == boost::tuples::get<1>(*vect_of_tuples.begin()) && - 43. == boost::tuples::get<0>(*(vect_of_tuples.begin() + 1)) && - 3.3 == boost::tuples::get<1>(*(vect_of_tuples.begin() + 1)) && - 44. == boost::tuples::get<0>(*(vect_of_tuples.begin() + 2)) && - 4.4 == boost::tuples::get<1>(*(vect_of_tuples.begin() + 2)) - ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator non-const --> const conversion - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator non-const to const conversion: " - << std::flush; - - boost::zip_iterator< - boost::tuples::tuple< - std::set::const_iterator, - std::vector::const_iterator - > - > - zip_it_const( - boost::make_tuple( - intset.begin(), - vect2.begin() - ) - ); - // - boost::zip_iterator< - boost::tuples::tuple< - std::set::iterator, - std::vector::const_iterator - > - > - zip_it_half_const( - boost::make_tuple( - intset.begin(), - vect2.begin() - ) - ); - // - boost::zip_iterator< - boost::tuples::tuple< - std::set::iterator, - std::vector::iterator - > - > - zip_it_non_const( - boost::make_tuple( - intset.begin(), - vect2.begin() - ) - ); - - zip_it_half_const = ++zip_it_non_const; - zip_it_const = zip_it_half_const; - ++zip_it_const; -// zip_it_non_const = ++zip_it_const; // Error: can't convert from const to non-const - - if( 54 == boost::tuples::get<0>(*zip_it_const) && - 4.4 == boost::tuples::get<1>(*zip_it_const) && - 53 == boost::tuples::get<0>(*zip_it_half_const) && - 3.3 == boost::tuples::get<1>(*zip_it_half_const) - ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator categories - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator categories: " - << std::flush; - - // The big iterator of the previous test has vector, list, and set iterators. - // Therefore, it must be bidirectional, but not random access. - bool bBigItIsBidirectionalIterator = boost::is_convertible< - boost::iterator_traversal::type - , boost::bidirectional_traversal_tag - >::value; - - bool bBigItIsRandomAccessIterator = boost::is_convertible< - boost::iterator_traversal::type - , boost::random_access_traversal_tag - >::value; - - // A combining iterator with all vector iterators must have random access - // traversal. - // - typedef boost::zip_iterator< - boost::tuples::tuple< - std::vector::const_iterator, - std::vector::const_iterator - > - > all_vects_type; - - bool bAllVectsIsRandomAccessIterator = boost::is_convertible< - boost::iterator_traversal::type - , boost::random_access_traversal_tag - >::value; - - // The big test. - if( bBigItIsBidirectionalIterator && - ! bBigItIsRandomAccessIterator && - bAllVectsIsRandomAccessIterator - ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - // Done - // - std::cout << "\nTest Result:" - << "\n============" - << "\nNumber of successful tests: " << static_cast(num_successful_tests) - << "\nNumber of failed tests: " << static_cast(num_failed_tests) - << std::endl; - - return num_failed_tests; -} -