Compare commits

..

120 Commits

Author SHA1 Message Date
1ef8189af4 make it work with fusion
[SVN r32949]
2006-02-16 06:23:06 +00:00
f3671a6422 This commit was manufactured by cvs2svn to create branch
'zip_iterator_fusion'.

[SVN r30672]
2005-08-25 16:27:30 +00:00
ae45f7abf7 Large patch from Ulrich Eckhardt to fix support for EVC++ 4.
[SVN r30670]
2005-08-25 16:27:28 +00:00
6363297754 Merged from 1.33.0 release
[SVN r30540]
2005-08-12 13:02:37 +00:00
55fd9078a1 Renamed to avoid >31 char filename.
[SVN r30088]
2005-07-14 21:10:07 +00:00
e22bb495db vc6-stlport workaround
[SVN r29795]
2005-06-26 13:21:09 +00:00
54ae365c98 Further generalized vc6 workaround
[SVN r29788]
2005-06-24 18:47:21 +00:00
a9483b5633 Kill off vc6/stlport error more generally and more specifically
[SVN r29786]
2005-06-24 18:34:17 +00:00
65fe75e558 Workarounds for Borland
Improved assertion output


[SVN r29779]
2005-06-24 15:37:23 +00:00
7a43350655 Avoid some Borland bugs by defining operators explicitly rather than
using partially_ordered<...> to generate them.


[SVN r29757]
2005-06-23 18:20:37 +00:00
df49ae74e0 Define BOOST_NO_LVALUE_RETURN_DETECTION for Tru64/CXX-6.5.
[SVN r29545]
2005-06-13 08:22:38 +00:00
3fe9b7517e updated docs
[SVN r29099]
2005-05-20 15:32:55 +00:00
ab372a0a74 Added failing test for missing #include guard, then fixed it.
[SVN r28459]
2005-04-24 11:48:23 +00:00
f9c4915b55 Sync with V1
[SVN r28241]
2005-04-14 11:37:17 +00:00
741da59c0d Link to documentation added.
[SVN r27745]
2005-03-20 14:53:58 +00:00
a0b28e4c8b Fix for indirect iterators to abstract classes.
[SVN r27625]
2005-03-12 23:10:43 +00:00
ef895f0cc7 Apply typo fixes from Julio M. Merino Vidal
[SVN r27513]
2005-02-27 17:28:24 +00:00
1d018cc602 Borland workaround. Replace 'add_const<value_type>::type with
'const value_type' in the code which computed the pointer type. Borland
did not property add const type with 'add_const'.


[SVN r27388]
2005-02-15 12:41:23 +00:00
88697aad65 merge from RC_1_32_0 branch
[SVN r26942]
2005-01-30 21:36:16 +00:00
7344357e32 merge changes from RC_1_32_0
[SVN r26891]
2005-01-28 07:42:05 +00:00
80501e1eb2 merge changes from RC_1_32_0
[SVN r26888]
2005-01-28 07:34:17 +00:00
7707262a07 base_type patch from Eric Niebler
[SVN r26818]
2005-01-23 15:40:15 +00:00
ba3e7a459e Allow for bidirectional filtered_iterators
[SVN r26491]
2004-12-13 09:31:17 +00:00
295ae05e40 Fix the problems described in this thread:
http://lists.boost.org/MailArchives/boost-users/msg08656.php


