forked from boostorg/iterator
Merge branch 'develop'
This commit is contained in:
@ -132,7 +132,7 @@ above are defined as follows:
|
|||||||
|
|
||||||
iterator_adaptor();
|
iterator_adaptor();
|
||||||
|
|
||||||
[*Requires:] The `Base` type must be Default Constructible.\n
|
[*Requires:] The `Base` type must be Default Constructible.[br]
|
||||||
[*Returns:] An instance of `iterator_adaptor` with
|
[*Returns:] An instance of `iterator_adaptor` with
|
||||||
`m_iterator` default constructed.
|
`m_iterator` default constructed.
|
||||||
|
|
||||||
@ -206,7 +206,7 @@ we're going to pick up right where it left off.
|
|||||||
.. |fac_tut| replace:: `iterator_facade` tutorial
|
.. |fac_tut| replace:: `iterator_facade` tutorial
|
||||||
.. _fac_tut: iterator_facade.html#tutorial-example
|
.. _fac_tut: iterator_facade.html#tutorial-example
|
||||||
|
|
||||||
[blurb [*`node_base*` really *is* an iterator]\n\n
|
[blurb [*`node_base*` really *is* an iterator][br][br]
|
||||||
It's not really a very interesting iterator, since `node_base`
|
It's not really a very interesting iterator, since `node_base`
|
||||||
is an abstract class: a pointer to a `node_base` just points
|
is an abstract class: a pointer to a `node_base` just points
|
||||||
at some base subobject of an instance of some other class, and
|
at some base subobject of an instance of some other class, and
|
||||||
|
@ -156,7 +156,7 @@ semantics.
|
|||||||
[
|
[
|
||||||
[`++r`]
|
[`++r`]
|
||||||
[`X&`]
|
[`X&`]
|
||||||
[pre:\n`r` is dereferenceable;\npost:\n`r` is dereferenceable or\n`r` is past-the-end]
|
[pre:[br]`r` is dereferenceable;[br]post:[br]`r` is dereferenceable or[br]`r` is past-the-end]
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
[`a == b`]
|
[`a == b`]
|
||||||
@ -227,7 +227,7 @@ the stated semantics.
|
|||||||
[
|
[
|
||||||
[`--r`]
|
[`--r`]
|
||||||
[`X&`]
|
[`X&`]
|
||||||
[pre: there exists `s` such that `r == ++s`.\n post: `s` is dereferenceable. `--(++r) == r`. `--r == --s` implies `r == s`. `&r == &--r`.]
|
[pre: there exists `s` such that `r == ++s`.[br] post: `s` is dereferenceable. `--(++r) == r`. `--r == --s` implies `r == s`. `&r == &--r`.]
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
[`r--`]
|
[`r--`]
|
||||||
|
@ -152,7 +152,7 @@ operations.
|
|||||||
|
|
||||||
counting_iterator();
|
counting_iterator();
|
||||||
|
|
||||||
[*Requires: ] `Incrementable` is Default Constructible.\n
|
[*Requires: ] `Incrementable` is Default Constructible.[br]
|
||||||
[*Effects: ] Default construct the member `m_inc`.
|
[*Effects: ] Default construct the member `m_inc`.
|
||||||
|
|
||||||
|
|
||||||
@ -174,13 +174,13 @@ operations.
|
|||||||
|
|
||||||
counting_iterator& operator++();
|
counting_iterator& operator++();
|
||||||
|
|
||||||
[*Effects: ] `++m_inc`\n
|
[*Effects: ] `++m_inc`[br]
|
||||||
[*Returns: ] `*this`
|
[*Returns: ] `*this`
|
||||||
|
|
||||||
|
|
||||||
counting_iterator& operator--();
|
counting_iterator& operator--();
|
||||||
|
|
||||||
[*Effects: ] `--m_inc`\n
|
[*Effects: ] `--m_inc`[br]
|
||||||
[*Returns: ] `*this`
|
[*Returns: ] `*this`
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,6 +68,7 @@ requirements.
|
|||||||
[
|
[
|
||||||
[`i.dereference()`]
|
[`i.dereference()`]
|
||||||
[Access the value referred to]
|
[Access the value referred to]
|
||||||
|
]
|
||||||
[
|
[
|
||||||
[`i.equal(j)`]
|
[`i.equal(j)`]
|
||||||
[Compare for equality with `j`]
|
[Compare for equality with `j`]
|
||||||
@ -83,6 +84,7 @@ requirements.
|
|||||||
[
|
[
|
||||||
[`i.advance(n)`]
|
[`i.advance(n)`]
|
||||||
[Advance by `n` positions]
|
[Advance by `n` positions]
|
||||||
|
]
|
||||||
[
|
[
|
||||||
[`i.distance_to(j)`]
|
[`i.distance_to(j)`]
|
||||||
[Measure the distance to `j`]
|
[Measure the distance to `j`]
|
||||||
@ -487,7 +489,8 @@ w.m)` for some temporary object `w` of type `value_type`.
|
|||||||
iterator_facade<Dr2,V2,TC2,R2,D2> const& rhs);
|
iterator_facade<Dr2,V2,TC2,R2,D2> const& rhs);
|
||||||
|
|
||||||
[*Returns:]
|
[*Returns:]
|
||||||
|
|
||||||
|
[pre
|
||||||
if `is_convertible<Dr2,Dr1>::value`
|
if `is_convertible<Dr2,Dr1>::value`
|
||||||
|
|
||||||
then
|
then
|
||||||
@ -495,6 +498,7 @@ w.m)` for some temporary object `w` of type `value_type`.
|
|||||||
|
|
||||||
Otherwise,
|
Otherwise,
|
||||||
`((Dr2 const&)rhs).equal((Dr1 const&)lhs)`.
|
`((Dr2 const&)rhs).equal((Dr1 const&)lhs)`.
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
template <class Dr1, class V1, class TC1, class R1, class D1,
|
template <class Dr1, class V1, class TC1, class R1, class D1,
|
||||||
@ -505,6 +509,7 @@ w.m)` for some temporary object `w` of type `value_type`.
|
|||||||
|
|
||||||
[*Returns:]
|
[*Returns:]
|
||||||
|
|
||||||
|
[pre
|
||||||
if `is_convertible<Dr2,Dr1>::value`
|
if `is_convertible<Dr2,Dr1>::value`
|
||||||
|
|
||||||
then
|
then
|
||||||
@ -512,6 +517,7 @@ w.m)` for some temporary object `w` of type `value_type`.
|
|||||||
|
|
||||||
Otherwise,
|
Otherwise,
|
||||||
`!((Dr2 const&)rhs).equal((Dr1 const&)lhs)`.
|
`!((Dr2 const&)rhs).equal((Dr1 const&)lhs)`.
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
template <class Dr1, class V1, class TC1, class R1, class D1,
|
template <class Dr1, class V1, class TC1, class R1, class D1,
|
||||||
@ -522,6 +528,7 @@ w.m)` for some temporary object `w` of type `value_type`.
|
|||||||
|
|
||||||
[*Returns:]
|
[*Returns:]
|
||||||
|
|
||||||
|
[pre
|
||||||
if `is_convertible<Dr2,Dr1>::value`
|
if `is_convertible<Dr2,Dr1>::value`
|
||||||
|
|
||||||
then
|
then
|
||||||
@ -529,6 +536,7 @@ w.m)` for some temporary object `w` of type `value_type`.
|
|||||||
|
|
||||||
Otherwise,
|
Otherwise,
|
||||||
`((Dr2 const&)rhs).distance_to((Dr1 const&)lhs) > 0`.
|
`((Dr2 const&)rhs).distance_to((Dr1 const&)lhs) > 0`.
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
template <class Dr1, class V1, class TC1, class R1, class D1,
|
template <class Dr1, class V1, class TC1, class R1, class D1,
|
||||||
@ -539,6 +547,7 @@ w.m)` for some temporary object `w` of type `value_type`.
|
|||||||
|
|
||||||
[*Returns:]
|
[*Returns:]
|
||||||
|
|
||||||
|
[pre
|
||||||
if `is_convertible<Dr2,Dr1>::value`
|
if `is_convertible<Dr2,Dr1>::value`
|
||||||
|
|
||||||
then
|
then
|
||||||
@ -546,6 +555,7 @@ w.m)` for some temporary object `w` of type `value_type`.
|
|||||||
|
|
||||||
Otherwise,
|
Otherwise,
|
||||||
`((Dr2 const&)rhs).distance_to((Dr1 const&)lhs) >= 0`.
|
`((Dr2 const&)rhs).distance_to((Dr1 const&)lhs) >= 0`.
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
template <class Dr1, class V1, class TC1, class R1, class D1,
|
template <class Dr1, class V1, class TC1, class R1, class D1,
|
||||||
@ -556,6 +566,7 @@ w.m)` for some temporary object `w` of type `value_type`.
|
|||||||
|
|
||||||
[*Returns:]
|
[*Returns:]
|
||||||
|
|
||||||
|
[pre
|
||||||
if `is_convertible<Dr2,Dr1>::value`
|
if `is_convertible<Dr2,Dr1>::value`
|
||||||
|
|
||||||
then
|
then
|
||||||
@ -563,6 +574,7 @@ w.m)` for some temporary object `w` of type `value_type`.
|
|||||||
|
|
||||||
Otherwise,
|
Otherwise,
|
||||||
`((Dr2 const&)rhs).distance_to((Dr1 const&)lhs) < 0`.
|
`((Dr2 const&)rhs).distance_to((Dr1 const&)lhs) < 0`.
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
template <class Dr1, class V1, class TC1, class R1, class D1,
|
template <class Dr1, class V1, class TC1, class R1, class D1,
|
||||||
@ -573,6 +585,7 @@ w.m)` for some temporary object `w` of type `value_type`.
|
|||||||
|
|
||||||
[*Returns:]
|
[*Returns:]
|
||||||
|
|
||||||
|
[pre
|
||||||
if `is_convertible<Dr2,Dr1>::value`
|
if `is_convertible<Dr2,Dr1>::value`
|
||||||
|
|
||||||
then
|
then
|
||||||
@ -580,6 +593,7 @@ w.m)` for some temporary object `w` of type `value_type`.
|
|||||||
|
|
||||||
Otherwise,
|
Otherwise,
|
||||||
`((Dr2 const&)rhs).distance_to((Dr1 const&)lhs) <= 0`.
|
`((Dr2 const&)rhs).distance_to((Dr1 const&)lhs) <= 0`.
|
||||||
|
]
|
||||||
|
|
||||||
.. _minus:
|
.. _minus:
|
||||||
|
|
||||||
@ -592,6 +606,7 @@ w.m)` for some temporary object `w` of type `value_type`.
|
|||||||
|
|
||||||
[*Return Type:]
|
[*Return Type:]
|
||||||
|
|
||||||
|
[pre
|
||||||
if `is_convertible<Dr2,Dr1>::value`
|
if `is_convertible<Dr2,Dr1>::value`
|
||||||
|
|
||||||
then
|
then
|
||||||
@ -600,9 +615,11 @@ w.m)` for some temporary object `w` of type `value_type`.
|
|||||||
|
|
||||||
Otherwise
|
Otherwise
|
||||||
`difference` shall be `iterator_traits<Dr2>::difference_type`
|
`difference` shall be `iterator_traits<Dr2>::difference_type`
|
||||||
|
]
|
||||||
|
|
||||||
[*Returns:]
|
[*Returns:]
|
||||||
|
|
||||||
|
[pre
|
||||||
if `is_convertible<Dr2,Dr1>::value`
|
if `is_convertible<Dr2,Dr1>::value`
|
||||||
|
|
||||||
then
|
then
|
||||||
@ -610,6 +627,7 @@ w.m)` for some temporary object `w` of type `value_type`.
|
|||||||
|
|
||||||
Otherwise,
|
Otherwise,
|
||||||
`((Dr2 const&)rhs).distance_to((Dr1 const&)lhs)`.
|
`((Dr2 const&)rhs).distance_to((Dr1 const&)lhs)`.
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
@ -261,17 +261,17 @@ __ ../example/node_iterator1.cpp
|
|||||||
|
|
||||||
[h2 A constant `node_iterator`]
|
[h2 A constant `node_iterator`]
|
||||||
|
|
||||||
[blurb *Constant and Mutable iterators*\n\n
|
[blurb *Constant and Mutable iterators*[br][br]
|
||||||
The term **mutable iterator** means an iterator through which
|
The term **mutable iterator** means an iterator through which
|
||||||
the object it references (its "referent") can be modified. A
|
the object it references (its "referent") can be modified. A
|
||||||
**constant iterator** is one which doesn't allow modification of
|
**constant iterator** is one which doesn't allow modification of
|
||||||
its referent.\n\n
|
its referent.[br][br]
|
||||||
The words *constant* and *mutable* don't refer to the ability to
|
The words *constant* and *mutable* don't refer to the ability to
|
||||||
modify the iterator itself. For example, an `int const*` is a
|
modify the iterator itself. For example, an `int const*` is a
|
||||||
non-\ `const` *constant iterator*, which can be incremented
|
non-\ `const` *constant iterator*, which can be incremented
|
||||||
but doesn't allow modification of its referent, and `int*
|
but doesn't allow modification of its referent, and `int*
|
||||||
const` is a `const` *mutable iterator*, which cannot be
|
const` is a `const` *mutable iterator*, which cannot be
|
||||||
modified but which allows modification of its referent.\n\n
|
modified but which allows modification of its referent.[br][br]
|
||||||
Confusing? We agree, but those are the standard terms. It
|
Confusing? We agree, but those are the standard terms. It
|
||||||
probably doesn't help much that a container's constant iterator
|
probably doesn't help much that a container's constant iterator
|
||||||
is called `const_iterator`.
|
is called `const_iterator`.
|
||||||
@ -312,7 +312,7 @@ changes:
|
|||||||
node_base **const**\ * m_node;
|
node_base **const**\ * m_node;
|
||||||
};
|
};
|
||||||
|
|
||||||
[blurb `const` and an iterator's `value_type`\n\n
|
[blurb `const` and an iterator's `value_type`[br][br]
|
||||||
The C++ standard requires an iterator's `value_type` *not* be
|
The C++ standard requires an iterator's `value_type` *not* be
|
||||||
`const`\ -qualified, so `iterator_facade` strips the
|
`const`\ -qualified, so `iterator_facade` strips the
|
||||||
`const` from its `Value` parameter in order to produce the
|
`const` from its `Value` parameter in order to produce the
|
||||||
|
@ -178,7 +178,7 @@ operations.
|
|||||||
|
|
||||||
filter_iterator();
|
filter_iterator();
|
||||||
|
|
||||||
[*Requires: ]`Predicate` and `Iterator` must be Default Constructible.\n
|
[*Requires: ]`Predicate` and `Iterator` must be Default Constructible.[br]
|
||||||
[*Effects: ] Constructs a `filter_iterator` whose`m_pred`, `m_iter`, and `m_end`
|
[*Effects: ] Constructs a `filter_iterator` whose`m_pred`, `m_iter`, and `m_end`
|
||||||
members are a default constructed.
|
members are a default constructed.
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ operations.
|
|||||||
filter_iterator(Iterator x, Iterator end = Iterator());
|
filter_iterator(Iterator x, Iterator end = Iterator());
|
||||||
|
|
||||||
[*Requires: ] `Predicate` must be Default Constructible and
|
[*Requires: ] `Predicate` must be Default Constructible and
|
||||||
`Predicate` is a class type (not a function pointer).\n
|
`Predicate` is a class type (not a function pointer).[br]
|
||||||
[*Effects: ] Constructs a `filter_iterator` where `m_iter` is either
|
[*Effects: ] Constructs a `filter_iterator` where `m_iter` is either
|
||||||
the first position in the range `[x,end)` such that `m_pred(*m_iter) == true`
|
the first position in the range `[x,end)` such that `m_pred(*m_iter) == true`
|
||||||
or else`m_iter == end`. The member `m_pred` is default constructed.
|
or else`m_iter == end`. The member `m_pred` is default constructed.
|
||||||
@ -205,9 +205,9 @@ operations.
|
|||||||
filter_iterator(
|
filter_iterator(
|
||||||
filter_iterator<Predicate, OtherIterator> const& t
|
filter_iterator<Predicate, OtherIterator> const& t
|
||||||
, typename enable_if_convertible<OtherIterator, Iterator>::type* = 0 // exposition
|
, typename enable_if_convertible<OtherIterator, Iterator>::type* = 0 // exposition
|
||||||
);`
|
);
|
||||||
|
|
||||||
[*Requires: ] `OtherIterator` is implicitly convertible to `Iterator`.\n
|
[*Requires: ] `OtherIterator` is implicitly convertible to `Iterator`.[br]
|
||||||
[*Effects: ] Constructs a filter iterator whose members are copied from `t`.
|
[*Effects: ] Constructs a filter iterator whose members are copied from `t`.
|
||||||
|
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ operations.
|
|||||||
|
|
||||||
[*Effects: ] Increments `m_iter` and then continues to
|
[*Effects: ] Increments `m_iter` and then continues to
|
||||||
increment `m_iter` until either `m_iter == m_end`
|
increment `m_iter` until either `m_iter == m_end`
|
||||||
or `m_pred(*m_iter) == true`.\n
|
or `m_pred(*m_iter) == true`.[br]
|
||||||
[*Returns: ] `*this`
|
[*Returns: ] `*this`
|
||||||
|
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ following operations:
|
|||||||
|
|
||||||
indirect_iterator();
|
indirect_iterator();
|
||||||
|
|
||||||
[*Requires: ] `Iterator` must be Default Constructible.\n
|
[*Requires: ] `Iterator` must be Default Constructible.[br]
|
||||||
[*Effects: ] Constructs an instance of `indirect_iterator` with
|
[*Effects: ] Constructs an instance of `indirect_iterator` with
|
||||||
a default-constructed `m_iterator`.
|
a default-constructed `m_iterator`.
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ following operations:
|
|||||||
, typename enable_if_convertible<Iterator2, Iterator>::type* = 0 // exposition
|
, typename enable_if_convertible<Iterator2, Iterator>::type* = 0 // exposition
|
||||||
);
|
);
|
||||||
|
|
||||||
[*Requires: ] `Iterator2` is implicitly convertible to `Iterator`.\n
|
[*Requires: ] `Iterator2` is implicitly convertible to `Iterator`.[br]
|
||||||
[*Effects: ] Constructs an instance of `indirect_iterator` whose
|
[*Effects: ] Constructs an instance of `indirect_iterator` whose
|
||||||
`m_iterator` subobject is constructed from `y.base()`.
|
`m_iterator` subobject is constructed from `y.base()`.
|
||||||
|
|
||||||
@ -242,13 +242,13 @@ following operations:
|
|||||||
|
|
||||||
indirect_iterator& operator++();
|
indirect_iterator& operator++();
|
||||||
|
|
||||||
[*Effects: ] `++m_iterator`\n
|
[*Effects: ] `++m_iterator`[br]
|
||||||
[*Returns: ] `*this`
|
[*Returns: ] `*this`
|
||||||
|
|
||||||
|
|
||||||
indirect_iterator& operator--();
|
indirect_iterator& operator--();
|
||||||
|
|
||||||
[*Effects: ] `--m_iterator`\n
|
[*Effects: ] `--m_iterator`[br]
|
||||||
[*Returns: ] `*this`
|
[*Returns: ] `*this`
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
[library Boost.Iterator
|
[library Boost.Iterator
|
||||||
[/ version 1.0.1]
|
[/ version 1.0.1]
|
||||||
|
[quickbook 1.6]
|
||||||
[authors [Abrahams, David], [Siek, Jeremy], [Witt, Thomas]]
|
[authors [Abrahams, David], [Siek, Jeremy], [Witt, Thomas]]
|
||||||
[copyright 2003 2005 David Abrahams Jeremy Siek Thomas Witt]
|
[copyright 2003 2005 David Abrahams Jeremy Siek Thomas Witt]
|
||||||
[category iterator]
|
[category iterator]
|
||||||
@ -99,7 +100,7 @@ adaptors`_ mentioned below have been proposed for standardization
|
|||||||
|
|
||||||
The iterator library supplies a useful suite of standard-conforming
|
The iterator library supplies a useful suite of standard-conforming
|
||||||
iterator templates based on the Boost [link
|
iterator templates based on the Boost [link
|
||||||
intro.iterator_facade_and_adaptor iterator facade and adaptor]
|
iterator.intro.iterator_facade_and_adaptor iterator facade and adaptor]
|
||||||
templates.
|
templates.
|
||||||
|
|
||||||
[def _counting_ [@./counting_iterator.html `counting_iterator`]]
|
[def _counting_ [@./counting_iterator.html `counting_iterator`]]
|
||||||
|
@ -189,7 +189,7 @@ following operations.
|
|||||||
|
|
||||||
permutation_iterator& operator++();
|
permutation_iterator& operator++();
|
||||||
|
|
||||||
[*Effects: ] `++m_order`\n
|
[*Effects: ] `++m_order`[br]
|
||||||
[*Returns: ] `*this`
|
[*Returns: ] `*this`
|
||||||
|
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ operations.
|
|||||||
|
|
||||||
reverse_iterator();
|
reverse_iterator();
|
||||||
|
|
||||||
[*Requires: ] `Iterator` must be Default Constructible.\n
|
[*Requires: ] `Iterator` must be Default Constructible.[br]
|
||||||
[*Effects: ] Constructs an instance of `reverse_iterator` with `m_iterator`
|
[*Effects: ] Constructs an instance of `reverse_iterator` with `m_iterator`
|
||||||
default constructed.
|
default constructed.
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ operations.
|
|||||||
, typename enable_if_convertible<OtherIterator, Iterator>::type* = 0 // exposition
|
, typename enable_if_convertible<OtherIterator, Iterator>::type* = 0 // exposition
|
||||||
);
|
);
|
||||||
|
|
||||||
[*Requires: ] `OtherIterator` is implicitly convertible to `Iterator`.\n
|
[*Requires: ] `OtherIterator` is implicitly convertible to `Iterator`.[br]
|
||||||
[*Effects: ] Constructs instance of `reverse_iterator` whose
|
[*Effects: ] Constructs instance of `reverse_iterator` whose
|
||||||
`m_iterator` subobject is constructed from `y.base()`.
|
`m_iterator` subobject is constructed from `y.base()`.
|
||||||
|
|
||||||
@ -149,12 +149,12 @@ operations.
|
|||||||
|
|
||||||
reverse_iterator& operator++();
|
reverse_iterator& operator++();
|
||||||
|
|
||||||
[*Effects: ] `--m_iterator`\n
|
[*Effects: ] `--m_iterator`[br]
|
||||||
[*Returns: ] `*this`
|
[*Returns: ] `*this`
|
||||||
|
|
||||||
reverse_iterator& operator--();
|
reverse_iterator& operator--();
|
||||||
|
|
||||||
[*Effects: ] `++m_iterator`\n
|
[*Effects: ] `++m_iterator`[br]
|
||||||
[*Returns: ] `*this`
|
[*Returns: ] `*this`
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
@ -85,7 +85,7 @@ The source code for this example can be found
|
|||||||
|
|
||||||
|
|
||||||
If `Reference` is `use_default` then the `reference` member of
|
If `Reference` is `use_default` then the `reference` member of
|
||||||
`transform_iterator` is\n
|
`transform_iterator` is[br]
|
||||||
`result_of<UnaryFunction(iterator_traits<Iterator>::reference)>::type`.
|
`result_of<UnaryFunction(iterator_traits<Iterator>::reference)>::type`.
|
||||||
Otherwise, `reference` is `Reference`.
|
Otherwise, `reference` is `Reference`.
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ interoperable with `Y`.
|
|||||||
|
|
||||||
[h3 Operations]
|
[h3 Operations]
|
||||||
|
|
||||||
In addition to the operations required by the [link transform.concepts concepts] modeled by
|
In addition to the operations required by the [link iterator.specialized.transform.concepts concepts] modeled by
|
||||||
`transform_iterator`, `transform_iterator` provides the following
|
`transform_iterator`, `transform_iterator` provides the following
|
||||||
operations:
|
operations:
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ operations:
|
|||||||
|
|
||||||
[*Returns: ] An instance of `transform_iterator` with `m_f`
|
[*Returns: ] An instance of `transform_iterator` with `m_f`
|
||||||
initialized to `t.functor()` and `m_iterator` initialized to
|
initialized to `t.functor()` and `m_iterator` initialized to
|
||||||
`t.base()`.\n
|
`t.base()`.[br]
|
||||||
[*Requires: ] `OtherIterator` is implicitly convertible to `Iterator`.
|
[*Requires: ] `OtherIterator` is implicitly convertible to `Iterator`.
|
||||||
|
|
||||||
|
|
||||||
@ -204,13 +204,13 @@ operations:
|
|||||||
|
|
||||||
transform_iterator& operator++();
|
transform_iterator& operator++();
|
||||||
|
|
||||||
[*Effects: ] `++m_iterator`\n
|
[*Effects: ] `++m_iterator`[br]
|
||||||
[*Returns: ] `*this`
|
[*Returns: ] `*this`
|
||||||
|
|
||||||
|
|
||||||
transform_iterator& operator--();
|
transform_iterator& operator--();
|
||||||
|
|
||||||
[*Effects: ] `--m_iterator`\n
|
[*Effects: ] `--m_iterator`[br]
|
||||||
[*Returns: ] `*this`
|
[*Returns: ] `*this`
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
@ -49,7 +49,7 @@ proxy references or return the pointee by value. When that
|
|||||||
information is needed, call on `indirect_reference`.
|
information is needed, call on `indirect_reference`.
|
||||||
|
|
||||||
Both of these templates are essential to the correct functioning of
|
Both of these templates are essential to the correct functioning of
|
||||||
[link boost_iterator.indirect `indirect_iterator`].
|
[link iterator.specialized.indirect `indirect_iterator`].
|
||||||
|
|
||||||
[h2 `minimum_category`]
|
[h2 `minimum_category`]
|
||||||
|
|
||||||
@ -103,9 +103,9 @@ or not), these additional tags are not considered.
|
|||||||
|
|
||||||
if ( ++x is ill-formed )
|
if ( ++x is ill-formed )
|
||||||
{
|
{
|
||||||
return `Dereferenceable::element_type`
|
return Dereferenceable::element_type
|
||||||
}
|
}
|
||||||
else if (`*x` is a mutable reference to
|
else if (*x is a mutable reference to
|
||||||
std::iterator_traits<Dereferenceable>::value_type)
|
std::iterator_traits<Dereferenceable>::value_type)
|
||||||
{
|
{
|
||||||
return iterator_traits<Dereferenceable>::value_type
|
return iterator_traits<Dereferenceable>::value_type
|
||||||
@ -135,7 +135,7 @@ or not), these additional tags are not considered.
|
|||||||
`x` is an object of type `Dereferenceable`:
|
`x` is an object of type `Dereferenceable`:
|
||||||
|
|
||||||
if ( ++x is ill-formed )
|
if ( ++x is ill-formed )
|
||||||
return `pointee<Dereferenceable>::type&`
|
return pointee<Dereferenceable>::type&
|
||||||
else
|
else
|
||||||
std::iterator_traits<Dereferenceable>::reference
|
std::iterator_traits<Dereferenceable>::reference
|
||||||
|
|
||||||
|
@ -8,6 +8,16 @@ the zip iterator moves all the iterators in parallel.
|
|||||||
Dereferencing the zip iterator returns a tuple that contains
|
Dereferencing the zip iterator returns a tuple that contains
|
||||||
the results of dereferencing the individual iterators.
|
the results of dereferencing the individual iterators.
|
||||||
|
|
||||||
|
The tuple of iterators is now implemented in terms of a Boost fusion sequence.
|
||||||
|
Because of this the 'tuple' may be any Boost fusion sequence and, for backwards
|
||||||
|
compatibility through a Boost fusion sequence adapter, a Boost tuple. Because the
|
||||||
|
'tuple' may be any boost::fusion sequence the 'tuple' may also be any type for which a
|
||||||
|
Boost fusion adapter exists. This includes, among others, a std::tuple and a std::pair.
|
||||||
|
Just remember to include the appropriate Boost fusion adapter header files for these
|
||||||
|
other Boost fusion adapters. The zip_iterator header file already includes the
|
||||||
|
Boost fusion adapter header file for Boost tuple, so you need not include it yourself
|
||||||
|
to use a Boost tuple as your 'tuple'.
|
||||||
|
|
||||||
[section:zip_example Example]
|
[section:zip_example Example]
|
||||||
|
|
||||||
There are two main types of applications of the `zip_iterator`. The first
|
There are two main types of applications of the `zip_iterator`. The first
|
||||||
@ -218,7 +228,7 @@ operations.
|
|||||||
, IteratorTuple>::type* = 0 // exposition only
|
, IteratorTuple>::type* = 0 // exposition only
|
||||||
);
|
);
|
||||||
|
|
||||||
[*Returns:] An instance of `zip_iterator` that is a copy of `other`.\n
|
[*Returns:] An instance of `zip_iterator` that is a copy of `other`.[br]
|
||||||
[*Requires:] `OtherIteratorTuple` is implicitly convertible to `IteratorTuple`.
|
[*Requires:] `OtherIteratorTuple` is implicitly convertible to `IteratorTuple`.
|
||||||
|
|
||||||
|
|
||||||
@ -235,13 +245,13 @@ operations.
|
|||||||
|
|
||||||
zip_iterator& operator++();
|
zip_iterator& operator++();
|
||||||
|
|
||||||
[*Effects:] Increments each iterator in `m_iterator_tuple`.\n
|
[*Effects:] Increments each iterator in `m_iterator_tuple`.[br]
|
||||||
[*Returns:] `*this`
|
[*Returns:] `*this`
|
||||||
|
|
||||||
|
|
||||||
zip_iterator& operator--();
|
zip_iterator& operator--();
|
||||||
|
|
||||||
[*Effects:] Decrements each iterator in `m_iterator_tuple`.\n
|
[*Effects:] Decrements each iterator in `m_iterator_tuple`.[br]
|
||||||
[*Returns:] `*this`
|
[*Returns:] `*this`
|
||||||
|
|
||||||
template<typename IteratorTuple>
|
template<typename IteratorTuple>
|
||||||
|
@ -8,3 +8,13 @@ iterator is constructed from a tuple of iterators. Moving
|
|||||||
the zip iterator moves all the iterators in parallel.
|
the zip iterator moves all the iterators in parallel.
|
||||||
Dereferencing the zip iterator returns a tuple that contains
|
Dereferencing the zip iterator returns a tuple that contains
|
||||||
the results of dereferencing the individual iterators.
|
the results of dereferencing the individual iterators.
|
||||||
|
|
||||||
|
The tuple of iterators is now implemented in terms of a Boost fusion sequence.
|
||||||
|
Because of this the 'tuple' may be any Boost fusion sequence and, for backwards
|
||||||
|
compatibility through a Boost fusion sequence adapter, a Boost tuple. Because the
|
||||||
|
'tuple' may be any boost::fusion sequence the 'tuple' may also be any type for which a
|
||||||
|
Boost fusion adapter exists. This includes, among others, a std::tuple and a std::pair.
|
||||||
|
Just remember to include the appropriate Boost fusion adapter header files for these
|
||||||
|
other Boost fusion adapters. The zip_iterator header file already includes the
|
||||||
|
Boost fusion adapter header file for Boost tuple, so you need not include it yourself
|
||||||
|
to use a Boost tuple as your 'tuple'.
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
#ifndef BOOST_FILTER_ITERATOR_23022003THW_HPP
|
#ifndef BOOST_FILTER_ITERATOR_23022003THW_HPP
|
||||||
#define BOOST_FILTER_ITERATOR_23022003THW_HPP
|
#define BOOST_FILTER_ITERATOR_23022003THW_HPP
|
||||||
|
|
||||||
#include <boost/iterator.hpp>
|
|
||||||
#include <boost/iterator/iterator_adaptor.hpp>
|
#include <boost/iterator/iterator_adaptor.hpp>
|
||||||
#include <boost/iterator/iterator_categories.hpp>
|
#include <boost/iterator/iterator_categories.hpp>
|
||||||
|
|
||||||
|
@ -7,12 +7,10 @@
|
|||||||
#ifndef BOOST_INDIRECT_ITERATOR_23022003THW_HPP
|
#ifndef BOOST_INDIRECT_ITERATOR_23022003THW_HPP
|
||||||
#define BOOST_INDIRECT_ITERATOR_23022003THW_HPP
|
#define BOOST_INDIRECT_ITERATOR_23022003THW_HPP
|
||||||
|
|
||||||
#include <boost/iterator.hpp>
|
|
||||||
#include <boost/iterator/iterator_adaptor.hpp>
|
#include <boost/iterator/iterator_adaptor.hpp>
|
||||||
|
|
||||||
#include <boost/pointee.hpp>
|
#include <boost/pointee.hpp>
|
||||||
#include <boost/indirect_reference.hpp>
|
#include <boost/indirect_reference.hpp>
|
||||||
#include <boost/detail/iterator.hpp>
|
|
||||||
|
|
||||||
#include <boost/detail/indirect_traits.hpp>
|
#include <boost/detail/indirect_traits.hpp>
|
||||||
|
|
||||||
@ -25,6 +23,8 @@
|
|||||||
#include <boost/mpl/not.hpp>
|
#include <boost/mpl/not.hpp>
|
||||||
#include <boost/mpl/has_xxx.hpp>
|
#include <boost/mpl/has_xxx.hpp>
|
||||||
|
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
#ifdef BOOST_MPL_CFG_NO_HAS_XXX
|
#ifdef BOOST_MPL_CFG_NO_HAS_XXX
|
||||||
# include <boost/shared_ptr.hpp>
|
# include <boost/shared_ptr.hpp>
|
||||||
# include <boost/scoped_ptr.hpp>
|
# include <boost/scoped_ptr.hpp>
|
||||||
@ -45,7 +45,7 @@ namespace iterators {
|
|||||||
template <class Iter, class Value, class Category, class Reference, class Difference>
|
template <class Iter, class Value, class Category, class Reference, class Difference>
|
||||||
struct indirect_base
|
struct indirect_base
|
||||||
{
|
{
|
||||||
typedef typename boost::detail::iterator_traits<Iter>::value_type dereferenceable;
|
typedef typename std::iterator_traits<Iter>::value_type dereferenceable;
|
||||||
|
|
||||||
typedef iterator_adaptor<
|
typedef iterator_adaptor<
|
||||||
indirect_iterator<Iter, Value, Category, Reference, Difference>
|
indirect_iterator<Iter, Value, Category, Reference, Difference>
|
||||||
|
@ -4,16 +4,15 @@
|
|||||||
#ifndef IS_LVALUE_ITERATOR_DWA2003112_HPP
|
#ifndef IS_LVALUE_ITERATOR_DWA2003112_HPP
|
||||||
# define IS_LVALUE_ITERATOR_DWA2003112_HPP
|
# define IS_LVALUE_ITERATOR_DWA2003112_HPP
|
||||||
|
|
||||||
#include <boost/iterator.hpp>
|
|
||||||
|
|
||||||
#include <boost/detail/workaround.hpp>
|
#include <boost/detail/workaround.hpp>
|
||||||
#include <boost/detail/iterator.hpp>
|
|
||||||
|
|
||||||
#include <boost/type_traits/add_lvalue_reference.hpp>
|
#include <boost/type_traits/add_lvalue_reference.hpp>
|
||||||
#include <boost/iterator/detail/any_conversion_eater.hpp>
|
#include <boost/iterator/detail/any_conversion_eater.hpp>
|
||||||
#include <boost/mpl/bool.hpp>
|
#include <boost/mpl/bool.hpp>
|
||||||
#include <boost/mpl/aux_/lambda_support.hpp>
|
#include <boost/mpl/aux_/lambda_support.hpp>
|
||||||
|
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
// should be the last #includes
|
// should be the last #includes
|
||||||
#include <boost/type_traits/integral_constant.hpp>
|
#include <boost/type_traits/integral_constant.hpp>
|
||||||
#include <boost/iterator/detail/config_def.hpp>
|
#include <boost/iterator/detail/config_def.hpp>
|
||||||
@ -125,14 +124,14 @@ namespace detail
|
|||||||
template <class It>
|
template <class It>
|
||||||
struct is_readable_lvalue_iterator_impl
|
struct is_readable_lvalue_iterator_impl
|
||||||
: is_lvalue_iterator_impl<
|
: is_lvalue_iterator_impl<
|
||||||
BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<It>::value_type const
|
BOOST_DEDUCED_TYPENAME std::iterator_traits<It>::value_type const
|
||||||
>::template rebind<It>
|
>::template rebind<It>
|
||||||
{};
|
{};
|
||||||
|
|
||||||
template <class It>
|
template <class It>
|
||||||
struct is_non_const_lvalue_iterator_impl
|
struct is_non_const_lvalue_iterator_impl
|
||||||
: is_lvalue_iterator_impl<
|
: is_lvalue_iterator_impl<
|
||||||
BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<It>::value_type
|
BOOST_DEDUCED_TYPENAME std::iterator_traits<It>::value_type
|
||||||
>::template rebind<It>
|
>::template rebind<It>
|
||||||
{};
|
{};
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
@ -6,11 +6,12 @@
|
|||||||
|
|
||||||
#include <boost/mpl/bool.hpp>
|
#include <boost/mpl/bool.hpp>
|
||||||
#include <boost/mpl/aux_/lambda_support.hpp>
|
#include <boost/mpl/aux_/lambda_support.hpp>
|
||||||
#include <boost/detail/iterator.hpp>
|
|
||||||
#include <boost/type_traits/add_lvalue_reference.hpp>
|
#include <boost/type_traits/add_lvalue_reference.hpp>
|
||||||
|
|
||||||
#include <boost/iterator/detail/any_conversion_eater.hpp>
|
#include <boost/iterator/detail/any_conversion_eater.hpp>
|
||||||
|
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
// should be the last #include
|
// should be the last #include
|
||||||
#include <boost/type_traits/integral_constant.hpp>
|
#include <boost/type_traits/integral_constant.hpp>
|
||||||
#include <boost/iterator/detail/config_def.hpp>
|
#include <boost/iterator/detail/config_def.hpp>
|
||||||
@ -93,7 +94,7 @@ namespace detail
|
|||||||
template <class It>
|
template <class It>
|
||||||
struct is_readable_iterator_impl2
|
struct is_readable_iterator_impl2
|
||||||
: is_readable_iterator_impl<
|
: is_readable_iterator_impl<
|
||||||
BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<It>::value_type const
|
BOOST_DEDUCED_TYPENAME std::iterator_traits<It>::value_type const
|
||||||
>::template rebind<It>
|
>::template rebind<It>
|
||||||
{};
|
{};
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
#define BOOST_ITERATOR_ADAPTOR_23022003THW_HPP
|
#define BOOST_ITERATOR_ADAPTOR_23022003THW_HPP
|
||||||
|
|
||||||
#include <boost/static_assert.hpp>
|
#include <boost/static_assert.hpp>
|
||||||
#include <boost/iterator.hpp>
|
|
||||||
#include <boost/detail/iterator.hpp>
|
|
||||||
|
|
||||||
#include <boost/iterator/iterator_categories.hpp>
|
#include <boost/iterator/iterator_categories.hpp>
|
||||||
#include <boost/iterator/iterator_facade.hpp>
|
#include <boost/iterator/iterator_facade.hpp>
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#include <boost/iterator/iterator_categories.hpp>
|
#include <boost/iterator/iterator_categories.hpp>
|
||||||
#include <boost/operators.hpp>
|
#include <boost/operators.hpp>
|
||||||
#include <boost/static_assert.hpp>
|
#include <boost/static_assert.hpp>
|
||||||
#include <boost/iterator.hpp>
|
|
||||||
|
|
||||||
#include <boost/iterator/detail/facade_iterator_category.hpp>
|
#include <boost/iterator/detail/facade_iterator_category.hpp>
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
# define BOOST_ITERATOR_CATEGORIES_HPP
|
# define BOOST_ITERATOR_CATEGORIES_HPP
|
||||||
|
|
||||||
# include <boost/config.hpp>
|
# include <boost/config.hpp>
|
||||||
# include <boost/detail/iterator.hpp>
|
|
||||||
# include <boost/iterator/detail/config_def.hpp>
|
# include <boost/iterator/detail/config_def.hpp>
|
||||||
|
|
||||||
# include <boost/detail/workaround.hpp>
|
# include <boost/detail/workaround.hpp>
|
||||||
@ -21,6 +20,8 @@
|
|||||||
|
|
||||||
# include <boost/static_assert.hpp>
|
# include <boost/static_assert.hpp>
|
||||||
|
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace iterators {
|
namespace iterators {
|
||||||
|
|
||||||
@ -116,7 +117,7 @@ struct iterator_category_to_traversal
|
|||||||
template <class Iterator = mpl::_1>
|
template <class Iterator = mpl::_1>
|
||||||
struct iterator_traversal
|
struct iterator_traversal
|
||||||
: iterator_category_to_traversal<
|
: iterator_category_to_traversal<
|
||||||
typename boost::detail::iterator_traits<Iterator>::iterator_category
|
typename std::iterator_traits<Iterator>::iterator_category
|
||||||
>
|
>
|
||||||
{};
|
{};
|
||||||
|
|
||||||
|
@ -9,9 +9,6 @@
|
|||||||
#include <boost/concept_check.hpp>
|
#include <boost/concept_check.hpp>
|
||||||
#include <boost/iterator/iterator_categories.hpp>
|
#include <boost/iterator/iterator_categories.hpp>
|
||||||
|
|
||||||
// Use boost::detail::iterator_traits to work around some MSVC/Dinkumware problems.
|
|
||||||
#include <boost/detail/iterator.hpp>
|
|
||||||
|
|
||||||
#include <boost/type_traits/is_same.hpp>
|
#include <boost/type_traits/is_same.hpp>
|
||||||
#include <boost/type_traits/is_integral.hpp>
|
#include <boost/type_traits/is_integral.hpp>
|
||||||
|
|
||||||
@ -27,6 +24,7 @@
|
|||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
#include <boost/concept/detail/concept_def.hpp>
|
#include <boost/concept/detail/concept_def.hpp>
|
||||||
|
|
||||||
@ -44,8 +42,8 @@ namespace boost_concepts
|
|||||||
, boost::CopyConstructible<Iterator>
|
, boost::CopyConstructible<Iterator>
|
||||||
|
|
||||||
{
|
{
|
||||||
typedef BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::value_type value_type;
|
typedef BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::value_type value_type;
|
||||||
typedef BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::reference reference;
|
typedef BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::reference reference;
|
||||||
|
|
||||||
BOOST_CONCEPT_USAGE(ReadableIterator)
|
BOOST_CONCEPT_USAGE(ReadableIterator)
|
||||||
{
|
{
|
||||||
@ -59,7 +57,7 @@ namespace boost_concepts
|
|||||||
|
|
||||||
template <
|
template <
|
||||||
typename Iterator
|
typename Iterator
|
||||||
, typename ValueType = BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::value_type
|
, typename ValueType = BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::value_type
|
||||||
>
|
>
|
||||||
struct WritableIterator
|
struct WritableIterator
|
||||||
: boost::CopyConstructible<Iterator>
|
: boost::CopyConstructible<Iterator>
|
||||||
@ -75,7 +73,7 @@ namespace boost_concepts
|
|||||||
|
|
||||||
template <
|
template <
|
||||||
typename Iterator
|
typename Iterator
|
||||||
, typename ValueType = BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::value_type
|
, typename ValueType = BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::value_type
|
||||||
>
|
>
|
||||||
struct WritableIteratorConcept : WritableIterator<Iterator,ValueType> {};
|
struct WritableIteratorConcept : WritableIterator<Iterator,ValueType> {};
|
||||||
|
|
||||||
@ -92,7 +90,7 @@ namespace boost_concepts
|
|||||||
|
|
||||||
BOOST_concept(LvalueIterator,(Iterator))
|
BOOST_concept(LvalueIterator,(Iterator))
|
||||||
{
|
{
|
||||||
typedef typename boost::detail::iterator_traits<Iterator>::value_type value_type;
|
typedef typename std::iterator_traits<Iterator>::value_type value_type;
|
||||||
|
|
||||||
BOOST_CONCEPT_USAGE(LvalueIterator)
|
BOOST_CONCEPT_USAGE(LvalueIterator)
|
||||||
{
|
{
|
||||||
@ -144,7 +142,7 @@ namespace boost_concepts
|
|||||||
: SinglePassIterator<Iterator>
|
: SinglePassIterator<Iterator>
|
||||||
, boost::DefaultConstructible<Iterator>
|
, boost::DefaultConstructible<Iterator>
|
||||||
{
|
{
|
||||||
typedef typename boost::detail::iterator_traits<Iterator>::difference_type difference_type;
|
typedef typename std::iterator_traits<Iterator>::difference_type difference_type;
|
||||||
|
|
||||||
BOOST_MPL_ASSERT((boost::is_integral<difference_type>));
|
BOOST_MPL_ASSERT((boost::is_integral<difference_type>));
|
||||||
BOOST_MPL_ASSERT_RELATION(std::numeric_limits<difference_type>::is_signed, ==, true);
|
BOOST_MPL_ASSERT_RELATION(std::numeric_limits<difference_type>::is_signed, ==, true);
|
||||||
@ -221,7 +219,7 @@ namespace boost_concepts
|
|||||||
boost::random_access_traversal_tag, boost::random_access_traversal_tag)
|
boost::random_access_traversal_tag, boost::random_access_traversal_tag)
|
||||||
{
|
{
|
||||||
bool b;
|
bool b;
|
||||||
typename boost::detail::iterator_traits<Iterator2>::difference_type n;
|
typename std::iterator_traits<Iterator2>::difference_type n;
|
||||||
b = i1 < i2;
|
b = i1 < i2;
|
||||||
b = i1 <= i2;
|
b = i1 <= i2;
|
||||||
b = i1 > i2;
|
b = i1 > i2;
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#define BOOST_ITERATOR_FACADE_23022003THW_HPP
|
#define BOOST_ITERATOR_FACADE_23022003THW_HPP
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/iterator.hpp>
|
|
||||||
#include <boost/iterator/interoperable.hpp>
|
#include <boost/iterator/interoperable.hpp>
|
||||||
#include <boost/iterator/iterator_traits.hpp>
|
#include <boost/iterator/iterator_traits.hpp>
|
||||||
#include <boost/iterator/iterator_categories.hpp>
|
#include <boost/iterator/iterator_categories.hpp>
|
||||||
@ -37,6 +36,8 @@
|
|||||||
#include <boost/mpl/apply.hpp>
|
#include <boost/mpl/apply.hpp>
|
||||||
#include <boost/mpl/identity.hpp>
|
#include <boost/mpl/identity.hpp>
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
#include <boost/iterator/detail/config_def.hpp> // this goes last
|
#include <boost/iterator/detail/config_def.hpp> // this goes last
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
|
@ -5,9 +5,10 @@
|
|||||||
#ifndef ITERATOR_TRAITS_DWA200347_HPP
|
#ifndef ITERATOR_TRAITS_DWA200347_HPP
|
||||||
# define ITERATOR_TRAITS_DWA200347_HPP
|
# define ITERATOR_TRAITS_DWA200347_HPP
|
||||||
|
|
||||||
# include <boost/detail/iterator.hpp>
|
|
||||||
# include <boost/detail/workaround.hpp>
|
# include <boost/detail/workaround.hpp>
|
||||||
|
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace iterators {
|
namespace iterators {
|
||||||
|
|
||||||
@ -19,32 +20,32 @@ namespace iterators {
|
|||||||
template <class Iterator>
|
template <class Iterator>
|
||||||
struct iterator_value
|
struct iterator_value
|
||||||
{
|
{
|
||||||
typedef typename boost::detail::iterator_traits<Iterator>::value_type type;
|
typedef typename std::iterator_traits<Iterator>::value_type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Iterator>
|
template <class Iterator>
|
||||||
struct iterator_reference
|
struct iterator_reference
|
||||||
{
|
{
|
||||||
typedef typename boost::detail::iterator_traits<Iterator>::reference type;
|
typedef typename std::iterator_traits<Iterator>::reference type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class Iterator>
|
template <class Iterator>
|
||||||
struct iterator_pointer
|
struct iterator_pointer
|
||||||
{
|
{
|
||||||
typedef typename boost::detail::iterator_traits<Iterator>::pointer type;
|
typedef typename std::iterator_traits<Iterator>::pointer type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Iterator>
|
template <class Iterator>
|
||||||
struct iterator_difference
|
struct iterator_difference
|
||||||
{
|
{
|
||||||
typedef typename boost::detail::iterator_traits<Iterator>::difference_type type;
|
typedef typename std::iterator_traits<Iterator>::difference_type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Iterator>
|
template <class Iterator>
|
||||||
struct iterator_category
|
struct iterator_category
|
||||||
{
|
{
|
||||||
typedef typename boost::detail::iterator_traits<Iterator>::iterator_category type;
|
typedef typename std::iterator_traits<Iterator>::iterator_category type;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace iterators
|
} // namespace iterators
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
# include <boost/type_traits.hpp>
|
# include <boost/type_traits.hpp>
|
||||||
# include <boost/static_assert.hpp>
|
# include <boost/static_assert.hpp>
|
||||||
# include <boost/concept_archetype.hpp> // for detail::dummy_constructor
|
# include <boost/concept_archetype.hpp> // for detail::dummy_constructor
|
||||||
# include <boost/detail/iterator.hpp>
|
|
||||||
# include <boost/pending/iterator_tests.hpp>
|
# include <boost/pending/iterator_tests.hpp>
|
||||||
# include <boost/iterator/is_readable_iterator.hpp>
|
# include <boost/iterator/is_readable_iterator.hpp>
|
||||||
# include <boost/iterator/is_lvalue_iterator.hpp>
|
# include <boost/iterator/is_lvalue_iterator.hpp>
|
||||||
@ -76,7 +75,7 @@ template <class Iterator, class T>
|
|||||||
void readable_iterator_test(const Iterator i1, T v)
|
void readable_iterator_test(const Iterator i1, T v)
|
||||||
{
|
{
|
||||||
Iterator i2(i1); // Copy Constructible
|
Iterator i2(i1); // Copy Constructible
|
||||||
typedef typename detail::iterator_traits<Iterator>::reference ref_t;
|
typedef typename std::iterator_traits<Iterator>::reference ref_t;
|
||||||
ref_t r1 = *i1;
|
ref_t r1 = *i1;
|
||||||
ref_t r2 = *i2;
|
ref_t r2 = *i2;
|
||||||
T v1 = r1;
|
T v1 = r1;
|
||||||
@ -112,9 +111,9 @@ template <class Iterator>
|
|||||||
void swappable_iterator_test(Iterator i, Iterator j)
|
void swappable_iterator_test(Iterator i, Iterator j)
|
||||||
{
|
{
|
||||||
Iterator i2(i), j2(j);
|
Iterator i2(i), j2(j);
|
||||||
typename detail::iterator_traits<Iterator>::value_type bi = *i, bj = *j;
|
typename std::iterator_traits<Iterator>::value_type bi = *i, bj = *j;
|
||||||
iter_swap(i2, j2);
|
iter_swap(i2, j2);
|
||||||
typename detail::iterator_traits<Iterator>::value_type ai = *i, aj = *j;
|
typename std::iterator_traits<Iterator>::value_type ai = *i, aj = *j;
|
||||||
BOOST_TEST(bi == aj && bj == ai);
|
BOOST_TEST(bi == aj && bj == ai);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,8 +121,8 @@ template <class Iterator, class T>
|
|||||||
void constant_lvalue_iterator_test(Iterator i, T v1)
|
void constant_lvalue_iterator_test(Iterator i, T v1)
|
||||||
{
|
{
|
||||||
Iterator i2(i);
|
Iterator i2(i);
|
||||||
typedef typename detail::iterator_traits<Iterator>::value_type value_type;
|
typedef typename std::iterator_traits<Iterator>::value_type value_type;
|
||||||
typedef typename detail::iterator_traits<Iterator>::reference reference;
|
typedef typename std::iterator_traits<Iterator>::reference reference;
|
||||||
BOOST_STATIC_ASSERT((is_same<const value_type&, reference>::value));
|
BOOST_STATIC_ASSERT((is_same<const value_type&, reference>::value));
|
||||||
const T& v2 = *i2;
|
const T& v2 = *i2;
|
||||||
BOOST_TEST(v1 == v2);
|
BOOST_TEST(v1 == v2);
|
||||||
@ -137,8 +136,8 @@ template <class Iterator, class T>
|
|||||||
void non_const_lvalue_iterator_test(Iterator i, T v1, T v2)
|
void non_const_lvalue_iterator_test(Iterator i, T v1, T v2)
|
||||||
{
|
{
|
||||||
Iterator i2(i);
|
Iterator i2(i);
|
||||||
typedef typename detail::iterator_traits<Iterator>::value_type value_type;
|
typedef typename std::iterator_traits<Iterator>::value_type value_type;
|
||||||
typedef typename detail::iterator_traits<Iterator>::reference reference;
|
typedef typename std::iterator_traits<Iterator>::reference reference;
|
||||||
BOOST_STATIC_ASSERT((is_same<value_type&, reference>::value));
|
BOOST_STATIC_ASSERT((is_same<value_type&, reference>::value));
|
||||||
T& v3 = *i2;
|
T& v3 = *i2;
|
||||||
BOOST_TEST(v1 == v3);
|
BOOST_TEST(v1 == v3);
|
||||||
@ -229,7 +228,7 @@ void random_access_readable_iterator_test(Iterator i, int N, TrueVals vals)
|
|||||||
{
|
{
|
||||||
BOOST_TEST(i == j + c);
|
BOOST_TEST(i == j + c);
|
||||||
BOOST_TEST(*i == vals[c]);
|
BOOST_TEST(*i == vals[c]);
|
||||||
typename detail::iterator_traits<Iterator>::value_type x = j[c];
|
typename std::iterator_traits<Iterator>::value_type x = j[c];
|
||||||
BOOST_TEST(*i == x);
|
BOOST_TEST(*i == x);
|
||||||
BOOST_TEST(*i == *(j + c));
|
BOOST_TEST(*i == *(j + c));
|
||||||
BOOST_TEST(*i == *(c + j));
|
BOOST_TEST(*i == *(c + j));
|
||||||
@ -245,7 +244,7 @@ void random_access_readable_iterator_test(Iterator i, int N, TrueVals vals)
|
|||||||
{
|
{
|
||||||
BOOST_TEST(i == k - c);
|
BOOST_TEST(i == k - c);
|
||||||
BOOST_TEST(*i == vals[N - 1 - c]);
|
BOOST_TEST(*i == vals[N - 1 - c]);
|
||||||
typename detail::iterator_traits<Iterator>::value_type x = j[N - 1 - c];
|
typename std::iterator_traits<Iterator>::value_type x = j[N - 1 - c];
|
||||||
BOOST_TEST(*i == x);
|
BOOST_TEST(*i == x);
|
||||||
Iterator q = k - c;
|
Iterator q = k - c;
|
||||||
BOOST_TEST(*i == *q);
|
BOOST_TEST(*i == *q);
|
||||||
|
@ -21,13 +21,13 @@ template< class ElementIterator
|
|||||||
class permutation_iterator
|
class permutation_iterator
|
||||||
: public iterator_adaptor<
|
: public iterator_adaptor<
|
||||||
permutation_iterator<ElementIterator, IndexIterator>
|
permutation_iterator<ElementIterator, IndexIterator>
|
||||||
, IndexIterator, typename boost::detail::iterator_traits<ElementIterator>::value_type
|
, IndexIterator, typename std::iterator_traits<ElementIterator>::value_type
|
||||||
, use_default, typename boost::detail::iterator_traits<ElementIterator>::reference>
|
, use_default, typename std::iterator_traits<ElementIterator>::reference>
|
||||||
{
|
{
|
||||||
typedef iterator_adaptor<
|
typedef iterator_adaptor<
|
||||||
permutation_iterator<ElementIterator, IndexIterator>
|
permutation_iterator<ElementIterator, IndexIterator>
|
||||||
, IndexIterator, typename boost::detail::iterator_traits<ElementIterator>::value_type
|
, IndexIterator, typename std::iterator_traits<ElementIterator>::value_type
|
||||||
, use_default, typename boost::detail::iterator_traits<ElementIterator>::reference> super_t;
|
, use_default, typename std::iterator_traits<ElementIterator>::reference> super_t;
|
||||||
|
|
||||||
friend class iterator_core_access;
|
friend class iterator_core_access;
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#define BOOST_REVERSE_ITERATOR_23022003THW_HPP
|
#define BOOST_REVERSE_ITERATOR_23022003THW_HPP
|
||||||
|
|
||||||
#include <boost/next_prior.hpp>
|
#include <boost/next_prior.hpp>
|
||||||
#include <boost/iterator.hpp>
|
|
||||||
#include <boost/iterator/iterator_adaptor.hpp>
|
#include <boost/iterator/iterator_adaptor.hpp>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
#ifndef BOOST_TRANSFORM_ITERATOR_23022003THW_HPP
|
#ifndef BOOST_TRANSFORM_ITERATOR_23022003THW_HPP
|
||||||
#define BOOST_TRANSFORM_ITERATOR_23022003THW_HPP
|
#define BOOST_TRANSFORM_ITERATOR_23022003THW_HPP
|
||||||
|
|
||||||
#include <boost/iterator.hpp>
|
|
||||||
#include <boost/iterator/detail/enable_if.hpp>
|
#include <boost/iterator/detail/enable_if.hpp>
|
||||||
#include <boost/iterator/iterator_adaptor.hpp>
|
#include <boost/iterator/iterator_adaptor.hpp>
|
||||||
#include <boost/iterator/iterator_categories.hpp>
|
#include <boost/iterator/iterator_categories.hpp>
|
||||||
@ -22,11 +21,12 @@
|
|||||||
#include <boost/type_traits/remove_reference.hpp>
|
#include <boost/type_traits/remove_reference.hpp>
|
||||||
#include <boost/utility/result_of.hpp>
|
#include <boost/utility/result_of.hpp>
|
||||||
|
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
|
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
|
||||||
# include <boost/type_traits/is_base_and_derived.hpp>
|
# include <boost/type_traits/is_base_and_derived.hpp>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/iterator/detail/config_def.hpp>
|
#include <boost/iterator/detail/config_def.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,30 +1,38 @@
|
|||||||
// Copyright David Abrahams and Thomas Becker 2000-2006. Distributed
|
// Copyright David Abrahams and Thomas Becker 2000-2006.
|
||||||
// under the Boost Software License, Version 1.0. (See accompanying
|
// Copyright Kohei Takahashi 2012-2014.
|
||||||
// file LICENSE_1_0.txt or copy at
|
//
|
||||||
|
// Distributed under 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)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef BOOST_ZIP_ITERATOR_TMB_07_13_2003_HPP_
|
#ifndef BOOST_ZIP_ITERATOR_TMB_07_13_2003_HPP_
|
||||||
# define BOOST_ZIP_ITERATOR_TMB_07_13_2003_HPP_
|
# define BOOST_ZIP_ITERATOR_TMB_07_13_2003_HPP_
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <boost/iterator.hpp>
|
|
||||||
#include <boost/iterator/iterator_traits.hpp>
|
#include <boost/iterator/iterator_traits.hpp>
|
||||||
#include <boost/iterator/iterator_facade.hpp>
|
#include <boost/iterator/iterator_facade.hpp>
|
||||||
#include <boost/iterator/iterator_adaptor.hpp> // for enable_if_convertible
|
#include <boost/iterator/iterator_adaptor.hpp> // for enable_if_convertible
|
||||||
#include <boost/iterator/iterator_categories.hpp>
|
#include <boost/iterator/iterator_categories.hpp>
|
||||||
#include <boost/detail/iterator.hpp>
|
|
||||||
|
|
||||||
#include <boost/iterator/minimum_category.hpp>
|
#include <boost/iterator/minimum_category.hpp>
|
||||||
|
|
||||||
#include <boost/tuple/tuple.hpp>
|
#include <utility> // for std::pair
|
||||||
|
#include <boost/fusion/adapted/boost_tuple.hpp> // for backward compatibility
|
||||||
|
|
||||||
#include <boost/type_traits/is_same.hpp>
|
#include <boost/type_traits/remove_reference.hpp>
|
||||||
#include <boost/mpl/and.hpp>
|
#include <boost/type_traits/remove_cv.hpp>
|
||||||
#include <boost/mpl/apply.hpp>
|
|
||||||
#include <boost/mpl/eval_if.hpp>
|
#include <boost/mpl/at.hpp>
|
||||||
#include <boost/mpl/lambda.hpp>
|
#include <boost/mpl/fold.hpp>
|
||||||
|
#include <boost/mpl/transform.hpp>
|
||||||
#include <boost/mpl/placeholders.hpp>
|
#include <boost/mpl/placeholders.hpp>
|
||||||
#include <boost/mpl/aux_/lambda_support.hpp>
|
|
||||||
|
#include <boost/fusion/algorithm/iteration/for_each.hpp>
|
||||||
|
#include <boost/fusion/algorithm/transformation/transform.hpp>
|
||||||
|
#include <boost/fusion/sequence/convert.hpp>
|
||||||
|
#include <boost/fusion/sequence/intrinsic/at_c.hpp>
|
||||||
|
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||||
|
#include <boost/fusion/support/tag_of_fwd.hpp>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace iterators {
|
namespace iterators {
|
||||||
@ -33,24 +41,6 @@ namespace iterators {
|
|||||||
template<typename IteratorTuple>
|
template<typename IteratorTuple>
|
||||||
class zip_iterator;
|
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
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -73,313 +63,96 @@ namespace iterators {
|
|||||||
struct increment_iterator
|
struct increment_iterator
|
||||||
{
|
{
|
||||||
template<typename Iterator>
|
template<typename Iterator>
|
||||||
void operator()(Iterator& it)
|
void operator()(Iterator& it) const
|
||||||
{ ++it; }
|
{ ++it; }
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
struct decrement_iterator
|
struct decrement_iterator
|
||||||
{
|
{
|
||||||
template<typename Iterator>
|
template<typename Iterator>
|
||||||
void operator()(Iterator& it)
|
void operator()(Iterator& it) const
|
||||||
{ --it; }
|
{ --it; }
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
struct dereference_iterator
|
struct dereference_iterator
|
||||||
{
|
{
|
||||||
template<typename Iterator>
|
template<typename>
|
||||||
struct apply
|
struct result;
|
||||||
|
|
||||||
|
template<typename This, typename Iterator>
|
||||||
|
struct result<This(Iterator)>
|
||||||
{
|
{
|
||||||
typedef typename
|
typedef typename
|
||||||
boost::detail::iterator_traits<Iterator>::reference
|
remove_reference<typename remove_cv<Iterator>::type>::type
|
||||||
type;
|
iterator;
|
||||||
|
|
||||||
|
typedef typename iterator_reference<iterator>::type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Iterator>
|
template<typename Iterator>
|
||||||
typename apply<Iterator>::type operator()(Iterator const& it)
|
typename result<dereference_iterator(Iterator)>::type
|
||||||
|
operator()(Iterator const& it) const
|
||||||
{ return *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<typename Tuple, class UnaryMetaFun>
|
|
||||||
struct tuple_meta_transform;
|
|
||||||
|
|
||||||
template<typename Tuple, class UnaryMetaFun>
|
|
||||||
struct tuple_meta_transform_impl
|
|
||||||
{
|
|
||||||
typedef tuples::cons<
|
|
||||||
typename mpl::apply1<
|
|
||||||
typename mpl::lambda<UnaryMetaFun>::type
|
|
||||||
, typename Tuple::head_type
|
|
||||||
>::type
|
|
||||||
, typename tuple_meta_transform<
|
|
||||||
typename Tuple::tail_type
|
|
||||||
, UnaryMetaFun
|
|
||||||
>::type
|
|
||||||
> type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename Tuple, class UnaryMetaFun>
|
|
||||||
struct tuple_meta_transform
|
|
||||||
: mpl::eval_if<
|
|
||||||
boost::is_same<Tuple, tuples::null_type>
|
|
||||||
, mpl::identity<tuples::null_type>
|
|
||||||
, tuple_meta_transform_impl<Tuple, UnaryMetaFun>
|
|
||||||
>
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
// Meta-accumulate algorithm for tuples. Note: The template
|
|
||||||
// parameter StartType corresponds to the initial value in
|
|
||||||
// ordinary accumulation.
|
|
||||||
//
|
|
||||||
template<class Tuple, class BinaryMetaFun, class StartType>
|
|
||||||
struct tuple_meta_accumulate;
|
|
||||||
|
|
||||||
template<
|
|
||||||
typename Tuple
|
|
||||||
, class BinaryMetaFun
|
|
||||||
, typename StartType
|
|
||||||
>
|
|
||||||
struct tuple_meta_accumulate_impl
|
|
||||||
{
|
|
||||||
typedef typename mpl::apply2<
|
|
||||||
typename mpl::lambda<BinaryMetaFun>::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::eval_if<
|
|
||||||
boost::is_same<Tuple, tuples::null_type>
|
|
||||||
, mpl::identity<StartType>
|
|
||||||
, 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 <class Arg>
|
|
||||||
// struct apply
|
|
||||||
// {
|
|
||||||
// typedef Arg* type;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// template <class Arg>
|
|
||||||
// Arg* operator()(Arg x);
|
|
||||||
// };
|
|
||||||
template<typename Fun>
|
|
||||||
inline tuples::null_type BOOST_TUPLE_ALGO(tuple_transform)
|
|
||||||
(tuples::null_type const&, Fun BOOST_TUPLE_ALGO_TERMINATOR)
|
|
||||||
{ return tuples::null_type(); }
|
|
||||||
|
|
||||||
template<typename Tuple, typename Fun>
|
|
||||||
inline 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, typename Fun>
|
|
||||||
inline 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<typename Fun>
|
|
||||||
inline Fun BOOST_TUPLE_ALGO(tuple_for_each)(
|
|
||||||
tuples::null_type
|
|
||||||
, Fun f BOOST_TUPLE_ALGO_TERMINATOR
|
|
||||||
)
|
|
||||||
{ return f; }
|
|
||||||
|
|
||||||
|
|
||||||
template<typename Tuple, typename Fun>
|
|
||||||
inline 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<typename Tuple, typename Fun>
|
|
||||||
inline 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.
|
|
||||||
//
|
|
||||||
inline bool tuple_equal(tuples::null_type, tuples::null_type)
|
|
||||||
{ return true; }
|
|
||||||
|
|
||||||
template<typename Tuple1, typename Tuple2>
|
|
||||||
inline 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<typename Iterator>
|
|
||||||
struct iterator_reference
|
|
||||||
{
|
|
||||||
typedef typename boost::detail::iterator_traits<Iterator>::reference type;
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef BOOST_MPL_CFG_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<mpl::_1>
|
|
||||||
{
|
|
||||||
template <class T>
|
|
||||||
struct apply : iterator_reference<T> {};
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Metafunction to obtain the type of the tuple whose element types
|
// Metafunction to obtain the type of the tuple whose element types
|
||||||
// are the reference types of an iterator tuple.
|
// are the reference types of an iterator tuple.
|
||||||
//
|
//
|
||||||
template<typename IteratorTuple>
|
template<typename IteratorTuple>
|
||||||
struct tuple_of_references
|
struct tuple_of_references
|
||||||
: tuple_impl_specific::tuple_meta_transform<
|
: mpl::transform<
|
||||||
IteratorTuple,
|
IteratorTuple,
|
||||||
iterator_reference<mpl::_1>
|
iterator_reference<mpl::_1>
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Specialization for std::pair
|
||||||
|
template<typename Iterator1, typename Iterator2>
|
||||||
|
struct tuple_of_references<std::pair<Iterator1, Iterator2> >
|
||||||
|
{
|
||||||
|
typedef std::pair<
|
||||||
|
typename iterator_reference<Iterator1>::type
|
||||||
|
, typename iterator_reference<Iterator2>::type
|
||||||
|
> type;
|
||||||
|
};
|
||||||
|
|
||||||
// Metafunction to obtain the minimal traversal tag in a tuple
|
// Metafunction to obtain the minimal traversal tag in a tuple
|
||||||
// of iterators.
|
// of iterators.
|
||||||
//
|
//
|
||||||
template<typename IteratorTuple>
|
template<typename IteratorTuple>
|
||||||
struct minimum_traversal_category_in_iterator_tuple
|
struct minimum_traversal_category_in_iterator_tuple
|
||||||
{
|
{
|
||||||
typedef typename tuple_impl_specific::tuple_meta_transform<
|
typedef typename mpl::transform<
|
||||||
IteratorTuple
|
IteratorTuple
|
||||||
, pure_traversal_tag<iterator_traversal<> >
|
, pure_traversal_tag<iterator_traversal<> >
|
||||||
>::type tuple_of_traversal_tags;
|
>::type tuple_of_traversal_tags;
|
||||||
|
|
||||||
typedef typename tuple_impl_specific::tuple_meta_accumulate<
|
typedef typename mpl::fold<
|
||||||
tuple_of_traversal_tags
|
tuple_of_traversal_tags
|
||||||
, minimum_category<>
|
|
||||||
, random_access_traversal_tag
|
, random_access_traversal_tag
|
||||||
|
, minimum_category<>
|
||||||
>::type type;
|
>::type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
// We need to call tuple_meta_accumulate with mpl::and_ as the
|
template<typename Iterator1, typename Iterator2>
|
||||||
// accumulating functor. To this end, we need to wrap it into
|
struct minimum_traversal_category_in_iterator_tuple<std::pair<Iterator1, Iterator2> >
|
||||||
// a struct that has exactly two arguments (that is, template
|
{
|
||||||
// parameters) and not five, like mpl::and_ does.
|
typedef typename pure_traversal_tag<
|
||||||
//
|
typename iterator_traversal<Iterator1>::type
|
||||||
template<typename Arg1, typename Arg2>
|
>::type iterator1_traversal;
|
||||||
struct and_with_two_args
|
typedef typename pure_traversal_tag<
|
||||||
: mpl::and_<Arg1, Arg2>
|
typename iterator_traversal<Iterator2>::type
|
||||||
{
|
>::type iterator2_traversal;
|
||||||
};
|
|
||||||
|
|
||||||
# ifdef BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT
|
typedef typename minimum_category<
|
||||||
// Hack because BOOST_MPL_AUX_LAMBDA_SUPPORT doesn't seem to work
|
iterator1_traversal
|
||||||
// out well. In this case I think it's an MPL bug
|
, typename minimum_category<
|
||||||
template<>
|
iterator2_traversal
|
||||||
struct and_with_two_args<mpl::_1,mpl::_2>
|
, random_access_traversal_tag
|
||||||
{
|
>::type
|
||||||
template <class A1, class A2>
|
>::type type;
|
||||||
struct apply : mpl::and_<A1,A2>
|
};
|
||||||
{};
|
|
||||||
};
|
|
||||||
# endif
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
@ -401,9 +174,9 @@ namespace iterators {
|
|||||||
typedef reference value_type;
|
typedef reference value_type;
|
||||||
|
|
||||||
// Difference type is the first iterator's difference type
|
// Difference type is the first iterator's difference type
|
||||||
typedef typename boost::detail::iterator_traits<
|
typedef typename iterator_difference<
|
||||||
typename tuples::element<0, IteratorTuple>::type
|
typename mpl::at_c<IteratorTuple, 0>::type
|
||||||
>::difference_type difference_type;
|
>::type difference_type;
|
||||||
|
|
||||||
// Traversal catetgory is the minimum traversal category in the
|
// Traversal catetgory is the minimum traversal category in the
|
||||||
// iterator tuple.
|
// iterator tuple.
|
||||||
@ -429,6 +202,30 @@ namespace iterators {
|
|||||||
{
|
{
|
||||||
typedef int type;
|
typedef int type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename reference>
|
||||||
|
struct converter
|
||||||
|
{
|
||||||
|
template <typename Seq>
|
||||||
|
static reference call(Seq seq)
|
||||||
|
{
|
||||||
|
typedef typename fusion::traits::tag_of<reference>::type tag;
|
||||||
|
return fusion::convert<tag>(seq);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename Reference1, typename Reference2>
|
||||||
|
struct converter<std::pair<Reference1, Reference2> >
|
||||||
|
{
|
||||||
|
typedef std::pair<Reference1, Reference2> reference;
|
||||||
|
template <typename Seq>
|
||||||
|
static reference call(Seq seq)
|
||||||
|
{
|
||||||
|
return reference(
|
||||||
|
fusion::at_c<0>(seq)
|
||||||
|
, fusion::at_c<1>(seq));
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
@ -484,10 +281,11 @@ namespace iterators {
|
|||||||
// iterators in the iterator tuple.
|
// iterators in the iterator tuple.
|
||||||
typename super_t::reference dereference() const
|
typename super_t::reference dereference() const
|
||||||
{
|
{
|
||||||
return detail::tuple_impl_specific::tuple_transform(
|
typedef typename super_t::reference reference;
|
||||||
get_iterator_tuple(),
|
typedef detail::converter<reference> gen;
|
||||||
detail::dereference_iterator()
|
return gen::call(fusion::transform(
|
||||||
);
|
get_iterator_tuple(),
|
||||||
|
detail::dereference_iterator()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Two zip iterators are equal if all iterators in the iterator
|
// Two zip iterators are equal if all iterators in the iterator
|
||||||
@ -503,39 +301,35 @@ namespace iterators {
|
|||||||
template<typename OtherIteratorTuple>
|
template<typename OtherIteratorTuple>
|
||||||
bool equal(const zip_iterator<OtherIteratorTuple>& other) const
|
bool equal(const zip_iterator<OtherIteratorTuple>& other) const
|
||||||
{
|
{
|
||||||
return detail::tuple_impl_specific::tuple_equal(
|
return fusion::equal_to(
|
||||||
get_iterator_tuple(),
|
get_iterator_tuple(),
|
||||||
other.get_iterator_tuple()
|
other.get_iterator_tuple());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Advancing a zip iterator means to advance all iterators in the
|
// Advancing a zip iterator means to advance all iterators in the
|
||||||
// iterator tuple.
|
// iterator tuple.
|
||||||
void advance(typename super_t::difference_type n)
|
void advance(typename super_t::difference_type n)
|
||||||
{
|
{
|
||||||
detail::tuple_impl_specific::tuple_for_each(
|
fusion::for_each(
|
||||||
m_iterator_tuple,
|
m_iterator_tuple,
|
||||||
detail::advance_iterator<BOOST_DEDUCED_TYPENAME super_t::difference_type>(n)
|
detail::advance_iterator<BOOST_DEDUCED_TYPENAME super_t::difference_type>(n));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
// Incrementing a zip iterator means to increment all iterators in
|
// Incrementing a zip iterator means to increment all iterators in
|
||||||
// the iterator tuple.
|
// the iterator tuple.
|
||||||
void increment()
|
void increment()
|
||||||
{
|
{
|
||||||
detail::tuple_impl_specific::tuple_for_each(
|
fusion::for_each(
|
||||||
m_iterator_tuple,
|
m_iterator_tuple,
|
||||||
detail::increment_iterator()
|
detail::increment_iterator());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decrementing a zip iterator means to decrement all iterators in
|
// Decrementing a zip iterator means to decrement all iterators in
|
||||||
// the iterator tuple.
|
// the iterator tuple.
|
||||||
void decrement()
|
void decrement()
|
||||||
{
|
{
|
||||||
detail::tuple_impl_specific::tuple_for_each(
|
fusion::for_each(
|
||||||
m_iterator_tuple,
|
m_iterator_tuple,
|
||||||
detail::decrement_iterator()
|
detail::decrement_iterator());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Distance is calculated using the first iterator in the tuple.
|
// Distance is calculated using the first iterator in the tuple.
|
||||||
@ -544,8 +338,8 @@ namespace iterators {
|
|||||||
const zip_iterator<OtherIteratorTuple>& other
|
const zip_iterator<OtherIteratorTuple>& other
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return boost::tuples::get<0>(other.get_iterator_tuple()) -
|
return fusion::at_c<0>(other.get_iterator_tuple()) -
|
||||||
boost::tuples::get<0>(this->get_iterator_tuple());
|
fusion::at_c<0>(this->get_iterator_tuple());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Data Members
|
// Data Members
|
||||||
|
@ -6,11 +6,12 @@
|
|||||||
#ifndef BOOST_INT_ITERATOR_H
|
#ifndef BOOST_INT_ITERATOR_H
|
||||||
#define BOOST_INT_ITERATOR_H
|
#define BOOST_INT_ITERATOR_H
|
||||||
|
|
||||||
#include <boost/iterator.hpp>
|
|
||||||
#if !defined BOOST_MSVC
|
#if !defined BOOST_MSVC
|
||||||
#include <boost/operators.hpp>
|
#include <boost/operators.hpp>
|
||||||
#endif
|
#endif
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <iterator>
|
||||||
|
#include <cstddef>
|
||||||
//using namespace std;
|
//using namespace std;
|
||||||
|
|
||||||
#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
|
#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
|
||||||
|
@ -215,7 +215,7 @@ void random_access_iterator_test(Iterator i, int N, TrueVals vals)
|
|||||||
const Iterator j = i;
|
const Iterator j = i;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
typedef typename boost::detail::iterator_traits<Iterator>::value_type value_type;
|
typedef typename std::iterator_traits<Iterator>::value_type value_type;
|
||||||
|
|
||||||
for (c = 0; c < N-1; ++c) {
|
for (c = 0; c < N-1; ++c) {
|
||||||
assert(i == j + c);
|
assert(i == j + c);
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
# include <boost/mpl/if.hpp>
|
# include <boost/mpl/if.hpp>
|
||||||
# include <boost/mpl/eval_if.hpp>
|
# include <boost/mpl/eval_if.hpp>
|
||||||
|
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
@ -33,7 +35,7 @@ namespace detail
|
|||||||
template <class Iterator>
|
template <class Iterator>
|
||||||
struct iterator_pointee
|
struct iterator_pointee
|
||||||
{
|
{
|
||||||
typedef typename iterator_traits<Iterator>::value_type value_type;
|
typedef typename std::iterator_traits<Iterator>::value_type value_type;
|
||||||
|
|
||||||
struct impl
|
struct impl
|
||||||
{
|
{
|
||||||
|
@ -14,11 +14,17 @@ test-suite iterator
|
|||||||
|
|
||||||
[ run zip_iterator_test.cpp
|
[ run zip_iterator_test.cpp
|
||||||
: : :
|
: : :
|
||||||
|
|
||||||
# stlport's debug mode generates long symbols which overwhelm
|
# stlport's debug mode generates long symbols which overwhelm
|
||||||
# vc6
|
# vc6
|
||||||
#<msvc-stlport><*><runtime-build>release
|
#<msvc-stlport><*><runtime-build>release
|
||||||
]
|
]
|
||||||
|
[ run zip_iterator_test2_std_tuple.cpp ]
|
||||||
|
[ run zip_iterator_test2_fusion_vector.cpp ]
|
||||||
|
[ run zip_iterator_test2_fusion_list.cpp ]
|
||||||
|
# [ run zip_iterator_test2_fusion_deque.cpp ] // See bug report for fusion https://svn.boost.org/trac/boost/ticket/11572
|
||||||
|
[ run zip_iterator_test_fusion.cpp ]
|
||||||
|
[ run zip_iterator_test_std_tuple.cpp ]
|
||||||
|
[ run zip_iterator_test_std_pair.cpp ]
|
||||||
|
|
||||||
# These tests should work for just about everything.
|
# These tests should work for just about everything.
|
||||||
[ compile is_lvalue_iterator.cpp ]
|
[ compile is_lvalue_iterator.cpp ]
|
||||||
|
@ -7,13 +7,16 @@
|
|||||||
#include <boost/iterator/iterator_categories.hpp>
|
#include <boost/iterator/iterator_categories.hpp>
|
||||||
#include <boost/operators.hpp>
|
#include <boost/operators.hpp>
|
||||||
|
|
||||||
|
#include <iterator>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
struct new_random_access
|
struct new_random_access
|
||||||
: std::random_access_iterator_tag
|
: std::random_access_iterator_tag
|
||||||
, boost::random_access_traversal_tag
|
, boost::random_access_traversal_tag
|
||||||
{};
|
{};
|
||||||
|
|
||||||
struct new_iterator
|
struct new_iterator
|
||||||
: public boost::iterator< new_random_access, int >
|
: public std::iterator< new_random_access, int >
|
||||||
{
|
{
|
||||||
int& operator*() const { return *m_x; }
|
int& operator*() const { return *m_x; }
|
||||||
new_iterator& operator++() { return *this; }
|
new_iterator& operator++() { return *this; }
|
||||||
@ -33,7 +36,7 @@ struct new_iterator
|
|||||||
new_iterator operator+(std::ptrdiff_t, new_iterator x) { return x; }
|
new_iterator operator+(std::ptrdiff_t, new_iterator x) { return x; }
|
||||||
|
|
||||||
struct old_iterator
|
struct old_iterator
|
||||||
: public boost::iterator<std::random_access_iterator_tag, int>
|
: public std::iterator<std::random_access_iterator_tag, int>
|
||||||
{
|
{
|
||||||
int& operator*() const { return *m_x; }
|
int& operator*() const { return *m_x; }
|
||||||
old_iterator& operator++() { return *this; }
|
old_iterator& operator++() { return *this; }
|
||||||
|
73
test/detail/zip_iterator_test.ipp
Normal file
73
test/detail/zip_iterator_test.ipp
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
// Copyright (c) 2014 Kohei Takahashi.
|
||||||
|
//
|
||||||
|
// Distributed under 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)
|
||||||
|
//
|
||||||
|
// See http://www.boost.org for most recent version including documentation.
|
||||||
|
|
||||||
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
|
|
||||||
|
#include <boost/assign/list_of.hpp>
|
||||||
|
#include <boost/fusion/include/at.hpp>
|
||||||
|
#include <boost/iterator/zip_iterator.hpp>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
typedef TUPLE<
|
||||||
|
std::vector<int>::iterator,
|
||||||
|
std::vector<std::string>::iterator
|
||||||
|
> iterator_tuple;
|
||||||
|
|
||||||
|
std::vector<int> vi = boost::assign::list_of(42)(72);
|
||||||
|
std::vector<std::string> vs = boost::assign::list_of("kokoro")("pyonpyon");
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::zip_iterator<iterator_tuple> i1(MAKE_TUPLE(vi.begin(), vs.begin()));
|
||||||
|
boost::zip_iterator<iterator_tuple> i2 = i1;
|
||||||
|
|
||||||
|
BOOST_TEST( i1 == i2);
|
||||||
|
BOOST_TEST( i1++ == i2);
|
||||||
|
BOOST_TEST( i1 == (i2 + 1));
|
||||||
|
BOOST_TEST((i1 - 1) == i2);
|
||||||
|
BOOST_TEST( i1-- == ++i2);
|
||||||
|
BOOST_TEST( i1 == --i2);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::zip_iterator<iterator_tuple> i1(MAKE_TUPLE(vi.begin(), vs.begin()));
|
||||||
|
boost::zip_iterator<iterator_tuple> i2 = i1 + 1;
|
||||||
|
|
||||||
|
BOOST_TEST( i1 != i2);
|
||||||
|
BOOST_TEST( i1++ != i2);
|
||||||
|
BOOST_TEST( i1 != (i2 + 1));
|
||||||
|
BOOST_TEST((i1 - 1) != i2);
|
||||||
|
BOOST_TEST( i1-- != ++i2);
|
||||||
|
BOOST_TEST( i1 != --i2);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::zip_iterator<iterator_tuple> i(MAKE_TUPLE(vi.begin(), vs.begin()));
|
||||||
|
|
||||||
|
BOOST_TEST(boost::fusion::at_c<0>(* i ) == 42);
|
||||||
|
BOOST_TEST(boost::fusion::at_c<1>(* i ) == "kokoro");
|
||||||
|
BOOST_TEST(boost::fusion::at_c<0>(*(i + 1)) == 72);
|
||||||
|
BOOST_TEST(boost::fusion::at_c<1>(*(i + 1)) == "pyonpyon");
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::zip_iterator<iterator_tuple> i1(MAKE_TUPLE(vi.begin(), vs.begin()));
|
||||||
|
boost::zip_iterator<iterator_tuple> i2(MAKE_TUPLE(vi.end(), vs.end()));
|
||||||
|
|
||||||
|
BOOST_TEST((i2 - i1) == 2);
|
||||||
|
++i1;
|
||||||
|
BOOST_TEST((i2 - i1) == 1);
|
||||||
|
--i2;
|
||||||
|
BOOST_TEST((i2 - i1) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
857
test/detail/zip_iterator_test_original.ipp
Normal file
857
test/detail/zip_iterator_test_original.ipp
Normal file
@ -0,0 +1,857 @@
|
|||||||
|
// (C) Copyright Dave Abrahams and Thomas Becker 2003. Distributed
|
||||||
|
// under 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)
|
||||||
|
//
|
||||||
|
|
||||||
|
// 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 <boost/iterator/zip_iterator.hpp>
|
||||||
|
#include <boost/iterator/zip_iterator.hpp> // 2nd #include tests #include guard.
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
#include <list>
|
||||||
|
#include <set>
|
||||||
|
#include <string>
|
||||||
|
#include <functional>
|
||||||
|
#include <boost/iterator/transform_iterator.hpp>
|
||||||
|
#include <boost/iterator/is_readable_iterator.hpp>
|
||||||
|
#include <boost/type_traits/is_same.hpp>
|
||||||
|
#include <boost/detail/workaround.hpp>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
|
||||||
|
/// Tests for https://svn.boost.org/trac/boost/ticket/1517
|
||||||
|
int to_value(int const &v)
|
||||||
|
{
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
void category_test()
|
||||||
|
{
|
||||||
|
std::list<int> rng1;
|
||||||
|
std::string rng2;
|
||||||
|
|
||||||
|
boost::make_zip_iterator(
|
||||||
|
ZI_MAKE_TUPLE(
|
||||||
|
boost::make_transform_iterator(rng1.begin(), &to_value), // BidirectionalInput
|
||||||
|
rng2.begin() // RandomAccess
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
///
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Das Main Funktion
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
int main( void )
|
||||||
|
{
|
||||||
|
|
||||||
|
category_test();
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Zip iterator construction and dereferencing
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
std::cout << "Zip iterator construction and dereferencing: "
|
||||||
|
<< std::flush;
|
||||||
|
|
||||||
|
std::vector<double> vect1(3);
|
||||||
|
vect1[0] = 42.;
|
||||||
|
vect1[1] = 43.;
|
||||||
|
vect1[2] = 44.;
|
||||||
|
|
||||||
|
std::set<int> intset;
|
||||||
|
intset.insert(52);
|
||||||
|
intset.insert(53);
|
||||||
|
intset.insert(54);
|
||||||
|
//
|
||||||
|
|
||||||
|
typedef
|
||||||
|
boost::zip_iterator<
|
||||||
|
ZI_TUPLE<
|
||||||
|
std::set<int>::iterator
|
||||||
|
, std::vector<double>::iterator
|
||||||
|
>
|
||||||
|
> zit_mixed;
|
||||||
|
|
||||||
|
zit_mixed zip_it_mixed = zit_mixed(
|
||||||
|
ZI_MAKE_TUPLE(
|
||||||
|
intset.begin()
|
||||||
|
, vect1.begin()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
ZI_TUPLE<int, double> val_tuple(
|
||||||
|
*zip_it_mixed);
|
||||||
|
|
||||||
|
ZI_TUPLE<const int&, double&> ref_tuple(
|
||||||
|
*zip_it_mixed);
|
||||||
|
|
||||||
|
double dblOldVal = ZI_TUPLE_GET(1)(ref_tuple);
|
||||||
|
ZI_TUPLE_GET(1)(ref_tuple) -= 41.;
|
||||||
|
|
||||||
|
if( 52 == ZI_TUPLE_GET(0)(val_tuple) &&
|
||||||
|
42. == ZI_TUPLE_GET(1)(val_tuple) &&
|
||||||
|
52 == ZI_TUPLE_GET(0)(ref_tuple) &&
|
||||||
|
1. == ZI_TUPLE_GET(1)(ref_tuple) &&
|
||||||
|
1. == *vect1.begin()
|
||||||
|
)
|
||||||
|
{
|
||||||
|
++num_successful_tests;
|
||||||
|
std::cout << "OK" << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
++num_failed_tests;
|
||||||
|
std::cout << "not OK" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Undo change to vect1
|
||||||
|
ZI_TUPLE_GET(1)(ref_tuple) = dblOldVal;
|
||||||
|
|
||||||
|
#if defined(ZI_USE_BOOST_TUPLE)
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Zip iterator with 12 components
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
std::cout << "Zip iterators with 12 components: "
|
||||||
|
<< std::flush;
|
||||||
|
|
||||||
|
// Declare 12 containers
|
||||||
|
//
|
||||||
|
std::list<int> li1;
|
||||||
|
li1.push_back(1);
|
||||||
|
std::set<int> se1;
|
||||||
|
se1.insert(2);
|
||||||
|
std::vector<int> ve1;
|
||||||
|
ve1.push_back(3);
|
||||||
|
//
|
||||||
|
std::list<int> li2;
|
||||||
|
li2.push_back(4);
|
||||||
|
std::set<int> se2;
|
||||||
|
se2.insert(5);
|
||||||
|
std::vector<int> ve2;
|
||||||
|
ve2.push_back(6);
|
||||||
|
//
|
||||||
|
std::list<int> li3;
|
||||||
|
li3.push_back(7);
|
||||||
|
std::set<int> se3;
|
||||||
|
se3.insert(8);
|
||||||
|
std::vector<int> ve3;
|
||||||
|
ve3.push_back(9);
|
||||||
|
//
|
||||||
|
std::list<int> li4;
|
||||||
|
li4.push_back(10);
|
||||||
|
std::set<int> se4;
|
||||||
|
se4.insert(11);
|
||||||
|
std::vector<int> ve4;
|
||||||
|
ve4.push_back(12);
|
||||||
|
|
||||||
|
// typedefs for cons lists of iterators.
|
||||||
|
typedef boost::tuples::cons<
|
||||||
|
std::set<int>::iterator,
|
||||||
|
ZI_TUPLE<
|
||||||
|
std::vector<int>::iterator,
|
||||||
|
std::list<int>::iterator,
|
||||||
|
std::set<int>::iterator,
|
||||||
|
std::vector<int>::iterator,
|
||||||
|
std::list<int>::iterator,
|
||||||
|
std::set<int>::iterator,
|
||||||
|
std::vector<int>::iterator,
|
||||||
|
std::list<int>::iterator,
|
||||||
|
std::set<int>::iterator,
|
||||||
|
std::vector<int>::const_iterator
|
||||||
|
>::inherited
|
||||||
|
> cons_11_its_type;
|
||||||
|
//
|
||||||
|
typedef boost::tuples::cons<
|
||||||
|
std::list<int>::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&,
|
||||||
|
ZI_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<cons_12_its_type> 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(),
|
||||||
|
ZI_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);
|
||||||
|
ZI_TUPLE_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( ZI_TUPLE_GET(11)(zip_it_12.get_iterator_tuple()) == ve4.begin() &&
|
||||||
|
ZI_TUPLE_GET(11)(zip_it_12_copy.get_iterator_tuple()) == ve4.end() &&
|
||||||
|
1 == ZI_TUPLE_GET(0)(zip_it_12_dereferenced) &&
|
||||||
|
12 == ZI_TUPLE_GET(11)(zip_it_12_dereferenced) &&
|
||||||
|
42 == *(li4.begin())
|
||||||
|
)
|
||||||
|
{
|
||||||
|
++num_successful_tests;
|
||||||
|
std::cout << "OK" << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
++num_failed_tests;
|
||||||
|
std::cout << "not OK" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Zip iterator incrementing and dereferencing
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
std::cout << "Zip iterator ++ and *: "
|
||||||
|
<< std::flush;
|
||||||
|
|
||||||
|
std::vector<double> vect2(3);
|
||||||
|
vect2[0] = 2.2;
|
||||||
|
vect2[1] = 3.3;
|
||||||
|
vect2[2] = 4.4;
|
||||||
|
|
||||||
|
boost::zip_iterator<
|
||||||
|
ZI_TUPLE<
|
||||||
|
std::vector<double>::const_iterator,
|
||||||
|
std::vector<double>::const_iterator
|
||||||
|
>
|
||||||
|
>
|
||||||
|
zip_it_begin(
|
||||||
|
ZI_MAKE_TUPLE(
|
||||||
|
vect1.begin(),
|
||||||
|
vect2.begin()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
boost::zip_iterator<
|
||||||
|
ZI_TUPLE<
|
||||||
|
std::vector<double>::const_iterator,
|
||||||
|
std::vector<double>::const_iterator
|
||||||
|
>
|
||||||
|
>
|
||||||
|
zip_it_run(
|
||||||
|
ZI_MAKE_TUPLE(
|
||||||
|
vect1.begin(),
|
||||||
|
vect2.begin()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
boost::zip_iterator<
|
||||||
|
ZI_TUPLE<
|
||||||
|
std::vector<double>::const_iterator,
|
||||||
|
std::vector<double>::const_iterator
|
||||||
|
>
|
||||||
|
>
|
||||||
|
zip_it_end(
|
||||||
|
ZI_MAKE_TUPLE(
|
||||||
|
vect1.end(),
|
||||||
|
vect2.end()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if( zip_it_run == zip_it_begin &&
|
||||||
|
42. == ZI_TUPLE_GET(0)(*zip_it_run) &&
|
||||||
|
2.2 == ZI_TUPLE_GET(1)(*zip_it_run) &&
|
||||||
|
43. == ZI_TUPLE_GET(0)(*(++zip_it_run)) &&
|
||||||
|
3.3 == ZI_TUPLE_GET(1)(*zip_it_run) &&
|
||||||
|
44. == ZI_TUPLE_GET(0)(*(++zip_it_run)) &&
|
||||||
|
4.4 == ZI_TUPLE_GET(1)(*zip_it_run) &&
|
||||||
|
zip_it_end == ++zip_it_run
|
||||||
|
)
|
||||||
|
{
|
||||||
|
++num_successful_tests;
|
||||||
|
std::cout << "OK" << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
++num_failed_tests;
|
||||||
|
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. == ZI_TUPLE_GET(0)(*zip_it_run) &&
|
||||||
|
4.4 == ZI_TUPLE_GET(1)(*zip_it_run) &&
|
||||||
|
43. == ZI_TUPLE_GET(0)(*(--zip_it_run)) &&
|
||||||
|
3.3 == ZI_TUPLE_GET(1)(*zip_it_run) &&
|
||||||
|
42. == ZI_TUPLE_GET(0)(*(--zip_it_run)) &&
|
||||||
|
2.2 == ZI_TUPLE_GET(1)(*zip_it_run) &&
|
||||||
|
zip_it_begin == zip_it_run
|
||||||
|
)
|
||||||
|
{
|
||||||
|
++num_successful_tests;
|
||||||
|
std::cout << "OK" << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
++num_failed_tests;
|
||||||
|
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<
|
||||||
|
ZI_TUPLE<
|
||||||
|
std::vector<double>::const_iterator,
|
||||||
|
std::vector<double>::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;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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( ZI_TUPLE_GET(0)(zip_it_run.get_iterator_tuple()) == vect1.begin() + 1 &&
|
||||||
|
ZI_TUPLE_GET(1)(zip_it_run.get_iterator_tuple()) == vect2.begin() + 1
|
||||||
|
)
|
||||||
|
{
|
||||||
|
++num_successful_tests;
|
||||||
|
std::cout << "OK" << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
++num_failed_tests;
|
||||||
|
std::cout << "not OK" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Making zip iterators
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
std::cout << "Making zip iterators: "
|
||||||
|
<< std::flush;
|
||||||
|
|
||||||
|
std::vector<ZI_TUPLE<double, double> >
|
||||||
|
vect_of_tuples(3);
|
||||||
|
|
||||||
|
std::copy(
|
||||||
|
boost::make_zip_iterator(
|
||||||
|
ZI_MAKE_TUPLE(
|
||||||
|
vect1.begin(),
|
||||||
|
vect2.begin()
|
||||||
|
)
|
||||||
|
),
|
||||||
|
boost::make_zip_iterator(
|
||||||
|
ZI_MAKE_TUPLE(
|
||||||
|
vect1.end(),
|
||||||
|
vect2.end()
|
||||||
|
)
|
||||||
|
),
|
||||||
|
vect_of_tuples.begin()
|
||||||
|
);
|
||||||
|
|
||||||
|
if( 42. == ZI_TUPLE_GET(0)(*vect_of_tuples.begin()) &&
|
||||||
|
2.2 == ZI_TUPLE_GET(1)(*vect_of_tuples.begin()) &&
|
||||||
|
43. == ZI_TUPLE_GET(0)(*(vect_of_tuples.begin() + 1)) &&
|
||||||
|
3.3 == ZI_TUPLE_GET(1)(*(vect_of_tuples.begin() + 1)) &&
|
||||||
|
44. == ZI_TUPLE_GET(0)(*(vect_of_tuples.begin() + 2)) &&
|
||||||
|
4.4 == ZI_TUPLE_GET(1)(*(vect_of_tuples.begin() + 2))
|
||||||
|
)
|
||||||
|
{
|
||||||
|
++num_successful_tests;
|
||||||
|
std::cout << "OK" << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
++num_failed_tests;
|
||||||
|
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<
|
||||||
|
ZI_TUPLE<
|
||||||
|
std::set<int>::const_iterator,
|
||||||
|
std::vector<double>::const_iterator
|
||||||
|
>
|
||||||
|
>
|
||||||
|
zip_it_const(
|
||||||
|
ZI_MAKE_TUPLE(
|
||||||
|
intset.begin(),
|
||||||
|
vect2.begin()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
//
|
||||||
|
boost::zip_iterator<
|
||||||
|
ZI_TUPLE<
|
||||||
|
std::set<int>::iterator,
|
||||||
|
std::vector<double>::const_iterator
|
||||||
|
>
|
||||||
|
>
|
||||||
|
zip_it_half_const(
|
||||||
|
ZI_MAKE_TUPLE(
|
||||||
|
intset.begin(),
|
||||||
|
vect2.begin()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
//
|
||||||
|
boost::zip_iterator<
|
||||||
|
ZI_TUPLE<
|
||||||
|
std::set<int>::iterator,
|
||||||
|
std::vector<double>::iterator
|
||||||
|
>
|
||||||
|
>
|
||||||
|
zip_it_non_const(
|
||||||
|
ZI_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 == ZI_TUPLE_GET(0)(*zip_it_const) &&
|
||||||
|
4.4 == ZI_TUPLE_GET(1)(*zip_it_const) &&
|
||||||
|
53 == ZI_TUPLE_GET(0)(*zip_it_half_const) &&
|
||||||
|
3.3 == ZI_TUPLE_GET(1)(*zip_it_half_const)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
++num_successful_tests;
|
||||||
|
std::cout << "OK" << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
++num_failed_tests;
|
||||||
|
std::cout << "not OK" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(ZI_USE_BOOST_TUPLE)
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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<zip_it_12_type>::type
|
||||||
|
, boost::bidirectional_traversal_tag
|
||||||
|
>::value;
|
||||||
|
|
||||||
|
bool bBigItIsRandomAccessIterator = boost::is_convertible<
|
||||||
|
boost::iterator_traversal<zip_it_12_type>::type
|
||||||
|
, boost::random_access_traversal_tag
|
||||||
|
>::value;
|
||||||
|
|
||||||
|
// A combining iterator with all vector iterators must have random access
|
||||||
|
// traversal.
|
||||||
|
//
|
||||||
|
typedef boost::zip_iterator<
|
||||||
|
ZI_TUPLE<
|
||||||
|
std::vector<double>::const_iterator,
|
||||||
|
std::vector<double>::const_iterator
|
||||||
|
>
|
||||||
|
> all_vects_type;
|
||||||
|
|
||||||
|
bool bAllVectsIsRandomAccessIterator = boost::is_convertible<
|
||||||
|
boost::iterator_traversal<all_vects_type>::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;
|
||||||
|
std::cout << "not OK" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Done
|
||||||
|
//
|
||||||
|
std::cout << "\nTest Result:"
|
||||||
|
<< "\n============"
|
||||||
|
<< "\nNumber of successful tests: " << static_cast<unsigned int>(num_successful_tests)
|
||||||
|
<< "\nNumber of failed tests: " << static_cast<unsigned int>(num_failed_tests)
|
||||||
|
<< std::endl;
|
||||||
|
|
||||||
|
return num_failed_tests;
|
||||||
|
}
|
||||||
|
|
@ -32,6 +32,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
#if !defined(__SGI_STL_PORT) \
|
#if !defined(__SGI_STL_PORT) \
|
||||||
&& (defined(BOOST_MSVC_STD_ITERATOR) \
|
&& (defined(BOOST_MSVC_STD_ITERATOR) \
|
||||||
@ -164,7 +165,7 @@ main()
|
|||||||
|
|
||||||
BOOST_STATIC_ASSERT(
|
BOOST_STATIC_ASSERT(
|
||||||
has_element_type<
|
has_element_type<
|
||||||
boost::detail::iterator_traits<shared_t::iterator>::value_type
|
std::iterator_traits<shared_t::iterator>::value_type
|
||||||
>::value
|
>::value
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,850 +1,8 @@
|
|||||||
// (C) Copyright Dave Abrahams and Thomas Becker 2003. Distributed
|
|
||||||
// under 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)
|
|
||||||
//
|
|
||||||
|
|
||||||
// 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 <boost/iterator/zip_iterator.hpp>
|
|
||||||
#include <boost/iterator/zip_iterator.hpp> // 2nd #include tests #include guard.
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
#include <list>
|
|
||||||
#include <set>
|
|
||||||
#include <string>
|
|
||||||
#include <functional>
|
|
||||||
#include <boost/tuple/tuple.hpp>
|
#include <boost/tuple/tuple.hpp>
|
||||||
#include <boost/iterator/transform_iterator.hpp>
|
|
||||||
#include <boost/iterator/is_readable_iterator.hpp>
|
|
||||||
#include <boost/type_traits/is_same.hpp>
|
|
||||||
#include <boost/detail/workaround.hpp>
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
|
#define ZI_TUPLE boost::tuples::tuple
|
||||||
|
#define ZI_MAKE_TUPLE boost::make_tuple
|
||||||
|
#define ZI_TUPLE_GET(n) boost::tuples::get<n>
|
||||||
|
#define ZI_USE_BOOST_TUPLE
|
||||||
|
|
||||||
/// Tests for https://svn.boost.org/trac/boost/ticket/1517
|
#include "detail/zip_iterator_test_original.ipp"
|
||||||
int to_value(int const &v)
|
|
||||||
{
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
void category_test()
|
|
||||||
{
|
|
||||||
std::list<int> rng1;
|
|
||||||
std::string rng2;
|
|
||||||
|
|
||||||
boost::make_zip_iterator(
|
|
||||||
boost::make_tuple(
|
|
||||||
boost::make_transform_iterator(rng1.begin(), &to_value), // BidirectionalInput
|
|
||||||
rng2.begin() // RandomAccess
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
///
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Das Main Funktion
|
|
||||||
//
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
int main( void )
|
|
||||||
{
|
|
||||||
|
|
||||||
category_test();
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Zip iterator construction and dereferencing
|
|
||||||
//
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
std::cout << "Zip iterator construction and dereferencing: "
|
|
||||||
<< std::flush;
|
|
||||||
|
|
||||||
std::vector<double> vect1(3);
|
|
||||||
vect1[0] = 42.;
|
|
||||||
vect1[1] = 43.;
|
|
||||||
vect1[2] = 44.;
|
|
||||||
|
|
||||||
std::set<int> intset;
|
|
||||||
intset.insert(52);
|
|
||||||
intset.insert(53);
|
|
||||||
intset.insert(54);
|
|
||||||
//
|
|
||||||
|
|
||||||
typedef
|
|
||||||
boost::zip_iterator<
|
|
||||||
boost::tuples::tuple<
|
|
||||||
std::set<int>::iterator
|
|
||||||
, std::vector<double>::iterator
|
|
||||||
>
|
|
||||||
> zit_mixed;
|
|
||||||
|
|
||||||
zit_mixed zip_it_mixed = zit_mixed(
|
|
||||||
boost::make_tuple(
|
|
||||||
intset.begin()
|
|
||||||
, vect1.begin()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
boost::tuples::tuple<int, double> val_tuple(
|
|
||||||
*zip_it_mixed);
|
|
||||||
|
|
||||||
boost::tuples::tuple<const int&, double&> 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<int> li1;
|
|
||||||
li1.push_back(1);
|
|
||||||
std::set<int> se1;
|
|
||||||
se1.insert(2);
|
|
||||||
std::vector<int> ve1;
|
|
||||||
ve1.push_back(3);
|
|
||||||
//
|
|
||||||
std::list<int> li2;
|
|
||||||
li2.push_back(4);
|
|
||||||
std::set<int> se2;
|
|
||||||
se2.insert(5);
|
|
||||||
std::vector<int> ve2;
|
|
||||||
ve2.push_back(6);
|
|
||||||
//
|
|
||||||
std::list<int> li3;
|
|
||||||
li3.push_back(7);
|
|
||||||
std::set<int> se3;
|
|
||||||
se3.insert(8);
|
|
||||||
std::vector<int> ve3;
|
|
||||||
ve3.push_back(9);
|
|
||||||
//
|
|
||||||
std::list<int> li4;
|
|
||||||
li4.push_back(10);
|
|
||||||
std::set<int> se4;
|
|
||||||
se4.insert(11);
|
|
||||||
std::vector<int> ve4;
|
|
||||||
ve4.push_back(12);
|
|
||||||
|
|
||||||
// typedefs for cons lists of iterators.
|
|
||||||
typedef boost::tuples::cons<
|
|
||||||
std::set<int>::iterator,
|
|
||||||
boost::tuples::tuple<
|
|
||||||
std::vector<int>::iterator,
|
|
||||||
std::list<int>::iterator,
|
|
||||||
std::set<int>::iterator,
|
|
||||||
std::vector<int>::iterator,
|
|
||||||
std::list<int>::iterator,
|
|
||||||
std::set<int>::iterator,
|
|
||||||
std::vector<int>::iterator,
|
|
||||||
std::list<int>::iterator,
|
|
||||||
std::set<int>::iterator,
|
|
||||||
std::vector<int>::const_iterator
|
|
||||||
>::inherited
|
|
||||||
> cons_11_its_type;
|
|
||||||
//
|
|
||||||
typedef boost::tuples::cons<
|
|
||||||
std::list<int>::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<cons_12_its_type> 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<double> vect2(3);
|
|
||||||
vect2[0] = 2.2;
|
|
||||||
vect2[1] = 3.3;
|
|
||||||
vect2[2] = 4.4;
|
|
||||||
|
|
||||||
boost::zip_iterator<
|
|
||||||
boost::tuples::tuple<
|
|
||||||
std::vector<double>::const_iterator,
|
|
||||||
std::vector<double>::const_iterator
|
|
||||||
>
|
|
||||||
>
|
|
||||||
zip_it_begin(
|
|
||||||
boost::make_tuple(
|
|
||||||
vect1.begin(),
|
|
||||||
vect2.begin()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
boost::zip_iterator<
|
|
||||||
boost::tuples::tuple<
|
|
||||||
std::vector<double>::const_iterator,
|
|
||||||
std::vector<double>::const_iterator
|
|
||||||
>
|
|
||||||
>
|
|
||||||
zip_it_run(
|
|
||||||
boost::make_tuple(
|
|
||||||
vect1.begin(),
|
|
||||||
vect2.begin()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
boost::zip_iterator<
|
|
||||||
boost::tuples::tuple<
|
|
||||||
std::vector<double>::const_iterator,
|
|
||||||
std::vector<double>::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<double>::const_iterator,
|
|
||||||
std::vector<double>::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<boost::tuples::tuple<double, double> >
|
|
||||||
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<int>::const_iterator,
|
|
||||||
std::vector<double>::const_iterator
|
|
||||||
>
|
|
||||||
>
|
|
||||||
zip_it_const(
|
|
||||||
boost::make_tuple(
|
|
||||||
intset.begin(),
|
|
||||||
vect2.begin()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
//
|
|
||||||
boost::zip_iterator<
|
|
||||||
boost::tuples::tuple<
|
|
||||||
std::set<int>::iterator,
|
|
||||||
std::vector<double>::const_iterator
|
|
||||||
>
|
|
||||||
>
|
|
||||||
zip_it_half_const(
|
|
||||||
boost::make_tuple(
|
|
||||||
intset.begin(),
|
|
||||||
vect2.begin()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
//
|
|
||||||
boost::zip_iterator<
|
|
||||||
boost::tuples::tuple<
|
|
||||||
std::set<int>::iterator,
|
|
||||||
std::vector<double>::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<zip_it_12_type>::type
|
|
||||||
, boost::bidirectional_traversal_tag
|
|
||||||
>::value;
|
|
||||||
|
|
||||||
bool bBigItIsRandomAccessIterator = boost::is_convertible<
|
|
||||||
boost::iterator_traversal<zip_it_12_type>::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<double>::const_iterator,
|
|
||||||
std::vector<double>::const_iterator
|
|
||||||
>
|
|
||||||
> all_vects_type;
|
|
||||||
|
|
||||||
bool bAllVectsIsRandomAccessIterator = boost::is_convertible<
|
|
||||||
boost::iterator_traversal<all_vects_type>::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<unsigned int>(num_successful_tests)
|
|
||||||
<< "\nNumber of failed tests: " << static_cast<unsigned int>(num_failed_tests)
|
|
||||||
<< std::endl;
|
|
||||||
|
|
||||||
return num_failed_tests;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
9
test/zip_iterator_test2_fusion_deque.cpp
Normal file
9
test/zip_iterator_test2_fusion_deque.cpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#include <boost/fusion/include/deque.hpp>
|
||||||
|
#include <boost/fusion/include/make_deque.hpp>
|
||||||
|
#include <boost/fusion/sequence/intrinsic/at_c.hpp>
|
||||||
|
|
||||||
|
#define ZI_TUPLE boost::fusion::deque
|
||||||
|
#define ZI_MAKE_TUPLE boost::fusion::make_deque
|
||||||
|
#define ZI_TUPLE_GET(n) boost::fusion::at_c<n>
|
||||||
|
|
||||||
|
#include "detail/zip_iterator_test_original.ipp"
|
11
test/zip_iterator_test2_fusion_list.cpp
Normal file
11
test/zip_iterator_test2_fusion_list.cpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
|
#include <boost/fusion/include/list.hpp>
|
||||||
|
#include <boost/fusion/include/make_list.hpp>
|
||||||
|
#include <boost/fusion/sequence/intrinsic/at_c.hpp>
|
||||||
|
|
||||||
|
#define ZI_TUPLE boost::fusion::list
|
||||||
|
#define ZI_MAKE_TUPLE boost::fusion::make_list
|
||||||
|
#define ZI_TUPLE_GET(n) boost::fusion::at_c<n>
|
||||||
|
|
||||||
|
#include "detail/zip_iterator_test_original.ipp"
|
11
test/zip_iterator_test2_fusion_vector.cpp
Normal file
11
test/zip_iterator_test2_fusion_vector.cpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
|
#include <boost/fusion/include/vector.hpp>
|
||||||
|
#include <boost/fusion/include/make_vector.hpp>
|
||||||
|
#include <boost/fusion/sequence/intrinsic/at_c.hpp>
|
||||||
|
|
||||||
|
#define ZI_TUPLE boost::fusion::vector
|
||||||
|
#define ZI_MAKE_TUPLE boost::fusion::make_vector
|
||||||
|
#define ZI_TUPLE_GET(n) boost::fusion::at_c<n>
|
||||||
|
|
||||||
|
#include "detail/zip_iterator_test_original.ipp"
|
21
test/zip_iterator_test2_std_tuple.cpp
Normal file
21
test/zip_iterator_test2_std_tuple.cpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||||
|
|
||||||
|
#include <tuple>
|
||||||
|
#include <boost/fusion/adapted/std_tuple.hpp>
|
||||||
|
|
||||||
|
#define ZI_TUPLE std::tuple
|
||||||
|
#define ZI_MAKE_TUPLE std::make_tuple
|
||||||
|
#define ZI_TUPLE_GET(n) std::get<n>
|
||||||
|
|
||||||
|
#include "detail/zip_iterator_test_original.ipp"
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
15
test/zip_iterator_test_fusion.cpp
Normal file
15
test/zip_iterator_test_fusion.cpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// Copyright (c) 2014 Kohei Takahashi.
|
||||||
|
//
|
||||||
|
// Distributed under 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)
|
||||||
|
//
|
||||||
|
// See http://www.boost.org for most recent version including documentation.
|
||||||
|
|
||||||
|
#include <boost/fusion/include/vector.hpp>
|
||||||
|
#include <boost/fusion/include/make_vector.hpp>
|
||||||
|
|
||||||
|
#define TUPLE boost::fusion::vector
|
||||||
|
#define MAKE_TUPLE boost::fusion::make_vector
|
||||||
|
|
||||||
|
#include "detail/zip_iterator_test.ipp"
|
16
test/zip_iterator_test_std_pair.cpp
Normal file
16
test/zip_iterator_test_std_pair.cpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// Copyright (c) 2014 Kohei Takahashi.
|
||||||
|
//
|
||||||
|
// Distributed under 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)
|
||||||
|
//
|
||||||
|
// See http://www.boost.org for most recent version including documentation.
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
#include <boost/fusion/adapted/std_pair.hpp>
|
||||||
|
|
||||||
|
#define TUPLE std::pair
|
||||||
|
#define MAKE_TUPLE std::make_pair
|
||||||
|
|
||||||
|
#include "detail/zip_iterator_test.ipp"
|
||||||
|
|
29
test/zip_iterator_test_std_tuple.cpp
Normal file
29
test/zip_iterator_test_std_tuple.cpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright (c) 2014 Kohei Takahashi.
|
||||||
|
//
|
||||||
|
// Distributed under 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)
|
||||||
|
//
|
||||||
|
// See http://www.boost.org for most recent version including documentation.
|
||||||
|
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||||
|
|
||||||
|
#include <tuple>
|
||||||
|
#include <boost/fusion/adapted/std_tuple.hpp>
|
||||||
|
|
||||||
|
#define TUPLE std::tuple
|
||||||
|
#define MAKE_TUPLE std::make_tuple
|
||||||
|
|
||||||
|
#include "detail/zip_iterator_test.ipp"
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Reference in New Issue
Block a user