[SVN r26410]
2004-12-03 09:55:30 +00:00
68268f81eb Stop relying on T(x) to do implicit conversion; it *casts* when T is a builtin!
[SVN r26393]
2004-12-01 16:46:06 +00:00
3b60f75bc6 Stop reserving rights.
[SVN r26085]
2004-11-02 14:31:27 +00:00
a8f528130a Stop reserving rights.
[SVN r26067]
2004-11-01 21:23:47 +00:00
c0788f2cd8 kill dead reference
[SVN r26015]
2004-10-31 12:38:45 +00:00
c6bc3b2547 added copyrights
[SVN r25810]
2004-10-20 13:20:19 +00:00
27adbbb6ed c++boost.gif -> boost.png replacement
[SVN r25573]
2004-10-05 15:45:52 +00:00
1f999864a1 Fix 31 character limit
[SVN r25193]
2004-09-18 13:32:24 +00:00
65af4c96a9 Move indirect_traits to boost/detail
[SVN r25117]
2004-09-15 15:00:12 +00:00
aa9e49b727 Fix >31 character filenames
[SVN r25040]
2004-09-13 14:39:59 +00:00
3318c82f83 Copyright
[SVN r25037]
2004-09-13 13:31:33 +00:00
68791c337a Remove GPL'd material
[SVN r25036]
2004-09-13 13:30:33 +00:00
a396085bc0 Added new types boost::long_long_type and boost::ulong_long_type in boost/config.hpp and applied these types in place of "long long" throughout. As a result, almost all of boost now compiles cleanly with -ansi -pedantic with gcc. Changes tested with gcc 3.3, 2.95, VC7.1 and Intel 8.
[SVN r24899]
2004-09-04 10:34:49 +00:00
6196a6e591 merge new MPL version from 'mplbook' branch
[SVN r24874]
2004-09-02 15:41:37 +00:00
4e07575b78 Update tests for fixed postfix increment
[SVN r24617]
2004-08-20 16:04:11 +00:00
557ef60557 Converted files to the BSL.
[SVN r24614]
2004-08-20 11:10:24 +00:00
4b583d3aa0 License update
[SVN r24598]
2004-08-19 15:23:47 +00:00
3eca5e8f60 License updates
[SVN r24597]
2004-08-19 15:19:17 +00:00
5947d569b9 License update
[SVN r24596]
2004-08-19 15:11:49 +00:00
e469abbf57 Work around an MSVC-stlport ICE
[SVN r24567]
2004-08-18 19:00:18 +00:00
c141f6cc59 obsolete
[SVN r24508]
2004-08-16 14:24:49 +00:00
55f8a6380a Moved to BSL
[SVN r24446]
2004-08-12 17:13:07 +00:00
9c955e8af2 Moved to BSL
[SVN r24445]
2004-08-12 17:02:24 +00:00
82108581b9 Make sure that X(r++) works for writable iterators.
[SVN r24420]
2004-08-11 19:54:40 +00:00
c4834d363e More (C).
[SVN r24383]
2004-08-10 15:12:53 +00:00
7194aff64c Fixed license added (only) my (C).
[SVN r24379]
2004-08-10 14:44:17 +00:00
ca41a4f902 Fixed (C) and license.
[SVN r24378]
2004-08-10 14:41:52 +00:00
47a3392c80 Removed Boost.org copyrights and replaced with originating authors copyright instead.
[SVN r24372]
2004-08-10 12:53:34 +00:00
bd765a21fb Eliminated unreviewed, unused, noncompiling code
[SVN r24314]
2004-08-05 18:57:39 +00:00
cad110e0f3 aCC workaround from From: "DY, JERRY U \(SBCSI\)" <jd2419-at-sbc.com>
[SVN r24254]
2004-08-03 00:38:26 +00:00
3599398eca Workaround CW8 issues with using static_cast on templates with template ctors.
[SVN r24214]
2004-07-31 22:56:49 +00:00
dd72d599c8 Disable interop properly for vc6/7 using known SFINAE capabilities.
[SVN r24209]
2004-07-31 18:10:00 +00:00
1a9677d9dc Stop support CW7; workaround for aCC
[SVN r24191]
2004-07-30 16:36:36 +00:00
a6d200f262 Converted to Boost Software License, Version 1.0
[SVN r24055]
2004-07-26 00:32:12 +00:00
0c28649d0b Remove tabs in file.
[SVN r24043]
2004-07-25 17:12:17 +00:00
d6405ddd54 Fix license
[SVN r24034]
2004-07-25 14:24:27 +00:00
700db48ac7 add nested typedefs
[SVN r23644]
2004-07-16 19:58:03 +00:00
2241bb1ae3 A few fixes
[SVN r23542]
2004-07-14 12:33:36 +00:00
539add7de6 Made what I thought were the right fixes
[SVN r23519]
2004-07-14 01:19:14 +00:00
edb7528136 Only use proxy for *r++ if *r is also a proxy.
[SVN r23516]
2004-07-14 00:40:04 +00:00
254186d6bd added requirement to Forward Traversal Iterator concerning a == b iff *a == *b
[SVN r23513]
2004-07-13 20:19:56 +00:00
aa62f4f9c7 fixed a little buglet in the spec of Incrementable Iterator
[SVN r23511]
2004-07-13 20:06:07 +00:00
f0bc339d55 change Incrementable Iterator reqs to better match those of Input/Output Iterators
[SVN r23510]
2004-07-13 19:50:09 +00:00
2721c3c97e Repair postfix increment proxies for input iterators
[SVN r23508]
2004-07-13 17:23:53 +00:00
f49f68c8fe Fixed postfix increment for incrementable and single-pass iterator facade
[SVN r23456]
2004-07-12 03:18:49 +00:00
02f606816d faster compile (no iostream)
[SVN r23451]
2004-07-12 02:21:35 +00:00
1ffc31cc37 Bugfix
[SVN r23306]
2004-07-01 18:41:47 +00:00
0acc6c38ef Need to include <algorithm> to get std::swap
[SVN r23213]
2004-06-27 18:48:11 +00:00
da1e5aa3e8 Made value_ mutable to enable operator long() const to compile
[SVN r23208]
2004-06-27 15:09:46 +00:00
db0bc36f58 Update
[SVN r23085]
2004-06-11 11:18:50 +00:00
99bafe363c Remove is_xxx dependency.
[SVN r22878]
2004-05-20 15:35:56 +00:00
b310ccda97 Fixed typo
[SVN r22708]
2004-04-29 00:38:46 +00:00
2a9c00f5b2 Work around CW bug; see http://lists.boost.org/MailArchives/boost/msg57316.php.
[SVN r22655]
2004-04-18 12:23:53 +00:00
020d0b8f99 fixed a typop
[SVN r22612]
2004-04-06 15:59:40 +00:00
d21781d8d1 fixed a typo
[SVN r22611]
2004-04-06 15:41:34 +00:00
bed1d7fa7a Incorporated Keith MacDonald's comments
[SVN r22567]
2004-03-30 22:38:47 +00:00
0c3a68530e shared_container_iterator library:
- updated Copyright and License notices
 - Added shared_iterator_test to the iterator test suite.


[SVN r22140]
2004-02-02 22:16:36 +00:00
d3daa47561 Don't allow non-random-access-traversal iterators to be subtracted.
[SVN r22121]
2004-02-01 22:11:47 +00:00
62c993978a unneeded
[SVN r22100]
2004-02-01 04:14:03 +00:00
74f41dcb5b not needed
[SVN r22099]
2004-02-01 04:13:28 +00:00
c8d1461340 Added function_output_iterator and shared_container_iterator to index.
Updated outdated pdfs.


[SVN r22097]
2004-02-01 03:58:49 +00:00
13dcd5590f GCC2 workarounds; fixed permutation_iterator_example
[SVN r22048]
2004-01-29 13:33:33 +00:00
7f125cacb9 roll back mistake
[SVN r22045]
2004-01-29 05:56:47 +00:00
8cf04e1c7b Fixed PDF format as article
Added iterator_traits docs


[SVN r22043]
2004-01-29 05:55:26 +00:00
0122a0c8ec initial commit
[SVN r22041]
2004-01-29 03:44:57 +00:00
09549783cc added lvalue_concept_fail_expected.cpp
[SVN r22019]
2004-01-28 14:05:33 +00:00
273c1d784c new file
[SVN r22018]
2004-01-28 14:04:21 +00:00
a99ab81803 changed LvalueIteratorConcept to really catch errors
[SVN r22017]
2004-01-28 14:01:45 +00:00
0cb4ce54ef No need to test things not related to zip_iterator
[SVN r22012]
2004-01-27 21:24:20 +00:00
0670e05297 improved the abstract
[SVN r22010]
2004-01-27 18:47:31 +00:00
b353d45f2d added boost::ignore_unused_variable_warning(r);
[SVN r22009]
2004-01-27 18:34:00 +00:00
19d339c916 removed ReadableLvalue and WritableLvalue, added Lvalue
[SVN r22005]
2004-01-27 18:14:48 +00:00
506517191c new files for iterator concepts
[SVN r22004]
2004-01-27 17:03:46 +00:00
b502873f00 A few simplifications with the help of Intel tech support
[SVN r21997]
2004-01-27 12:42:59 +00:00
b838d27aa3 HTML updates
[SVN r21990]
2004-01-27 04:13:36 +00:00
17c373ded3 Added zip_iterator docs
[SVN r21988]
2004-01-27 04:12:54 +00:00
09e1cb9a38 Added transform_iterator, zip_iterator, and iterator_archetypes
[SVN r21987]
2004-01-27 04:07:10 +00:00
58288cfb48 Fixed parsed-literal
[SVN r21986]
2004-01-27 04:06:21 +00:00
cd730895ca Added PDF references
[SVN r21985]
2004-01-27 04:05:33 +00:00
2d2a84f8c4 Remove GPL'd material from CVS
[SVN r21984]
2004-01-27 04:04:00 +00:00
4871736269 Added pdfs
[SVN r21983]
2004-01-27 03:53:56 +00:00
fec82e2de8 Fixed interop downcasts
[SVN r21982]
2004-01-27 03:19:34 +00:00
a5b14e1a4f Remove copyright
[SVN r21981]
2004-01-27 03:17:30 +00:00
8480d452a9 vc6 ICE workarounds,
General simplification for compilers that don't support strict
interop.

Renamed "minus" -> "distance_from".


[SVN r21973]
2004-01-26 14:52:39 +00:00
5f870d780d vc6 linker workarounds
[SVN r21896]
2004-01-24 18:28:48 +00:00
010f715950 Borland workarounds
[SVN r21893]
2004-01-24 17:39:45 +00:00
020f2ab867 untabified
[SVN r21890]
2004-01-24 16:14:46 +00:00
2071230859 split constructor into two
[SVN r21863]
2004-01-21 16:26:04 +00:00
413d0b01cf added default constructor stuff to 9.31
[SVN r21862]
2004-01-21 16:25:41 +00:00
4abd97910d split the one constructor into two
[SVN r21861]
2004-01-21 16:20:39 +00:00
564ed3ed88 added a typo to 9.45
[SVN r21860]
2004-01-21 16:02:56 +00:00
c90814e515 removed mention of projection_iterator
[SVN r21859]
2004-01-21 15:58:29 +00:00
576395a469 added stuff about reference
[SVN r21858]
2004-01-21 14:24:50 +00:00
f75a60e074 #if def'd out the test on a writable base iterator
[SVN r21851]
2004-01-21 03:56:49 +00:00
3e5f366f4f added missing reverse_iterator wrapping of Iter
[SVN r21850]
2004-01-21 03:28:25 +00:00
a456f8d969 Workaround GCC2 eager instantiation bug.
[SVN r21847]
2004-01-20 19:40:50 +00:00
cfe17e7fe5 GCC2 workaround
[SVN r21846]
2004-01-20 19:38:54 +00:00
3 changed files with 1189 additions and 68 deletions

View File

@ -0,0 +1,353 @@
// (C) Copyright David Abrahams and Thomas Becker 2000. Permission to
// copy, use, modify, sell and distribute this software is granted
// provided this copyright notice appears in all copies. This software
// is provided "as is" without express or implied warranty, and with
// no claim as to its suitability for any purpose.
//
// Compilers Tested:
// =================
// Metrowerks Codewarrior Pro 7.2, 8.3
// gcc 2.95.3
// gcc 3.2
// Microsoft VC 6sp5 (test fails due to some compiler bug)
// Microsoft VC 7 (works)
// Microsoft VC 7.1
// Intel 5
// Intel 6
// Intel 7.1
// Intel 8
// Borland 5.5.1 (broken due to lack of support from Boost.Tuples)
#ifndef BOOST_ZIP_ITERATOR_TMB_07_13_2003_HPP_
# define BOOST_ZIP_ITERATOR_TMB_07_13_2003_HPP_
#include <stddef.h>
#include <boost/iterator.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/iterator/iterator_adaptor.hpp> // for enable_if_convertible
#include <boost/iterator/iterator_categories.hpp>
#include <boost/detail/iterator.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <boost/iterator/detail/minimum_category.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/lambda.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/mpl/aux_/lambda_support.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/fold.hpp>
#include <boost/mpl/transform.hpp>
#include <boost/spirit/fusion/algorithm/transform.hpp>
#include <boost/spirit/fusion/algorithm/for_each.hpp>
#include <boost/spirit/fusion/algorithm/fold.hpp>
#include <boost/spirit/fusion/sequence/generate.hpp>
#include <boost/spirit/fusion/sequence/begin.hpp>
#include <boost/spirit/fusion/algorithm/push_front.hpp>
#include <boost/spirit/fusion/sequence/equal_to.hpp>
namespace boost {
// Zip iterator forward declaration for zip_iterator_base
template<typename IteratorTuple>
class zip_iterator;
namespace detail
{
// Functors to be used with tuple algorithms
//
template<typename DiffType>
class advance_iterator
{
public:
advance_iterator(DiffType step) : m_step(step) {}
template<typename Iterator>
void operator()(Iterator& it) const
{ it += m_step; }
private:
DiffType m_step;
};
//
struct increment_iterator
{
template<typename Iterator>
void operator()(Iterator& it) const
{ ++it; }
};
//
struct decrement_iterator
{
template<typename Iterator>
void operator()(Iterator& it) const
{ --it; }
};
//
struct dereference_iterator
{
template<typename Iterator>
struct apply : iterator_reference<Iterator>
{};
template<typename Iterator>
typename apply<Iterator>::type
operator()(Iterator const& it) const
{ return *it; }
};
struct dereference
{
template <class Iterator>
struct apply
: boost::iterator_reference<Iterator>
{};
template <class Iterator>
typename apply<Iterator>::type operator()(Iterator const& x) const
{
return *x;
}
};
// Metafunction to obtain the type of the tuple whose element types
// are the reference types of an iterator tuple.
//
template<typename IteratorTuple>
struct tuple_of_references
: mpl::transform<IteratorTuple, dereference::apply<mpl::_1> >
{};
// Metafunction to obtain the minimal traversal tag in a tuple
// of iterators.
//
template<typename IteratorTuple>
struct minimum_traversal_category_in_iterator_tuple
: mpl::fold<
typename mpl::transform<
IteratorTuple, iterator_traversal<>
>::type
, random_access_traversal_tag
, minimum_category<>
>
{};
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) // ETI workaround
template <>
struct minimum_traversal_category_in_iterator_tuple<int>
{
typedef int type;
};
#endif
// We need to call tuple_meta_accumulate with mpl::and_ as the
// accumulating functor. To this end, we need to wrap it into
// a struct that has exactly two arguments (that is, template
// parameters) and not five, like mpl::and_ does.
//
template<typename Arg1, typename Arg2>
struct and_with_two_args
: mpl::and_<Arg1, Arg2>
{
};
# ifdef BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT
// Hack because BOOST_MPL_AUX_LAMBDA_SUPPORT doesn't seem to work
// out well. In this case I think it's an MPL bug
template<>
struct and_with_two_args<mpl::_1,mpl::_2>
{
template <class A1, class A2>
struct apply : mpl::and_<A1,A2>
{};
};
# endif
///////////////////////////////////////////////////////////////////
//
// Class zip_iterator_base
//
// Builds and exposes the iterator facade type from which the zip
// iterator will be derived.
//
template<typename IteratorTuple>
struct zip_iterator_base
{
private:
// Reference type is the type of the tuple obtained from the
// iterators' reference types.
typedef typename
detail::tuple_of_references<IteratorTuple>::type reference;
// Value type is the same as reference type.
typedef reference value_type;
// Difference type is the first iterator's difference type
typedef typename iterator_traits<
typename mpl::front<IteratorTuple>::type
>::difference_type difference_type;
// Traversal catetgory is the minimum traversal category in the
// iterator tuple.
typedef typename
detail::minimum_traversal_category_in_iterator_tuple<
IteratorTuple
>::type traversal_category;
public:
// The iterator facade type from which the zip iterator will
// be derived.
typedef iterator_facade<
zip_iterator<IteratorTuple>,
value_type,
traversal_category,
reference,
difference_type
> type;
};
template <>
struct zip_iterator_base<int>
{
typedef int type;
};
}
/////////////////////////////////////////////////////////////////////
//
// zip_iterator class definition
//
template<typename IteratorTuple>
class zip_iterator :
public detail::zip_iterator_base<IteratorTuple>::type
{
// Typedef super_t as our base class.
typedef typename
detail::zip_iterator_base<IteratorTuple>::type super_t;
// iterator_core_access is the iterator's best friend.
friend class iterator_core_access;
public:
// Construction
// ============
// Default constructor
zip_iterator() { }
// Constructor from iterator tuple
zip_iterator(IteratorTuple iterator_tuple)
: m_iterator_tuple(iterator_tuple)
{ }
// Copy constructor
template<typename OtherIteratorTuple>
zip_iterator(
const zip_iterator<OtherIteratorTuple>& other,
typename enable_if_convertible<
OtherIteratorTuple,
IteratorTuple
>::type* = 0
) : m_iterator_tuple(other.get_iterator_tuple())
{}
// Get method for the iterator tuple.
const IteratorTuple& get_iterator_tuple() const
{ return m_iterator_tuple; }
private:
// Implementation of Iterator Operations
// =====================================
// Dereferencing returns a tuple built from the dereferenced
// iterators in the iterator tuple.
typename super_t::reference dereference() const
{
return fusion::generate(fusion::transform(
get_iterator_tuple(),
detail::dereference_iterator()
));
}
// Two zip iterators are equal if all iterators in the iterator
// tuple are equal. NOTE: It should be possible to implement this
// as
//
// return get_iterator_tuple() == other.get_iterator_tuple();
//
// but equality of tuples currently (7/2003) does not compile
// under several compilers. No point in bringing in a bunch
// of #ifdefs here.
//
template<typename OtherIteratorTuple>
bool equal(const zip_iterator<OtherIteratorTuple>& other) const
{
return get_iterator_tuple() == other.get_iterator_tuple();
}
// Advancing a zip iterator means to advance all iterators in the
// iterator tuple.
void advance(typename super_t::difference_type n)
{
fusion::for_each(
m_iterator_tuple,
detail::advance_iterator<BOOST_DEDUCED_TYPENAME super_t::difference_type>(n)
);
}
// Incrementing a zip iterator means to increment all iterators in
// the iterator tuple.
void increment()
{
fusion::for_each(
m_iterator_tuple,
detail::increment_iterator()
);
}
// Decrementing a zip iterator means to decrement all iterators in
// the iterator tuple.
void decrement()
{
fusion::for_each(
m_iterator_tuple,
detail::decrement_iterator()
);
}
// Distance is calculated using the first iterator in the tuple.
template<typename OtherIteratorTuple>
typename super_t::difference_type distance_to(
const zip_iterator<OtherIteratorTuple>& other
) const
{
return *fusion::begin(other.get_iterator_tuple()) -
*fusion::begin(this->get_iterator_tuple());
}
// Data Members
// ============
// The iterator tuple.
IteratorTuple m_iterator_tuple;
};
// Make function for zip iterator
//
template<typename IteratorTuple>
zip_iterator<IteratorTuple>
make_zip_iterator(IteratorTuple t)
{ return zip_iterator<IteratorTuple>(t); }
}
#endif

View File

@ -1,68 +0,0 @@
// Copyright David Abrahams 2004. Use, modification and distribution is
// subject to the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef POINTEE_DWA200415_HPP
# define POINTEE_DWA200415_HPP
// dereferenceable_traits provides access to the value_type and
// reference of a Dereferenceable type.
# include <boost/detail/is_incrementable.hpp>
# include <boost/iterator/iterator_traits.hpp>
# include <boost/type_traits/add_const.hpp>
# include <boost/type_traits/remove_cv.hpp>
# include <boost/mpl/if.hpp>
# include <boost/mpl/apply_if.hpp>
namespace boost {
namespace detail
{
template <class P>
struct smart_ptr_pointee
{
typedef typename P::element_type type;
};
template <class Iterator>
struct iterator_pointee
{
typedef typename iterator_traits<Iterator>::value_type value_type;
struct impl
{
template <class T>
static char test(T const&);
static char (& test(value_type&) )[2];
static Iterator& x;
};
BOOST_STATIC_CONSTANT(bool, is_constant = sizeof(impl::test(*impl::x)) == 1);
typedef typename mpl::if_c<
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
::boost::detail::iterator_pointee<Iterator>::is_constant
# else
is_constant
# endif
, typename add_const<value_type>::type
, value_type
>::type type;
};
}
template <class P>
struct pointee
: mpl::apply_if<
detail::is_incrementable<P>
, detail::iterator_pointee<P>
, detail::smart_ptr_pointee<P>
>
{
};
} // namespace boost
#endif // POINTEE_DWA200415_HPP

836
test/zip_iterator_test.cpp Executable file
View File

@ -0,0 +1,836 @@
// (C) Copyright Dave Abrahams and Thomas Becker 2003. Permission to
// copy, use, modify, sell and distribute this software is granted
// provided this copyright notice appears in all copies. This software
// is provided "as is" without express or implied warranty, and with
// no claim as to its suitability for any purpose.
//
// File:
// =====
// zip_iterator_test_main.cpp
// Author:
// =======
// Thomas Becker
// Created:
// ========
// Jul 15, 2003
// Purpose:
// ========
// Test driver for zip_iterator.hpp
// Compilers Tested:
// =================
// Metrowerks Codewarrior Pro 7.2, 8.3
// gcc 2.95.3
// gcc 3.2
// Microsoft VC 6sp5 (test fails due to some compiler bug)
// Microsoft VC 7 (works)
// Microsoft VC 7.1
// Intel 5
// Intel 6
// Intel 7.1
// Intel 8
// Borland 5.5.1 (broken due to lack of support from Boost.Tuples)
/////////////////////////////////////////////////////////////////////////////
//
// Includes
//
/////////////////////////////////////////////////////////////////////////////
#define FUSION_MAX_TUPLE_SIZE 13
#include <boost/iterator/zip_iterator.hpp> // 2nd #include tests #include guard.
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <functional>
#include <boost/spirit/fusion/sequence/tuple.hpp>
#include <boost/spirit/fusion/sequence/tuple20.hpp>
#include <boost/spirit/fusion/sequence/make_tuple.hpp>
#include <boost/spirit/fusion/algorithm/push_front.hpp>
#include <boost/spirit/fusion/sequence/get.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>
template <class It>
struct pure_traversal
: boost::detail::pure_traversal_tag<
typename boost::iterator_traversal<It>::type
>
{};
/////////////////////////////////////////////////////////////////////////////
//
// Das Main Funktion
//
/////////////////////////////////////////////////////////////////////////////
int main( void )
{
std::cout << "\n"
<< "***********************************************\n"
<< "* *\n"
<< "* Test driver for boost::zip_iterator *\n"
<< "* Copyright Thomas Becker 2003 *\n"
<< "* *\n"
<< "***********************************************\n\n"
<< std::flush;
size_t num_successful_tests = 0;
size_t num_failed_tests = 0;
/////////////////////////////////////////////////////////////////////////////
//
// 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::fusion::tuple<
std::set<int>::iterator
, std::vector<double>::iterator
>
> zit_mixed;
zit_mixed zip_it_mixed = zit_mixed(
boost::fusion::make_tuple(
intset.begin()
, vect1.begin()
)
);
boost::fusion::tuple<int, double> val_tuple(
*zip_it_mixed);
boost::fusion::tuple<const int&, double&> ref_tuple(
*zip_it_mixed);
double dblOldVal = boost::fusion::get<1>(ref_tuple);
boost::fusion::get<1>(ref_tuple) -= 41.;
if( 52 == boost::fusion::get<0>(val_tuple) &&
42. == boost::fusion::get<1>(val_tuple) &&
52 == boost::fusion::get<0>(ref_tuple) &&
1. == boost::fusion::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::fusion::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::fusion::tuple11<
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>::iterator,
std::list<int>::iterator,
std::set<int>::iterator,
std::vector<int>::const_iterator
> cons_11_its_type;
//
typedef boost::fusion::meta::generate<
boost::fusion::meta::push_front<
cons_11_its_type,
std::list<int>::const_iterator
>::type
>::type cons_12_its_type;
// typedefs for cons lists for dereferencing the zip iterator
// made from the cons list above.
typedef boost::fusion::tuple11<
const int&,
int&,
int&,
const int&,
int&,
int&,
const int&,
int&,
int&,
const int&,
const int&
> cons_11_refs_type;
//
typedef boost::fusion::meta::generate<
boost::fusion::meta::push_front<
cons_11_refs_type,
const int&
>::type
>::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(),
se1.begin(),
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::fusion::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::fusion::get<11>(zip_it_12.get_iterator_tuple()) == ve4.begin() &&
boost::fusion::get<11>(zip_it_12_copy.get_iterator_tuple()) == ve4.end() &&
1 == boost::fusion::get<0>(zip_it_12_dereferenced) &&
12 == boost::fusion::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::fusion::tuple<
std::vector<double>::const_iterator,
std::vector<double>::const_iterator
>
>
zip_it_begin(
boost::fusion::make_tuple(
vect1.begin(),
vect2.begin()
)
);
boost::zip_iterator<
boost::fusion::tuple<
std::vector<double>::const_iterator,
std::vector<double>::const_iterator
>
>
zip_it_run(
boost::fusion::make_tuple(
vect1.begin(),
vect2.begin()
)
);
boost::zip_iterator<
boost::fusion::tuple<
std::vector<double>::const_iterator,
std::vector<double>::const_iterator
>
>
zip_it_end(
boost::fusion::make_tuple(
vect1.end(),
vect2.end()
)
);
if( zip_it_run == zip_it_begin &&
42. == boost::fusion::get<0>(*zip_it_run) &&
2.2 == boost::fusion::get<1>(*zip_it_run) &&
43. == boost::fusion::get<0>(*(++zip_it_run)) &&
3.3 == boost::fusion::get<1>(*zip_it_run) &&
44. == boost::fusion::get<0>(*(++zip_it_run)) &&
4.4 == boost::fusion::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::fusion::get<0>(*zip_it_run) &&
4.4 == boost::fusion::get<1>(*zip_it_run) &&
43. == boost::fusion::get<0>(*(--zip_it_run)) &&
3.3 == boost::fusion::get<1>(*zip_it_run) &&
42. == boost::fusion::get<0>(*(--zip_it_run)) &&
2.2 == boost::fusion::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::fusion::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::fusion::get<0>(zip_it_run.get_iterator_tuple()) == vect1.begin() + 1 &&
boost::fusion::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::fusion::tuple<double, double> >
vect_of_tuples(3);
std::copy(
boost::make_zip_iterator(
boost::fusion::make_tuple(
vect1.begin(),
vect2.begin()
)
),
boost::make_zip_iterator(
boost::fusion::make_tuple(
vect1.end(),
vect2.end()
)
),
vect_of_tuples.begin()
);
if( 42. == boost::fusion::get<0>(*vect_of_tuples.begin()) &&
2.2 == boost::fusion::get<1>(*vect_of_tuples.begin()) &&
43. == boost::fusion::get<0>(*(vect_of_tuples.begin() + 1)) &&
3.3 == boost::fusion::get<1>(*(vect_of_tuples.begin() + 1)) &&
44. == boost::fusion::get<0>(*(vect_of_tuples.begin() + 2)) &&
4.4 == boost::fusion::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::fusion::tuple<
std::set<int>::const_iterator,
std::vector<double>::const_iterator
>
>
zip_it_const(
boost::fusion::make_tuple(
intset.begin(),
vect2.begin()
)
);
//
boost::zip_iterator<
boost::fusion::tuple<
std::set<int>::iterator,
std::vector<double>::const_iterator
>
>
zip_it_half_const(
boost::fusion::make_tuple(
intset.begin(),
vect2.begin()
)
);
//
boost::zip_iterator<
boost::fusion::tuple<
std::set<int>::iterator,
std::vector<double>::iterator
>
>
zip_it_non_const(
boost::fusion::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::fusion::get<0>(*zip_it_const) &&
4.4 == boost::fusion::get<1>(*zip_it_const) &&
53 == boost::fusion::get<0>(*zip_it_half_const) &&
3.3 == boost::fusion::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::fusion::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;
}