From acf9b4d4cfceb6d81fc8c6d30aa26afcc6ed9738 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Wed, 17 Oct 2012 18:09:08 +0900 Subject: [PATCH 01/13] Reimplement zip_iterator based on Boost.Fusion By default, backward compatibility for Boost.Tuple is presented. Signed-off-by: Kohei Takahashi --- include/boost/iterator/zip_iterator.hpp | 441 +++++------------------- 1 file changed, 94 insertions(+), 347 deletions(-) diff --git a/include/boost/iterator/zip_iterator.hpp b/include/boost/iterator/zip_iterator.hpp index a468070..497ba7d 100644 --- a/include/boost/iterator/zip_iterator.hpp +++ b/include/boost/iterator/zip_iterator.hpp @@ -1,6 +1,8 @@ -// Copyright David Abrahams and Thomas Becker 2000-2006. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at +// Copyright David Abrahams and Thomas Becker 2000-2006. +// Copyright Kohei Takahashi 2012-2014. +// +// 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) #ifndef BOOST_ZIP_ITERATOR_TMB_07_13_2003_HPP_ @@ -16,40 +18,30 @@ #include -#include +#include // for backward compatibility -#include -#include -#include -#include -#include +#include +#include + +#include +#include +#include #include #include +#include +#include +#include +#include +#include +#include + namespace boost { // Zip iterator forward declaration for zip_iterator_base template class zip_iterator; - // One important design goal of the zip_iterator is to isolate all - // functionality whose implementation relies on the current tuple - // implementation. This goal has been achieved as follows: Inside - // the namespace detail there is a namespace tuple_impl_specific. - // This namespace encapsulates all functionality that is specific - // to the current Boost tuple implementation. More precisely, the - // namespace tuple_impl_specific provides the following tuple - // algorithms and meta-algorithms for the current Boost tuple - // implementation: - // - // tuple_meta_transform - // tuple_meta_accumulate - // tuple_transform - // tuple_for_each - // - // If the tuple implementation changes, all that needs to be - // replaced is the implementation of these four (meta-)algorithms. - namespace detail { @@ -60,7 +52,7 @@ namespace boost { { public: advance_iterator(DiffType step) : m_step(step) {} - + template void operator()(Iterator& it) const { it += m_step; } @@ -72,250 +64,39 @@ namespace boost { struct increment_iterator { template - void operator()(Iterator& it) + void operator()(Iterator& it) const { ++it; } }; // struct decrement_iterator { template - void operator()(Iterator& it) + void operator()(Iterator& it) const { --it; } }; // struct dereference_iterator { - template - struct apply - { + template + struct result; + + template + struct result + { typedef typename - iterator_traits::reference + remove_reference::type>::type + iterator; + + typedef typename + iterator_traits::reference type; }; template - typename apply::type operator()(Iterator const& it) + typename result::type + operator()(Iterator const& it) const { return *it; } }; - - - // The namespace tuple_impl_specific provides two meta- - // algorithms and two algorithms for tuples. - // - namespace tuple_impl_specific - { - // Meta-transform algorithm for tuples - // - template - struct tuple_meta_transform; - - template - struct tuple_meta_transform_impl - { - typedef tuples::cons< - typename mpl::apply1< - typename mpl::lambda::type - , typename Tuple::head_type - >::type - , typename tuple_meta_transform< - typename Tuple::tail_type - , UnaryMetaFun - >::type - > type; - }; - - template - struct tuple_meta_transform - : mpl::eval_if< - boost::is_same - , mpl::identity - , tuple_meta_transform_impl - > - { - }; - - // Meta-accumulate algorithm for tuples. Note: The template - // parameter StartType corresponds to the initial value in - // ordinary accumulation. - // - template - struct tuple_meta_accumulate; - - template< - typename Tuple - , class BinaryMetaFun - , typename StartType - > - struct tuple_meta_accumulate_impl - { - typedef typename mpl::apply2< - typename mpl::lambda::type - , typename Tuple::head_type - , typename tuple_meta_accumulate< - typename Tuple::tail_type - , BinaryMetaFun - , StartType - >::type - >::type type; - }; - - template< - typename Tuple - , class BinaryMetaFun - , typename StartType - > - struct tuple_meta_accumulate - : mpl::eval_if< -#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) - mpl::or_< -#endif - boost::is_same -#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) - , boost::is_same - > -#endif - , mpl::identity - , tuple_meta_accumulate_impl< - Tuple - , BinaryMetaFun - , StartType - > - > - { - }; - -#if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \ - || ( \ - BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, != 0) && defined(_MSC_VER) \ - ) -// Not sure why intel's partial ordering fails in this case, but I'm -// assuming int's an MSVC bug-compatibility feature. - -# define BOOST_TUPLE_ALGO_DISPATCH -# define BOOST_TUPLE_ALGO(algo) algo##_impl -# define BOOST_TUPLE_ALGO_TERMINATOR , int -# define BOOST_TUPLE_ALGO_RECURSE , ... -#else -# define BOOST_TUPLE_ALGO(algo) algo -# define BOOST_TUPLE_ALGO_TERMINATOR -# define BOOST_TUPLE_ALGO_RECURSE -#endif - - // transform algorithm for tuples. The template parameter Fun - // must be a unary functor which is also a unary metafunction - // class that computes its return type based on its argument - // type. For example: - // - // struct to_ptr - // { - // template - // struct apply - // { - // typedef Arg* type; - // } - // - // template - // Arg* operator()(Arg x); - // }; - template - tuples::null_type BOOST_TUPLE_ALGO(tuple_transform) - (tuples::null_type const&, Fun BOOST_TUPLE_ALGO_TERMINATOR) - { return tuples::null_type(); } - - template - typename tuple_meta_transform< - Tuple - , Fun - >::type - - BOOST_TUPLE_ALGO(tuple_transform)( - const Tuple& t, - Fun f - BOOST_TUPLE_ALGO_RECURSE - ) - { - typedef typename tuple_meta_transform< - BOOST_DEDUCED_TYPENAME Tuple::tail_type - , Fun - >::type transformed_tail_type; - - return tuples::cons< - BOOST_DEDUCED_TYPENAME mpl::apply1< - Fun, BOOST_DEDUCED_TYPENAME Tuple::head_type - >::type - , transformed_tail_type - >( - f(boost::tuples::get<0>(t)), tuple_transform(t.get_tail(), f) - ); - } - -#ifdef BOOST_TUPLE_ALGO_DISPATCH - template - typename tuple_meta_transform< - Tuple - , Fun - >::type - - tuple_transform( - const Tuple& t, - Fun f - ) - { - return tuple_transform_impl(t, f, 1); - } -#endif - - // for_each algorithm for tuples. - // - template - Fun BOOST_TUPLE_ALGO(tuple_for_each)( - tuples::null_type - , Fun f BOOST_TUPLE_ALGO_TERMINATOR - ) - { return f; } - - - template - Fun BOOST_TUPLE_ALGO(tuple_for_each)( - Tuple& t - , Fun f BOOST_TUPLE_ALGO_RECURSE) - { - f( t.get_head() ); - return tuple_for_each(t.get_tail(), f); - } - -#ifdef BOOST_TUPLE_ALGO_DISPATCH - template - Fun - tuple_for_each( - Tuple& t, - Fun f - ) - { - return tuple_for_each_impl(t, f, 1); - } -#endif - - // Equality of tuples. NOTE: "==" for tuples currently (7/2003) - // has problems under some compilers, so I just do my own. - // No point in bringing in a bunch of #ifdefs here. This is - // going to go away with the next tuple implementation anyway. - // - inline bool tuple_equal(tuples::null_type, tuples::null_type) - { return true; } - - template - bool tuple_equal( - Tuple1 const& t1, - Tuple2 const& t2 - ) - { - return t1.get_head() == t2.get_head() && - tuple_equal(t1.get_tail(), t2.get_tail()); - } - } - // - // end namespace tuple_impl_specific template struct iterator_reference @@ -336,14 +117,14 @@ namespace boost { struct apply : iterator_reference {}; }; #endif - + // Metafunction to obtain the type of the tuple whose element types // are the reference types of an iterator tuple. // template struct tuple_of_references - : tuple_impl_specific::tuple_meta_transform< - IteratorTuple, + : mpl::transform< + IteratorTuple, iterator_reference > { @@ -355,54 +136,23 @@ namespace boost { template struct minimum_traversal_category_in_iterator_tuple { - typedef typename tuple_impl_specific::tuple_meta_transform< + typedef typename mpl::transform< IteratorTuple , pure_traversal_tag > >::type tuple_of_traversal_tags; - - typedef typename tuple_impl_specific::tuple_meta_accumulate< + + typedef typename mpl::fold< tuple_of_traversal_tags - , minimum_category<> , random_access_traversal_tag + , minimum_category<> >::type type; }; -#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) // ETI workaround - template <> - struct minimum_traversal_category_in_iterator_tuple - { - typedef int type; - }; -#endif - - // We need to call tuple_meta_accumulate with mpl::and_ as the - // accumulating functor. To this end, we need to wrap it into - // a struct that has exactly two arguments (that is, template - // parameters) and not five, like mpl::and_ does. - // - template - struct and_with_two_args - : mpl::and_ - { - }; - -# ifdef BOOST_MPL_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 - { - template - struct apply : mpl::and_ - {}; - }; -# endif - /////////////////////////////////////////////////////////////////// // // Class zip_iterator_base // - // Builds and exposes the iterator facade type from which the zip + // Builds and exposes the iterator facade type from which the zip // iterator will be derived. // template @@ -411,30 +161,30 @@ namespace boost { private: // Reference type is the type of the tuple obtained from the // iterators' reference types. - typedef typename + typedef typename detail::tuple_of_references::type reference; - + // Value type is the same as reference type. typedef reference value_type; - + // Difference type is the first iterator's difference type typedef typename iterator_traits< - typename tuples::element<0, IteratorTuple>::type + typename mpl::at_c::type >::difference_type difference_type; - - // Traversal catetgory is the minimum traversal category in the + + // Traversal catetgory is the minimum traversal category in the // iterator tuple. - typedef typename + typedef typename detail::minimum_traversal_category_in_iterator_tuple< IteratorTuple >::type traversal_category; public: - + // The iterator facade type from which the zip iterator will // be derived. typedef iterator_facade< zip_iterator, - value_type, + value_type, traversal_category, reference, difference_type @@ -447,34 +197,34 @@ namespace boost { typedef int type; }; } - + ///////////////////////////////////////////////////////////////////// // // zip_iterator class definition // template - class zip_iterator : + class zip_iterator : public detail::zip_iterator_base::type - { + { - // Typedef super_t as our base class. - typedef typename + // Typedef super_t as our base class. + typedef typename detail::zip_iterator_base::type super_t; // iterator_core_access is the iterator's best friend. friend class iterator_core_access; public: - + // Construction // ============ - + // Default constructor zip_iterator() { } // Constructor from iterator tuple - zip_iterator(IteratorTuple iterator_tuple) - : m_iterator_tuple(iterator_tuple) + zip_iterator(IteratorTuple iterator_tuple) + : m_iterator_tuple(iterator_tuple) { } // Copy constructor @@ -493,18 +243,19 @@ namespace boost { { return m_iterator_tuple; } private: - + // Implementation of Iterator Operations // ===================================== - + // Dereferencing returns a tuple built from the dereferenced // iterators in the iterator tuple. typename super_t::reference dereference() const - { - return detail::tuple_impl_specific::tuple_transform( - get_iterator_tuple(), - detail::dereference_iterator() - ); + { + typedef typename super_t::reference reference; + typedef typename fusion::traits::tag_of::type tag; + return fusion::convert(fusion::transform( + get_iterator_tuple(), + detail::dereference_iterator())); } // Two zip iterators are equal if all iterators in the iterator @@ -517,66 +268,62 @@ namespace boost { // under several compilers. No point in bringing in a bunch // of #ifdefs here. // - template + template bool equal(const zip_iterator& other) const { - return detail::tuple_impl_specific::tuple_equal( - get_iterator_tuple(), - other.get_iterator_tuple() - ); + return fusion::equal_to( + get_iterator_tuple(), + other.get_iterator_tuple()); } // Advancing a zip iterator means to advance all iterators in the // iterator tuple. void advance(typename super_t::difference_type n) - { - detail::tuple_impl_specific::tuple_for_each( + { + fusion::for_each( m_iterator_tuple, - detail::advance_iterator(n) - ); + detail::advance_iterator(n)); } // Incrementing a zip iterator means to increment all iterators in // the iterator tuple. void increment() - { - detail::tuple_impl_specific::tuple_for_each( - m_iterator_tuple, - detail::increment_iterator() - ); + { + fusion::for_each( + m_iterator_tuple, + detail::increment_iterator()); } - + // Decrementing a zip iterator means to decrement all iterators in // the iterator tuple. void decrement() - { - detail::tuple_impl_specific::tuple_for_each( - m_iterator_tuple, - detail::decrement_iterator() - ); + { + fusion::for_each( + m_iterator_tuple, + detail::decrement_iterator()); } - + // Distance is calculated using the first iterator in the tuple. template typename super_t::difference_type distance_to( const zip_iterator& other ) const - { - return boost::tuples::get<0>(other.get_iterator_tuple()) - - boost::tuples::get<0>(this->get_iterator_tuple()); + { + return fusion::at_c<0>(other.get_iterator_tuple()) - + fusion::at_c<0>(this->get_iterator_tuple()); } - + // Data Members // ============ - + // The iterator tuple. IteratorTuple m_iterator_tuple; - + }; // Make function for zip iterator // - template - zip_iterator + template + zip_iterator make_zip_iterator(IteratorTuple t) { return zip_iterator(t); } From 1ddaca82975abcf151aefc62a64fd7189de97527 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Thu, 18 Oct 2012 20:40:12 +0900 Subject: [PATCH 02/13] zip_iterator specialization for std::pair Signed-off-by: Kohei Takahashi --- include/boost/iterator/zip_iterator.hpp | 58 ++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/include/boost/iterator/zip_iterator.hpp b/include/boost/iterator/zip_iterator.hpp index 497ba7d..65dd82f 100644 --- a/include/boost/iterator/zip_iterator.hpp +++ b/include/boost/iterator/zip_iterator.hpp @@ -18,6 +18,7 @@ #include +#include // for std::pair #include // for backward compatibility #include @@ -130,6 +131,16 @@ namespace boost { { }; + // Specialization for std::pair + template + struct tuple_of_references > + { + typedef std::pair< + typename iterator_reference::type + , typename iterator_reference::type + > type; + }; + // Metafunction to obtain the minimal traversal tag in a tuple // of iterators. // @@ -148,6 +159,25 @@ namespace boost { >::type type; }; + template + struct minimum_traversal_category_in_iterator_tuple > + { + typedef typename pure_traversal_tag< + typename iterator_traversal::type + >::type iterator1_traversal; + typedef typename pure_traversal_tag< + typename iterator_traversal::type + >::type iterator2_traversal; + + typedef typename minimum_category< + iterator1_traversal + , typename minimum_category< + iterator2_traversal + , random_access_traversal_tag + >::type + >::type type; + }; + /////////////////////////////////////////////////////////////////// // // Class zip_iterator_base @@ -196,6 +226,30 @@ namespace boost { { typedef int type; }; + + template + struct converter + { + template + static reference call(Seq seq) + { + typedef typename fusion::traits::tag_of::type tag; + return fusion::convert(seq); + } + }; + + template + struct converter > + { + typedef std::pair reference; + template + static reference call(Seq seq) + { + return reference( + fusion::at_c<0>(seq) + , fusion::at_c<1>(seq)); + } + }; } ///////////////////////////////////////////////////////////////////// @@ -252,8 +306,8 @@ namespace boost { typename super_t::reference dereference() const { typedef typename super_t::reference reference; - typedef typename fusion::traits::tag_of::type tag; - return fusion::convert(fusion::transform( + typedef detail::converter gen; + return gen::call(fusion::transform( get_iterator_tuple(), detail::dereference_iterator())); } From c040d4c38b53a025788e197a89256507a06d13fd Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Sat, 14 Jun 2014 15:54:37 +0900 Subject: [PATCH 03/13] make_zip_iterator should be inlined Signed-off-by: Kohei Takahashi --- include/boost/iterator/zip_iterator.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/iterator/zip_iterator.hpp b/include/boost/iterator/zip_iterator.hpp index 65dd82f..e9a1c43 100644 --- a/include/boost/iterator/zip_iterator.hpp +++ b/include/boost/iterator/zip_iterator.hpp @@ -377,7 +377,7 @@ namespace boost { // Make function for zip iterator // template - zip_iterator + inline zip_iterator make_zip_iterator(IteratorTuple t) { return zip_iterator(t); } From 782313db8c6aec859a288f0a5f4dc87b24cdf437 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Sat, 14 Jun 2014 15:58:52 +0900 Subject: [PATCH 04/13] Remove unnecessary specialization Signed-off-by: Kohei Takahashi --- include/boost/iterator/zip_iterator.hpp | 30 +++---------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/include/boost/iterator/zip_iterator.hpp b/include/boost/iterator/zip_iterator.hpp index e9a1c43..4863f68 100644 --- a/include/boost/iterator/zip_iterator.hpp +++ b/include/boost/iterator/zip_iterator.hpp @@ -14,7 +14,6 @@ #include #include // for enable_if_convertible #include -#include #include @@ -28,7 +27,6 @@ #include #include #include -#include #include #include @@ -88,9 +86,7 @@ namespace boost { remove_reference::type>::type iterator; - typedef typename - iterator_traits::reference - type; + typedef typename iterator_reference::type type; }; template @@ -99,26 +95,6 @@ namespace boost { { return *it; } }; - template - struct iterator_reference - { - typedef typename iterator_traits::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 - { - template - struct apply : iterator_reference {}; - }; -#endif - // Metafunction to obtain the type of the tuple whose element types // are the reference types of an iterator tuple. // @@ -198,9 +174,9 @@ namespace boost { typedef reference value_type; // Difference type is the first iterator's difference type - typedef typename iterator_traits< + typedef typename iterator_difference< typename mpl::at_c::type - >::difference_type difference_type; + >::type difference_type; // Traversal catetgory is the minimum traversal category in the // iterator tuple. From 9841d87212f39da1f99de1302c57d4ee25b8c56f Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Thu, 12 Jun 2014 01:04:29 +0900 Subject: [PATCH 05/13] Add tests for fusion based zip_iterator Signed-off-by: Kohei Takahashi --- test/Jamfile.v2 | 22 +++++---- test/detail/zip_iterator_test.ipp | 73 ++++++++++++++++++++++++++++ test/zip_iterator_test_fusion.cpp | 15 ++++++ test/zip_iterator_test_std_pair.cpp | 16 ++++++ test/zip_iterator_test_std_tuple.cpp | 29 +++++++++++ 5 files changed, 145 insertions(+), 10 deletions(-) create mode 100644 test/detail/zip_iterator_test.ipp create mode 100644 test/zip_iterator_test_fusion.cpp create mode 100644 test/zip_iterator_test_std_pair.cpp create mode 100644 test/zip_iterator_test_std_tuple.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 023a826..560c212 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -3,28 +3,30 @@ # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) test-suite iterator - : + : # These first two tests will run last, and are expected to fail # for many less-capable compilers. - + [ compile-fail interoperable_fail.cpp ] # test uses expected success, so that we catch unrelated # compilation problems. - [ run is_convertible_fail.cpp ] + [ run is_convertible_fail.cpp ] [ run zip_iterator_test.cpp - : : : - + : : : # stlport's debug mode generates long symbols which overwhelm # vc6 - #<*>release + #<*>release ] - + [ 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. [ compile is_lvalue_iterator.cpp ] [ compile is_readable_iterator.cpp ] [ compile pointee.cpp ] - + [ run unit_tests.cpp ] [ run concept_tests.cpp ] [ run iterator_adaptor_cc.cpp ] @@ -41,8 +43,8 @@ test-suite iterator [ run counting_iterator_test.cpp ] [ run interoperable.cpp ] [ run iterator_traits_test.cpp ] - [ run permutation_iterator_test.cpp : : : # on + [ run permutation_iterator_test.cpp : : : # on ] [ run function_input_iterator_test.cpp ] - + ; diff --git a/test/detail/zip_iterator_test.ipp b/test/detail/zip_iterator_test.ipp new file mode 100644 index 0000000..f659099 --- /dev/null +++ b/test/detail/zip_iterator_test.ipp @@ -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 + +#include +#include +#include +#include +#include + + +int main() +{ + typedef TUPLE< + std::vector::iterator, + std::vector::iterator + > iterator_tuple; + + std::vector vi = boost::assign::list_of(42)(72); + std::vector vs = boost::assign::list_of("kokoro")("pyonpyon"); + + { + boost::zip_iterator i1(MAKE_TUPLE(vi.begin(), vs.begin())); + boost::zip_iterator 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 i1(MAKE_TUPLE(vi.begin(), vs.begin())); + boost::zip_iterator 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 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 i1(MAKE_TUPLE(vi.begin(), vs.begin())); + boost::zip_iterator 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(); +} diff --git a/test/zip_iterator_test_fusion.cpp b/test/zip_iterator_test_fusion.cpp new file mode 100644 index 0000000..542fd88 --- /dev/null +++ b/test/zip_iterator_test_fusion.cpp @@ -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 +#include + +#define TUPLE boost::fusion::vector +#define MAKE_TUPLE boost::fusion::make_vector + +#include "detail/zip_iterator_test.ipp" diff --git a/test/zip_iterator_test_std_pair.cpp b/test/zip_iterator_test_std_pair.cpp new file mode 100644 index 0000000..215777a --- /dev/null +++ b/test/zip_iterator_test_std_pair.cpp @@ -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 +#include + +#define TUPLE std::pair +#define MAKE_TUPLE std::make_pair + +#include "detail/zip_iterator_test.ipp" + diff --git a/test/zip_iterator_test_std_tuple.cpp b/test/zip_iterator_test_std_tuple.cpp new file mode 100644 index 0000000..02d648d --- /dev/null +++ b/test/zip_iterator_test_std_tuple.cpp @@ -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 + +#if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + +#include +#include + +#define TUPLE std::tuple +#define MAKE_TUPLE std::make_tuple + +#include "detail/zip_iterator_test.ipp" + +#else + +int main() +{ + return 0; +} + +#endif + From 878812c42f390b72cfd3f394ba87c7f19497a1bc Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Sun, 23 Aug 2015 23:46:44 -0400 Subject: [PATCH 06/13] More tests with fusion sequence as tuple --- test/Jamfile.v2 | 4 + test/detail/zip_iterator_test_original.ipp | 857 +++++++++++++++++++++ test/zip_iterator_test.cpp | 852 +------------------- test/zip_iterator_test2_fusion_deque.cpp | 9 + test/zip_iterator_test2_fusion_list.cpp | 11 + test/zip_iterator_test2_fusion_vector.cpp | 11 + test/zip_iterator_test2_std_tuple.cpp | 21 + 7 files changed, 918 insertions(+), 847 deletions(-) create mode 100644 test/detail/zip_iterator_test_original.ipp create mode 100644 test/zip_iterator_test2_fusion_deque.cpp create mode 100644 test/zip_iterator_test2_fusion_list.cpp create mode 100644 test/zip_iterator_test2_fusion_vector.cpp create mode 100644 test/zip_iterator_test2_std_tuple.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 944c41c..81547dc 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -18,6 +18,10 @@ test-suite iterator # vc6 #<*>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 ] diff --git a/test/detail/zip_iterator_test_original.ipp b/test/detail/zip_iterator_test_original.ipp new file mode 100644 index 0000000..dc04221 --- /dev/null +++ b/test/detail/zip_iterator_test_original.ipp @@ -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 +#include // 2nd #include tests #include guard. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +/// Tests for https://svn.boost.org/trac/boost/ticket/1517 +int to_value(int const &v) +{ + return v; +} + +void category_test() +{ + std::list 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 vect1(3); + vect1[0] = 42.; + vect1[1] = 43.; + vect1[2] = 44.; + + std::set intset; + intset.insert(52); + intset.insert(53); + intset.insert(54); + // + + typedef + boost::zip_iterator< + ZI_TUPLE< + std::set::iterator + , std::vector::iterator + > + > zit_mixed; + + zit_mixed zip_it_mixed = zit_mixed( + ZI_MAKE_TUPLE( + intset.begin() + , vect1.begin() + ) + ); + + ZI_TUPLE val_tuple( + *zip_it_mixed); + + ZI_TUPLE 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 li1; + li1.push_back(1); + std::set se1; + se1.insert(2); + std::vector ve1; + ve1.push_back(3); + // + std::list li2; + li2.push_back(4); + std::set se2; + se2.insert(5); + std::vector ve2; + ve2.push_back(6); + // + std::list li3; + li3.push_back(7); + std::set se3; + se3.insert(8); + std::vector ve3; + ve3.push_back(9); + // + std::list li4; + li4.push_back(10); + std::set se4; + se4.insert(11); + std::vector ve4; + ve4.push_back(12); + + // typedefs for cons lists of iterators. + typedef boost::tuples::cons< + std::set::iterator, + ZI_TUPLE< + std::vector::iterator, + std::list::iterator, + std::set::iterator, + std::vector::iterator, + std::list::iterator, + std::set::iterator, + std::vector::iterator, + std::list::iterator, + std::set::iterator, + std::vector::const_iterator + >::inherited + > cons_11_its_type; + // + typedef boost::tuples::cons< + std::list::const_iterator, + cons_11_its_type + > cons_12_its_type; + + // typedefs for cons lists for dereferencing the zip iterator + // made from the cons list above. + typedef boost::tuples::cons< + const int&, + 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 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 vect2(3); + vect2[0] = 2.2; + vect2[1] = 3.3; + vect2[2] = 4.4; + + boost::zip_iterator< + ZI_TUPLE< + std::vector::const_iterator, + std::vector::const_iterator + > + > + zip_it_begin( + ZI_MAKE_TUPLE( + vect1.begin(), + vect2.begin() + ) + ); + + boost::zip_iterator< + ZI_TUPLE< + std::vector::const_iterator, + std::vector::const_iterator + > + > + zip_it_run( + ZI_MAKE_TUPLE( + vect1.begin(), + vect2.begin() + ) + ); + + boost::zip_iterator< + ZI_TUPLE< + std::vector::const_iterator, + std::vector::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::const_iterator, + std::vector::const_iterator + > + > zip_it_run_copy(zip_it_run); + + if(zip_it_run == zip_it_run && zip_it_run == zip_it_run_copy) + { + ++num_successful_tests; + std::cout << "OK" << std::endl; + } + else + { + ++num_failed_tests; + 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 > + 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::const_iterator, + std::vector::const_iterator + > + > + zip_it_const( + ZI_MAKE_TUPLE( + intset.begin(), + vect2.begin() + ) + ); + // + boost::zip_iterator< + ZI_TUPLE< + std::set::iterator, + std::vector::const_iterator + > + > + zip_it_half_const( + ZI_MAKE_TUPLE( + intset.begin(), + vect2.begin() + ) + ); + // + boost::zip_iterator< + ZI_TUPLE< + std::set::iterator, + std::vector::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::type + , boost::bidirectional_traversal_tag + >::value; + + bool bBigItIsRandomAccessIterator = boost::is_convertible< + boost::iterator_traversal::type + , boost::random_access_traversal_tag + >::value; + + // A combining iterator with all vector iterators must have random access + // traversal. + // + typedef boost::zip_iterator< + ZI_TUPLE< + std::vector::const_iterator, + std::vector::const_iterator + > + > all_vects_type; + + bool bAllVectsIsRandomAccessIterator = boost::is_convertible< + boost::iterator_traversal::type + , boost::random_access_traversal_tag + >::value; + + // The big test. + if( bBigItIsBidirectionalIterator && + ! bBigItIsRandomAccessIterator && + bAllVectsIsRandomAccessIterator + ) + { + ++num_successful_tests; + std::cout << "OK" << std::endl; + } + else + { + ++num_failed_tests; + std::cout << "not OK" << std::endl; + } + +#endif + + // Done + // + std::cout << "\nTest Result:" + << "\n============" + << "\nNumber of successful tests: " << static_cast(num_successful_tests) + << "\nNumber of failed tests: " << static_cast(num_failed_tests) + << std::endl; + + return num_failed_tests; +} + diff --git a/test/zip_iterator_test.cpp b/test/zip_iterator_test.cpp index b508098..08c4581 100644 --- a/test/zip_iterator_test.cpp +++ b/test/zip_iterator_test.cpp @@ -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 -#include // 2nd #include tests #include guard. -#include -#include -#include -#include -#include -#include #include -#include -#include -#include -#include -#include +#define ZI_TUPLE boost::tuples::tuple +#define ZI_MAKE_TUPLE boost::make_tuple +#define ZI_TUPLE_GET(n) boost::tuples::get +#define ZI_USE_BOOST_TUPLE -/// Tests for https://svn.boost.org/trac/boost/ticket/1517 -int to_value(int const &v) -{ - return v; -} - -void category_test() -{ - std::list 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 vect1(3); - vect1[0] = 42.; - vect1[1] = 43.; - vect1[2] = 44.; - - std::set intset; - intset.insert(52); - intset.insert(53); - intset.insert(54); - // - - typedef - boost::zip_iterator< - boost::tuples::tuple< - std::set::iterator - , std::vector::iterator - > - > zit_mixed; - - zit_mixed zip_it_mixed = zit_mixed( - boost::make_tuple( - intset.begin() - , vect1.begin() - ) - ); - - boost::tuples::tuple val_tuple( - *zip_it_mixed); - - boost::tuples::tuple ref_tuple( - *zip_it_mixed); - - double dblOldVal = boost::tuples::get<1>(ref_tuple); - boost::tuples::get<1>(ref_tuple) -= 41.; - - if( 52 == boost::tuples::get<0>(val_tuple) && - 42. == boost::tuples::get<1>(val_tuple) && - 52 == boost::tuples::get<0>(ref_tuple) && - 1. == boost::tuples::get<1>(ref_tuple) && - 1. == *vect1.begin() - ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - // Undo change to vect1 - boost::tuples::get<1>(ref_tuple) = dblOldVal; - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator with 12 components - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterators with 12 components: " - << std::flush; - - // Declare 12 containers - // - std::list li1; - li1.push_back(1); - std::set se1; - se1.insert(2); - std::vector ve1; - ve1.push_back(3); - // - std::list li2; - li2.push_back(4); - std::set se2; - se2.insert(5); - std::vector ve2; - ve2.push_back(6); - // - std::list li3; - li3.push_back(7); - std::set se3; - se3.insert(8); - std::vector ve3; - ve3.push_back(9); - // - std::list li4; - li4.push_back(10); - std::set se4; - se4.insert(11); - std::vector ve4; - ve4.push_back(12); - - // typedefs for cons lists of iterators. - typedef boost::tuples::cons< - std::set::iterator, - boost::tuples::tuple< - std::vector::iterator, - std::list::iterator, - std::set::iterator, - std::vector::iterator, - std::list::iterator, - std::set::iterator, - std::vector::iterator, - std::list::iterator, - std::set::iterator, - std::vector::const_iterator - >::inherited - > cons_11_its_type; - // - typedef boost::tuples::cons< - std::list::const_iterator, - cons_11_its_type - > cons_12_its_type; - - // typedefs for cons lists for dereferencing the zip iterator - // made from the cons list above. - typedef boost::tuples::cons< - const int&, - boost::tuples::tuple< - int&, - int&, - const int&, - int&, - int&, - const int&, - int&, - int&, - const int&, - const int& - >::inherited - > cons_11_refs_type; - // - typedef boost::tuples::cons< - const int&, - cons_11_refs_type - > cons_12_refs_type; - - // typedef for zip iterator with 12 elements - typedef boost::zip_iterator zip_it_12_type; - - // Declare a 12-element zip iterator. - zip_it_12_type zip_it_12( - cons_12_its_type( - li1.begin(), - cons_11_its_type( - se1.begin(), - boost::make_tuple( - ve1.begin(), - li2.begin(), - se2.begin(), - ve2.begin(), - li3.begin(), - se3.begin(), - ve3.begin(), - li4.begin(), - se4.begin(), - ve4.begin() - ) - ) - ) - ); - - // Dereference, mess with the result a little. - cons_12_refs_type zip_it_12_dereferenced(*zip_it_12); - boost::tuples::get<9>(zip_it_12_dereferenced) = 42; - - // Make a copy and move it a little to force some instantiations. - zip_it_12_type zip_it_12_copy(zip_it_12); - ++zip_it_12_copy; - - if( boost::tuples::get<11>(zip_it_12.get_iterator_tuple()) == ve4.begin() && - boost::tuples::get<11>(zip_it_12_copy.get_iterator_tuple()) == ve4.end() && - 1 == boost::tuples::get<0>(zip_it_12_dereferenced) && - 12 == boost::tuples::get<11>(zip_it_12_dereferenced) && - 42 == *(li4.begin()) - ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator incrementing and dereferencing - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator ++ and *: " - << std::flush; - - std::vector vect2(3); - vect2[0] = 2.2; - vect2[1] = 3.3; - vect2[2] = 4.4; - - boost::zip_iterator< - boost::tuples::tuple< - std::vector::const_iterator, - std::vector::const_iterator - > - > - zip_it_begin( - boost::make_tuple( - vect1.begin(), - vect2.begin() - ) - ); - - boost::zip_iterator< - boost::tuples::tuple< - std::vector::const_iterator, - std::vector::const_iterator - > - > - zip_it_run( - boost::make_tuple( - vect1.begin(), - vect2.begin() - ) - ); - - boost::zip_iterator< - boost::tuples::tuple< - std::vector::const_iterator, - std::vector::const_iterator - > - > - zip_it_end( - boost::make_tuple( - vect1.end(), - vect2.end() - ) - ); - - if( zip_it_run == zip_it_begin && - 42. == boost::tuples::get<0>(*zip_it_run) && - 2.2 == boost::tuples::get<1>(*zip_it_run) && - 43. == boost::tuples::get<0>(*(++zip_it_run)) && - 3.3 == boost::tuples::get<1>(*zip_it_run) && - 44. == boost::tuples::get<0>(*(++zip_it_run)) && - 4.4 == boost::tuples::get<1>(*zip_it_run) && - zip_it_end == ++zip_it_run - ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator decrementing and dereferencing - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator -- and *: " - << std::flush; - - if( zip_it_run == zip_it_end && - zip_it_end == zip_it_run-- && - 44. == boost::tuples::get<0>(*zip_it_run) && - 4.4 == boost::tuples::get<1>(*zip_it_run) && - 43. == boost::tuples::get<0>(*(--zip_it_run)) && - 3.3 == boost::tuples::get<1>(*zip_it_run) && - 42. == boost::tuples::get<0>(*(--zip_it_run)) && - 2.2 == boost::tuples::get<1>(*zip_it_run) && - zip_it_begin == zip_it_run - ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator copy construction and equality - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator copy construction and equality: " - << std::flush; - - boost::zip_iterator< - boost::tuples::tuple< - std::vector::const_iterator, - std::vector::const_iterator - > - > zip_it_run_copy(zip_it_run); - - if(zip_it_run == zip_it_run && zip_it_run == zip_it_run_copy) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator inequality - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator inequality: " - << std::flush; - - if(!(zip_it_run != zip_it_run_copy) && zip_it_run != ++zip_it_run_copy) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator less than - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator less than: " - << std::flush; - - // Note: zip_it_run_copy == zip_it_run + 1 - // - if( zip_it_run < zip_it_run_copy && - !( zip_it_run < --zip_it_run_copy) && - zip_it_run == zip_it_run_copy - ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator less than or equal - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "zip iterator less than or equal: " - << std::flush; - - // Note: zip_it_run_copy == zip_it_run - // - ++zip_it_run; - zip_it_run_copy += 2; - - if( zip_it_run <= zip_it_run_copy && - zip_it_run <= --zip_it_run_copy && - !( zip_it_run <= --zip_it_run_copy) && - zip_it_run <= zip_it_run - ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator greater than - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator greater than: " - << std::flush; - - // Note: zip_it_run_copy == zip_it_run - 1 - // - if( zip_it_run > zip_it_run_copy && - !( zip_it_run > ++zip_it_run_copy) && - zip_it_run == zip_it_run_copy - ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator greater than or equal - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator greater than or equal: " - << std::flush; - - ++zip_it_run; - - // Note: zip_it_run == zip_it_run_copy + 1 - // - if( zip_it_run >= zip_it_run_copy && - --zip_it_run >= zip_it_run_copy && - ! (zip_it_run >= ++zip_it_run_copy) - ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator + int - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator + int: " - << std::flush; - - // Note: zip_it_run == zip_it_run_copy - 1 - // - zip_it_run = zip_it_run + 2; - ++zip_it_run_copy; - - if( zip_it_run == zip_it_run_copy && zip_it_run == zip_it_begin + 3 ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator - int - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator - int: " - << std::flush; - - // Note: zip_it_run == zip_it_run_copy, and both are at end position - // - zip_it_run = zip_it_run - 2; - --zip_it_run_copy; - --zip_it_run_copy; - - if( zip_it_run == zip_it_run_copy && (zip_it_run - 1) == zip_it_begin ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator += - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator +=: " - << std::flush; - - // Note: zip_it_run == zip_it_run_copy, and both are at begin + 1 - // - zip_it_run += 2; - if( zip_it_run == zip_it_begin + 3 ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator -= - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator -=: " - << std::flush; - - // Note: zip_it_run is at end position, zip_it_run_copy is at - // begin plus one. - // - zip_it_run -= 2; - if( zip_it_run == zip_it_run_copy ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator getting member iterators - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator member iterators: " - << std::flush; - - // Note: zip_it_run and zip_it_run_copy are both at - // begin plus one. - // - if( boost::tuples::get<0>(zip_it_run.get_iterator_tuple()) == vect1.begin() + 1 && - boost::tuples::get<1>(zip_it_run.get_iterator_tuple()) == vect2.begin() + 1 - ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Making zip iterators - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Making zip iterators: " - << std::flush; - - std::vector > - vect_of_tuples(3); - - std::copy( - boost::make_zip_iterator( - boost::make_tuple( - vect1.begin(), - vect2.begin() - ) - ), - boost::make_zip_iterator( - boost::make_tuple( - vect1.end(), - vect2.end() - ) - ), - vect_of_tuples.begin() - ); - - if( 42. == boost::tuples::get<0>(*vect_of_tuples.begin()) && - 2.2 == boost::tuples::get<1>(*vect_of_tuples.begin()) && - 43. == boost::tuples::get<0>(*(vect_of_tuples.begin() + 1)) && - 3.3 == boost::tuples::get<1>(*(vect_of_tuples.begin() + 1)) && - 44. == boost::tuples::get<0>(*(vect_of_tuples.begin() + 2)) && - 4.4 == boost::tuples::get<1>(*(vect_of_tuples.begin() + 2)) - ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator non-const --> const conversion - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator non-const to const conversion: " - << std::flush; - - boost::zip_iterator< - boost::tuples::tuple< - std::set::const_iterator, - std::vector::const_iterator - > - > - zip_it_const( - boost::make_tuple( - intset.begin(), - vect2.begin() - ) - ); - // - boost::zip_iterator< - boost::tuples::tuple< - std::set::iterator, - std::vector::const_iterator - > - > - zip_it_half_const( - boost::make_tuple( - intset.begin(), - vect2.begin() - ) - ); - // - boost::zip_iterator< - boost::tuples::tuple< - std::set::iterator, - std::vector::iterator - > - > - zip_it_non_const( - boost::make_tuple( - intset.begin(), - vect2.begin() - ) - ); - - zip_it_half_const = ++zip_it_non_const; - zip_it_const = zip_it_half_const; - ++zip_it_const; -// zip_it_non_const = ++zip_it_const; // Error: can't convert from const to non-const - - if( 54 == boost::tuples::get<0>(*zip_it_const) && - 4.4 == boost::tuples::get<1>(*zip_it_const) && - 53 == boost::tuples::get<0>(*zip_it_half_const) && - 3.3 == boost::tuples::get<1>(*zip_it_half_const) - ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - - ///////////////////////////////////////////////////////////////////////////// - // - // Zip iterator categories - // - ///////////////////////////////////////////////////////////////////////////// - - std::cout << "Zip iterator categories: " - << std::flush; - - // The big iterator of the previous test has vector, list, and set iterators. - // Therefore, it must be bidirectional, but not random access. - bool bBigItIsBidirectionalIterator = boost::is_convertible< - boost::iterator_traversal::type - , boost::bidirectional_traversal_tag - >::value; - - bool bBigItIsRandomAccessIterator = boost::is_convertible< - boost::iterator_traversal::type - , boost::random_access_traversal_tag - >::value; - - // A combining iterator with all vector iterators must have random access - // traversal. - // - typedef boost::zip_iterator< - boost::tuples::tuple< - std::vector::const_iterator, - std::vector::const_iterator - > - > all_vects_type; - - bool bAllVectsIsRandomAccessIterator = boost::is_convertible< - boost::iterator_traversal::type - , boost::random_access_traversal_tag - >::value; - - // The big test. - if( bBigItIsBidirectionalIterator && - ! bBigItIsRandomAccessIterator && - bAllVectsIsRandomAccessIterator - ) - { - ++num_successful_tests; - std::cout << "OK" << std::endl; - } - else - { - ++num_failed_tests = 0; - std::cout << "not OK" << std::endl; - } - - // Done - // - std::cout << "\nTest Result:" - << "\n============" - << "\nNumber of successful tests: " << static_cast(num_successful_tests) - << "\nNumber of failed tests: " << static_cast(num_failed_tests) - << std::endl; - - return num_failed_tests; -} - +#include "detail/zip_iterator_test_original.ipp" diff --git a/test/zip_iterator_test2_fusion_deque.cpp b/test/zip_iterator_test2_fusion_deque.cpp new file mode 100644 index 0000000..82d3b78 --- /dev/null +++ b/test/zip_iterator_test2_fusion_deque.cpp @@ -0,0 +1,9 @@ +#include +#include +#include + +#define ZI_TUPLE boost::fusion::deque +#define ZI_MAKE_TUPLE boost::fusion::make_deque +#define ZI_TUPLE_GET(n) boost::fusion::at_c + +#include "detail/zip_iterator_test_original.ipp" diff --git a/test/zip_iterator_test2_fusion_list.cpp b/test/zip_iterator_test2_fusion_list.cpp new file mode 100644 index 0000000..d410032 --- /dev/null +++ b/test/zip_iterator_test2_fusion_list.cpp @@ -0,0 +1,11 @@ +#include + +#include +#include +#include + +#define ZI_TUPLE boost::fusion::list +#define ZI_MAKE_TUPLE boost::fusion::make_list +#define ZI_TUPLE_GET(n) boost::fusion::at_c + +#include "detail/zip_iterator_test_original.ipp" diff --git a/test/zip_iterator_test2_fusion_vector.cpp b/test/zip_iterator_test2_fusion_vector.cpp new file mode 100644 index 0000000..d9400b0 --- /dev/null +++ b/test/zip_iterator_test2_fusion_vector.cpp @@ -0,0 +1,11 @@ +#include + +#include +#include +#include + +#define ZI_TUPLE boost::fusion::vector +#define ZI_MAKE_TUPLE boost::fusion::make_vector +#define ZI_TUPLE_GET(n) boost::fusion::at_c + +#include "detail/zip_iterator_test_original.ipp" diff --git a/test/zip_iterator_test2_std_tuple.cpp b/test/zip_iterator_test2_std_tuple.cpp new file mode 100644 index 0000000..60b1b97 --- /dev/null +++ b/test/zip_iterator_test2_std_tuple.cpp @@ -0,0 +1,21 @@ +#include + +#if !defined(BOOST_NO_CXX11_HDR_TUPLE) + +#include +#include + +#define ZI_TUPLE std::tuple +#define ZI_MAKE_TUPLE std::make_tuple +#define ZI_TUPLE_GET(n) std::get + +#include "detail/zip_iterator_test_original.ipp" + +#else + +int main() + { + return 0; + } + +#endif From b9448b5fae5f17a240fc8181e476c37213856daa Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Mon, 24 Aug 2015 00:24:09 -0400 Subject: [PATCH 07/13] Updated with an explanation of the new 'tuple' type for a zip_iterator based on Boost fusion sequences. --- doc/quickbook/zip_iterator.qbk | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/quickbook/zip_iterator.qbk b/doc/quickbook/zip_iterator.qbk index 7f97772..ccd8689 100644 --- a/doc/quickbook/zip_iterator.qbk +++ b/doc/quickbook/zip_iterator.qbk @@ -8,6 +8,16 @@ the zip iterator moves all the iterators in parallel. Dereferencing the zip iterator returns a tuple that contains 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] There are two main types of applications of the `zip_iterator`. The first From 87d82527b169c15ad2cfcee89488ce96693daa90 Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Mon, 24 Aug 2015 07:18:03 -0400 Subject: [PATCH 08/13] Updated zip iterator abstract adds information about the iterator 'tuple'. --- doc/zip_iterator_abstract.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/zip_iterator_abstract.rst b/doc/zip_iterator_abstract.rst index 2f4aecf..524c2b1 100644 --- a/doc/zip_iterator_abstract.rst +++ b/doc/zip_iterator_abstract.rst @@ -8,3 +8,13 @@ iterator is constructed from a tuple of iterators. Moving the zip iterator moves all the iterators in parallel. Dereferencing the zip iterator returns a tuple that contains 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'. From 398bbe63bb75912dc5bfa95dda9dfe850c2c8353 Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Mon, 24 Aug 2015 12:49:59 -0400 Subject: [PATCH 09/13] Updated quickbook docs just fix problems exposed by upgrading to quickbook 1.6 --- doc/quickbook/adaptor.qbk | 4 ++-- doc/quickbook/concepts.qbk | 4 ++-- doc/quickbook/counting_iterator.qbk | 6 +++--- doc/quickbook/facade.qbk | 20 +++++++++++++++++++- doc/quickbook/facade_tutorial.qbk | 8 ++++---- doc/quickbook/filter_iterator.qbk | 10 +++++----- doc/quickbook/indirect_iterator.qbk | 8 ++++---- doc/quickbook/iterator.qbk | 3 ++- doc/quickbook/permutation_iterator.qbk | 2 +- doc/quickbook/reverse_iterator.qbk | 8 ++++---- doc/quickbook/transform_iterator.qbk | 10 +++++----- doc/quickbook/utilities.qbk | 8 ++++---- doc/quickbook/zip_iterator.qbk | 6 +++--- 13 files changed, 58 insertions(+), 39 deletions(-) diff --git a/doc/quickbook/adaptor.qbk b/doc/quickbook/adaptor.qbk index cdef018..d791ce0 100644 --- a/doc/quickbook/adaptor.qbk +++ b/doc/quickbook/adaptor.qbk @@ -132,7 +132,7 @@ above are defined as follows: 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 `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: 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` is an abstract class: a pointer to a `node_base` just points at some base subobject of an instance of some other class, and diff --git a/doc/quickbook/concepts.qbk b/doc/quickbook/concepts.qbk index 13d429b..679d1a8 100644 --- a/doc/quickbook/concepts.qbk +++ b/doc/quickbook/concepts.qbk @@ -156,7 +156,7 @@ semantics. [ [`++r`] [`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`] @@ -227,7 +227,7 @@ the stated semantics. [ [`--r`] [`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--`] diff --git a/doc/quickbook/counting_iterator.qbk b/doc/quickbook/counting_iterator.qbk index fad4904..c33d065 100644 --- a/doc/quickbook/counting_iterator.qbk +++ b/doc/quickbook/counting_iterator.qbk @@ -152,7 +152,7 @@ operations. counting_iterator(); -[*Requires: ] `Incrementable` is Default Constructible.\n +[*Requires: ] `Incrementable` is Default Constructible.[br] [*Effects: ] Default construct the member `m_inc`. @@ -174,13 +174,13 @@ operations. counting_iterator& operator++(); -[*Effects: ] `++m_inc`\n +[*Effects: ] `++m_inc`[br] [*Returns: ] `*this` counting_iterator& operator--(); -[*Effects: ] `--m_inc`\n +[*Effects: ] `--m_inc`[br] [*Returns: ] `*this` diff --git a/doc/quickbook/facade.qbk b/doc/quickbook/facade.qbk index ed62e47..ac7104f 100644 --- a/doc/quickbook/facade.qbk +++ b/doc/quickbook/facade.qbk @@ -68,6 +68,7 @@ requirements. [ [`i.dereference()`] [Access the value referred to] + ] [ [`i.equal(j)`] [Compare for equality with `j`] @@ -83,6 +84,7 @@ requirements. [ [`i.advance(n)`] [Advance by `n` positions] + ] [ [`i.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 const& rhs); [*Returns:] - + +[pre if `is_convertible::value` then @@ -495,6 +498,7 @@ w.m)` for some temporary object `w` of type `value_type`. Otherwise, `((Dr2 const&)rhs).equal((Dr1 const&)lhs)`. +] template ::value` then @@ -512,6 +517,7 @@ w.m)` for some temporary object `w` of type `value_type`. Otherwise, `!((Dr2 const&)rhs).equal((Dr1 const&)lhs)`. +] template ::value` then @@ -529,6 +536,7 @@ w.m)` for some temporary object `w` of type `value_type`. Otherwise, `((Dr2 const&)rhs).distance_to((Dr1 const&)lhs) > 0`. +] template ::value` then @@ -546,6 +555,7 @@ w.m)` for some temporary object `w` of type `value_type`. Otherwise, `((Dr2 const&)rhs).distance_to((Dr1 const&)lhs) >= 0`. +] template ::value` then @@ -563,6 +574,7 @@ w.m)` for some temporary object `w` of type `value_type`. Otherwise, `((Dr2 const&)rhs).distance_to((Dr1 const&)lhs) < 0`. +] template ::value` then @@ -580,6 +593,7 @@ w.m)` for some temporary object `w` of type `value_type`. Otherwise, `((Dr2 const&)rhs).distance_to((Dr1 const&)lhs) <= 0`. +] .. _minus: @@ -592,6 +606,7 @@ w.m)` for some temporary object `w` of type `value_type`. [*Return Type:] +[pre if `is_convertible::value` then @@ -600,9 +615,11 @@ w.m)` for some temporary object `w` of type `value_type`. Otherwise `difference` shall be `iterator_traits::difference_type` +] [*Returns:] +[pre if `is_convertible::value` then @@ -610,6 +627,7 @@ w.m)` for some temporary object `w` of type `value_type`. Otherwise, `((Dr2 const&)rhs).distance_to((Dr1 const&)lhs)`. +] [endsect] diff --git a/doc/quickbook/facade_tutorial.qbk b/doc/quickbook/facade_tutorial.qbk index 09682ac..756c11e 100644 --- a/doc/quickbook/facade_tutorial.qbk +++ b/doc/quickbook/facade_tutorial.qbk @@ -261,17 +261,17 @@ __ ../example/node_iterator1.cpp [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 object it references (its "referent") can be modified. A **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 modify the iterator itself. For example, an `int const*` is a non-\ `const` *constant iterator*, which can be incremented but doesn't allow modification of its referent, and `int* 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 probably doesn't help much that a container's constant iterator is called `const_iterator`. @@ -312,7 +312,7 @@ changes: 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 `const`\ -qualified, so `iterator_facade` strips the `const` from its `Value` parameter in order to produce the diff --git a/doc/quickbook/filter_iterator.qbk b/doc/quickbook/filter_iterator.qbk index 5a46000..5076353 100644 --- a/doc/quickbook/filter_iterator.qbk +++ b/doc/quickbook/filter_iterator.qbk @@ -178,7 +178,7 @@ operations. 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` members are a default constructed. @@ -195,7 +195,7 @@ operations. filter_iterator(Iterator x, Iterator end = Iterator()); [*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 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. @@ -205,9 +205,9 @@ operations. filter_iterator( filter_iterator const& t , typename enable_if_convertible::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`. @@ -235,7 +235,7 @@ operations. [*Effects: ] Increments `m_iter` and then continues to 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` diff --git a/doc/quickbook/indirect_iterator.qbk b/doc/quickbook/indirect_iterator.qbk index af53d86..2556aa2 100644 --- a/doc/quickbook/indirect_iterator.qbk +++ b/doc/quickbook/indirect_iterator.qbk @@ -203,7 +203,7 @@ following operations: indirect_iterator(); -[*Requires: ] `Iterator` must be Default Constructible.\n +[*Requires: ] `Iterator` must be Default Constructible.[br] [*Effects: ] Constructs an instance of `indirect_iterator` with a default-constructed `m_iterator`. @@ -225,7 +225,7 @@ following operations: , typename enable_if_convertible::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 `m_iterator` subobject is constructed from `y.base()`. @@ -242,13 +242,13 @@ following operations: indirect_iterator& operator++(); -[*Effects: ] `++m_iterator`\n +[*Effects: ] `++m_iterator`[br] [*Returns: ] `*this` indirect_iterator& operator--(); -[*Effects: ] `--m_iterator`\n +[*Effects: ] `--m_iterator`[br] [*Returns: ] `*this` [endsect] \ No newline at end of file diff --git a/doc/quickbook/iterator.qbk b/doc/quickbook/iterator.qbk index 9c7c4b7..0ec20b2 100644 --- a/doc/quickbook/iterator.qbk +++ b/doc/quickbook/iterator.qbk @@ -1,6 +1,7 @@ [library Boost.Iterator [/ version 1.0.1] + [quickbook 1.6] [authors [Abrahams, David], [Siek, Jeremy], [Witt, Thomas]] [copyright 2003 2005 David Abrahams Jeremy Siek Thomas Witt] [category iterator] @@ -99,7 +100,7 @@ adaptors`_ mentioned below have been proposed for standardization The iterator library supplies a useful suite of standard-conforming 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. [def _counting_ [@./counting_iterator.html `counting_iterator`]] diff --git a/doc/quickbook/permutation_iterator.qbk b/doc/quickbook/permutation_iterator.qbk index 718a368..81352b6 100644 --- a/doc/quickbook/permutation_iterator.qbk +++ b/doc/quickbook/permutation_iterator.qbk @@ -189,7 +189,7 @@ following operations. permutation_iterator& operator++(); -[*Effects: ] `++m_order`\n +[*Effects: ] `++m_order`[br] [*Returns: ] `*this` diff --git a/doc/quickbook/reverse_iterator.qbk b/doc/quickbook/reverse_iterator.qbk index c9973ca..2599105 100644 --- a/doc/quickbook/reverse_iterator.qbk +++ b/doc/quickbook/reverse_iterator.qbk @@ -115,7 +115,7 @@ operations. 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` default constructed. @@ -131,7 +131,7 @@ operations. , typename enable_if_convertible::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 `m_iterator` subobject is constructed from `y.base()`. @@ -149,12 +149,12 @@ operations. reverse_iterator& operator++(); -[*Effects: ] `--m_iterator`\n +[*Effects: ] `--m_iterator`[br] [*Returns: ] `*this` reverse_iterator& operator--(); -[*Effects: ] `++m_iterator`\n +[*Effects: ] `++m_iterator`[br] [*Returns: ] `*this` [endsect] \ No newline at end of file diff --git a/doc/quickbook/transform_iterator.qbk b/doc/quickbook/transform_iterator.qbk index 04416a1..adf30b8 100644 --- a/doc/quickbook/transform_iterator.qbk +++ b/doc/quickbook/transform_iterator.qbk @@ -85,7 +85,7 @@ The source code for this example can be found If `Reference` is `use_default` then the `reference` member of -`transform_iterator` is\n +`transform_iterator` is[br] `result_of::reference)>::type`. Otherwise, `reference` is `Reference`. @@ -160,7 +160,7 @@ interoperable with `Y`. [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 operations: @@ -183,7 +183,7 @@ operations: [*Returns: ] An instance of `transform_iterator` with `m_f` initialized to `t.functor()` and `m_iterator` initialized to - `t.base()`.\n + `t.base()`.[br] [*Requires: ] `OtherIterator` is implicitly convertible to `Iterator`. @@ -204,13 +204,13 @@ operations: transform_iterator& operator++(); -[*Effects: ] `++m_iterator`\n +[*Effects: ] `++m_iterator`[br] [*Returns: ] `*this` transform_iterator& operator--(); -[*Effects: ] `--m_iterator`\n +[*Effects: ] `--m_iterator`[br] [*Returns: ] `*this` [endsect] diff --git a/doc/quickbook/utilities.qbk b/doc/quickbook/utilities.qbk index 3e001a2..d219842 100644 --- a/doc/quickbook/utilities.qbk +++ b/doc/quickbook/utilities.qbk @@ -49,7 +49,7 @@ proxy references or return the pointee by value. When that information is needed, call on `indirect_reference`. 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`] @@ -103,9 +103,9 @@ or not), these additional tags are not considered. 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::value_type) { return iterator_traits::value_type @@ -135,7 +135,7 @@ or not), these additional tags are not considered. `x` is an object of type `Dereferenceable`: if ( ++x is ill-formed ) - return `pointee::type&` + return pointee::type& else std::iterator_traits::reference diff --git a/doc/quickbook/zip_iterator.qbk b/doc/quickbook/zip_iterator.qbk index ccd8689..6395538 100644 --- a/doc/quickbook/zip_iterator.qbk +++ b/doc/quickbook/zip_iterator.qbk @@ -228,7 +228,7 @@ operations. , 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`. @@ -245,13 +245,13 @@ operations. zip_iterator& operator++(); -[*Effects:] Increments each iterator in `m_iterator_tuple`.\n +[*Effects:] Increments each iterator in `m_iterator_tuple`.[br] [*Returns:] `*this` zip_iterator& operator--(); -[*Effects:] Decrements each iterator in `m_iterator_tuple`.\n +[*Effects:] Decrements each iterator in `m_iterator_tuple`.[br] [*Returns:] `*this` template From 80e6f4a3bf001ec110765242a499032c1d454937 Mon Sep 17 00:00:00 2001 From: Marcel Raad Date: Mon, 14 Sep 2015 09:34:02 +0200 Subject: [PATCH 10/13] Remove unused deprecated includes A comment in boost/iterator.hpp and boost/detail/iterator.hpp mentions that the files are obsolete and will be deprecated. All they do is pull some types from namespace std into namespace boost. --- include/boost/iterator/filter_iterator.hpp | 1 - include/boost/iterator/indirect_iterator.hpp | 6 +++--- include/boost/iterator/is_lvalue_iterator.hpp | 9 ++++----- .../boost/iterator/is_readable_iterator.hpp | 5 +++-- include/boost/iterator/iterator_adaptor.hpp | 2 -- .../boost/iterator/iterator_archetypes.hpp | 1 - .../boost/iterator/iterator_categories.hpp | 5 +++-- include/boost/iterator/iterator_concepts.hpp | 18 ++++++++---------- include/boost/iterator/iterator_facade.hpp | 3 ++- include/boost/iterator/iterator_traits.hpp | 13 +++++++------ include/boost/iterator/new_iterator_tests.hpp | 19 +++++++++---------- .../boost/iterator/permutation_iterator.hpp | 8 ++++---- include/boost/iterator/reverse_iterator.hpp | 1 - include/boost/iterator/transform_iterator.hpp | 4 ++-- include/boost/iterator/zip_iterator.hpp | 1 - include/boost/pending/detail/int_iterator.hpp | 3 ++- include/boost/pointee.hpp | 4 +++- 17 files changed, 50 insertions(+), 53 deletions(-) diff --git a/include/boost/iterator/filter_iterator.hpp b/include/boost/iterator/filter_iterator.hpp index 58aea33..b87c02b 100644 --- a/include/boost/iterator/filter_iterator.hpp +++ b/include/boost/iterator/filter_iterator.hpp @@ -7,7 +7,6 @@ #ifndef BOOST_FILTER_ITERATOR_23022003THW_HPP #define BOOST_FILTER_ITERATOR_23022003THW_HPP -#include #include #include diff --git a/include/boost/iterator/indirect_iterator.hpp b/include/boost/iterator/indirect_iterator.hpp index c16eb84..7449d62 100644 --- a/include/boost/iterator/indirect_iterator.hpp +++ b/include/boost/iterator/indirect_iterator.hpp @@ -7,12 +7,10 @@ #ifndef BOOST_INDIRECT_ITERATOR_23022003THW_HPP #define BOOST_INDIRECT_ITERATOR_23022003THW_HPP -#include #include #include #include -#include #include @@ -25,6 +23,8 @@ #include #include +#include + #ifdef BOOST_MPL_CFG_NO_HAS_XXX # include # include @@ -45,7 +45,7 @@ namespace iterators { template struct indirect_base { - typedef typename boost::detail::iterator_traits::value_type dereferenceable; + typedef typename std::iterator_traits::value_type dereferenceable; typedef iterator_adaptor< indirect_iterator diff --git a/include/boost/iterator/is_lvalue_iterator.hpp b/include/boost/iterator/is_lvalue_iterator.hpp index e821da9..46f0483 100644 --- a/include/boost/iterator/is_lvalue_iterator.hpp +++ b/include/boost/iterator/is_lvalue_iterator.hpp @@ -4,16 +4,15 @@ #ifndef IS_LVALUE_ITERATOR_DWA2003112_HPP # define IS_LVALUE_ITERATOR_DWA2003112_HPP -#include - #include -#include #include #include #include #include +#include + // should be the last #includes #include #include @@ -125,14 +124,14 @@ namespace detail template struct is_readable_lvalue_iterator_impl : is_lvalue_iterator_impl< - BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::value_type const + BOOST_DEDUCED_TYPENAME std::iterator_traits::value_type const >::template rebind {}; template struct is_non_const_lvalue_iterator_impl : is_lvalue_iterator_impl< - BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::value_type + BOOST_DEDUCED_TYPENAME std::iterator_traits::value_type >::template rebind {}; } // namespace detail diff --git a/include/boost/iterator/is_readable_iterator.hpp b/include/boost/iterator/is_readable_iterator.hpp index 5bc2339..26827c4 100644 --- a/include/boost/iterator/is_readable_iterator.hpp +++ b/include/boost/iterator/is_readable_iterator.hpp @@ -6,11 +6,12 @@ #include #include -#include #include #include +#include + // should be the last #include #include #include @@ -93,7 +94,7 @@ namespace detail template struct is_readable_iterator_impl2 : is_readable_iterator_impl< - BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::value_type const + BOOST_DEDUCED_TYPENAME std::iterator_traits::value_type const >::template rebind {}; } // namespace detail diff --git a/include/boost/iterator/iterator_adaptor.hpp b/include/boost/iterator/iterator_adaptor.hpp index 87cfd05..f803fc6 100644 --- a/include/boost/iterator/iterator_adaptor.hpp +++ b/include/boost/iterator/iterator_adaptor.hpp @@ -8,8 +8,6 @@ #define BOOST_ITERATOR_ADAPTOR_23022003THW_HPP #include -#include -#include #include #include diff --git a/include/boost/iterator/iterator_archetypes.hpp b/include/boost/iterator/iterator_archetypes.hpp index 3e9d444..9b4b543 100644 --- a/include/boost/iterator/iterator_archetypes.hpp +++ b/include/boost/iterator/iterator_archetypes.hpp @@ -9,7 +9,6 @@ #include #include #include -#include #include diff --git a/include/boost/iterator/iterator_categories.hpp b/include/boost/iterator/iterator_categories.hpp index 71202c9..baf805a 100644 --- a/include/boost/iterator/iterator_categories.hpp +++ b/include/boost/iterator/iterator_categories.hpp @@ -7,7 +7,6 @@ # define BOOST_ITERATOR_CATEGORIES_HPP # include -# include # include # include @@ -21,6 +20,8 @@ # include +#include + namespace boost { namespace iterators { @@ -116,7 +117,7 @@ struct iterator_category_to_traversal template struct iterator_traversal : iterator_category_to_traversal< - typename boost::detail::iterator_traits::iterator_category + typename std::iterator_traits::iterator_category > {}; diff --git a/include/boost/iterator/iterator_concepts.hpp b/include/boost/iterator/iterator_concepts.hpp index 1a9f7d6..415cc49 100644 --- a/include/boost/iterator/iterator_concepts.hpp +++ b/include/boost/iterator/iterator_concepts.hpp @@ -9,9 +9,6 @@ #include #include -// Use boost::detail::iterator_traits to work around some MSVC/Dinkumware problems. -#include - #include #include @@ -27,6 +24,7 @@ #include #include +#include #include @@ -44,8 +42,8 @@ namespace boost_concepts , boost::CopyConstructible { - typedef BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::value_type value_type; - typedef BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::reference reference; + typedef BOOST_DEDUCED_TYPENAME std::iterator_traits::value_type value_type; + typedef BOOST_DEDUCED_TYPENAME std::iterator_traits::reference reference; BOOST_CONCEPT_USAGE(ReadableIterator) { @@ -59,7 +57,7 @@ namespace boost_concepts template < typename Iterator - , typename ValueType = BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::value_type + , typename ValueType = BOOST_DEDUCED_TYPENAME std::iterator_traits::value_type > struct WritableIterator : boost::CopyConstructible @@ -75,7 +73,7 @@ namespace boost_concepts template < typename Iterator - , typename ValueType = BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::value_type + , typename ValueType = BOOST_DEDUCED_TYPENAME std::iterator_traits::value_type > struct WritableIteratorConcept : WritableIterator {}; @@ -92,7 +90,7 @@ namespace boost_concepts BOOST_concept(LvalueIterator,(Iterator)) { - typedef typename boost::detail::iterator_traits::value_type value_type; + typedef typename std::iterator_traits::value_type value_type; BOOST_CONCEPT_USAGE(LvalueIterator) { @@ -144,7 +142,7 @@ namespace boost_concepts : SinglePassIterator , boost::DefaultConstructible { - typedef typename boost::detail::iterator_traits::difference_type difference_type; + typedef typename std::iterator_traits::difference_type difference_type; BOOST_MPL_ASSERT((boost::is_integral)); BOOST_MPL_ASSERT_RELATION(std::numeric_limits::is_signed, ==, true); @@ -221,7 +219,7 @@ namespace boost_concepts boost::random_access_traversal_tag, boost::random_access_traversal_tag) { bool b; - typename boost::detail::iterator_traits::difference_type n; + typename std::iterator_traits::difference_type n; b = i1 < i2; b = i1 <= i2; b = i1 > i2; diff --git a/include/boost/iterator/iterator_facade.hpp b/include/boost/iterator/iterator_facade.hpp index 7b11d0a..225c53a 100644 --- a/include/boost/iterator/iterator_facade.hpp +++ b/include/boost/iterator/iterator_facade.hpp @@ -8,7 +8,6 @@ #define BOOST_ITERATOR_FACADE_23022003THW_HPP #include -#include #include #include #include @@ -37,6 +36,8 @@ #include #include +#include + #include // this goes last namespace boost { diff --git a/include/boost/iterator/iterator_traits.hpp b/include/boost/iterator/iterator_traits.hpp index 1a5f1e0..6582a68 100644 --- a/include/boost/iterator/iterator_traits.hpp +++ b/include/boost/iterator/iterator_traits.hpp @@ -5,9 +5,10 @@ #ifndef ITERATOR_TRAITS_DWA200347_HPP # define ITERATOR_TRAITS_DWA200347_HPP -# include # include +#include + namespace boost { namespace iterators { @@ -19,32 +20,32 @@ namespace iterators { template struct iterator_value { - typedef typename boost::detail::iterator_traits::value_type type; + typedef typename std::iterator_traits::value_type type; }; template struct iterator_reference { - typedef typename boost::detail::iterator_traits::reference type; + typedef typename std::iterator_traits::reference type; }; template struct iterator_pointer { - typedef typename boost::detail::iterator_traits::pointer type; + typedef typename std::iterator_traits::pointer type; }; template struct iterator_difference { - typedef typename boost::detail::iterator_traits::difference_type type; + typedef typename std::iterator_traits::difference_type type; }; template struct iterator_category { - typedef typename boost::detail::iterator_traits::iterator_category type; + typedef typename std::iterator_traits::iterator_category type; }; } // namespace iterators diff --git a/include/boost/iterator/new_iterator_tests.hpp b/include/boost/iterator/new_iterator_tests.hpp index caad700..cb9b107 100644 --- a/include/boost/iterator/new_iterator_tests.hpp +++ b/include/boost/iterator/new_iterator_tests.hpp @@ -32,7 +32,6 @@ # include # include # include // for detail::dummy_constructor -# include # include # include # include @@ -76,7 +75,7 @@ template void readable_iterator_test(const Iterator i1, T v) { Iterator i2(i1); // Copy Constructible - typedef typename detail::iterator_traits::reference ref_t; + typedef typename std::iterator_traits::reference ref_t; ref_t r1 = *i1; ref_t r2 = *i2; T v1 = r1; @@ -112,9 +111,9 @@ template void swappable_iterator_test(Iterator i, Iterator j) { Iterator i2(i), j2(j); - typename detail::iterator_traits::value_type bi = *i, bj = *j; + typename std::iterator_traits::value_type bi = *i, bj = *j; iter_swap(i2, j2); - typename detail::iterator_traits::value_type ai = *i, aj = *j; + typename std::iterator_traits::value_type ai = *i, aj = *j; BOOST_TEST(bi == aj && bj == ai); } @@ -122,8 +121,8 @@ template void constant_lvalue_iterator_test(Iterator i, T v1) { Iterator i2(i); - typedef typename detail::iterator_traits::value_type value_type; - typedef typename detail::iterator_traits::reference reference; + typedef typename std::iterator_traits::value_type value_type; + typedef typename std::iterator_traits::reference reference; BOOST_STATIC_ASSERT((is_same::value)); const T& v2 = *i2; BOOST_TEST(v1 == v2); @@ -137,8 +136,8 @@ template void non_const_lvalue_iterator_test(Iterator i, T v1, T v2) { Iterator i2(i); - typedef typename detail::iterator_traits::value_type value_type; - typedef typename detail::iterator_traits::reference reference; + typedef typename std::iterator_traits::value_type value_type; + typedef typename std::iterator_traits::reference reference; BOOST_STATIC_ASSERT((is_same::value)); T& v3 = *i2; 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 == vals[c]); - typename detail::iterator_traits::value_type x = j[c]; + typename std::iterator_traits::value_type x = j[c]; BOOST_TEST(*i == x); BOOST_TEST(*i == *(j + c)); 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 == vals[N - 1 - c]); - typename detail::iterator_traits::value_type x = j[N - 1 - c]; + typename std::iterator_traits::value_type x = j[N - 1 - c]; BOOST_TEST(*i == x); Iterator q = k - c; BOOST_TEST(*i == *q); diff --git a/include/boost/iterator/permutation_iterator.hpp b/include/boost/iterator/permutation_iterator.hpp index 32648b0..3876f3d 100644 --- a/include/boost/iterator/permutation_iterator.hpp +++ b/include/boost/iterator/permutation_iterator.hpp @@ -21,13 +21,13 @@ template< class ElementIterator class permutation_iterator : public iterator_adaptor< permutation_iterator - , IndexIterator, typename boost::detail::iterator_traits::value_type - , use_default, typename boost::detail::iterator_traits::reference> + , IndexIterator, typename std::iterator_traits::value_type + , use_default, typename std::iterator_traits::reference> { typedef iterator_adaptor< permutation_iterator - , IndexIterator, typename boost::detail::iterator_traits::value_type - , use_default, typename boost::detail::iterator_traits::reference> super_t; + , IndexIterator, typename std::iterator_traits::value_type + , use_default, typename std::iterator_traits::reference> super_t; friend class iterator_core_access; diff --git a/include/boost/iterator/reverse_iterator.hpp b/include/boost/iterator/reverse_iterator.hpp index 3bef39e..7dcf645 100644 --- a/include/boost/iterator/reverse_iterator.hpp +++ b/include/boost/iterator/reverse_iterator.hpp @@ -8,7 +8,6 @@ #define BOOST_REVERSE_ITERATOR_23022003THW_HPP #include -#include #include namespace boost { diff --git a/include/boost/iterator/transform_iterator.hpp b/include/boost/iterator/transform_iterator.hpp index 851f16f..67356ff 100644 --- a/include/boost/iterator/transform_iterator.hpp +++ b/include/boost/iterator/transform_iterator.hpp @@ -7,7 +7,6 @@ #ifndef BOOST_TRANSFORM_ITERATOR_23022003THW_HPP #define BOOST_TRANSFORM_ITERATOR_23022003THW_HPP -#include #include #include #include @@ -22,11 +21,12 @@ #include #include +#include #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310)) # include - #endif + #include diff --git a/include/boost/iterator/zip_iterator.hpp b/include/boost/iterator/zip_iterator.hpp index 83fa63b..61d1f17 100644 --- a/include/boost/iterator/zip_iterator.hpp +++ b/include/boost/iterator/zip_iterator.hpp @@ -9,7 +9,6 @@ # define BOOST_ZIP_ITERATOR_TMB_07_13_2003_HPP_ #include -#include #include #include #include // for enable_if_convertible diff --git a/include/boost/pending/detail/int_iterator.hpp b/include/boost/pending/detail/int_iterator.hpp index ca8372b..dcc7024 100644 --- a/include/boost/pending/detail/int_iterator.hpp +++ b/include/boost/pending/detail/int_iterator.hpp @@ -6,11 +6,12 @@ #ifndef BOOST_INT_ITERATOR_H #define BOOST_INT_ITERATOR_H -#include #if !defined BOOST_MSVC #include #endif #include +#include +#include //using namespace std; #ifndef BOOST_NO_OPERATORS_IN_NAMESPACE diff --git a/include/boost/pointee.hpp b/include/boost/pointee.hpp index 0f561b8..f3bcf44 100644 --- a/include/boost/pointee.hpp +++ b/include/boost/pointee.hpp @@ -20,6 +20,8 @@ # include # include +#include + namespace boost { namespace detail @@ -33,7 +35,7 @@ namespace detail template struct iterator_pointee { - typedef typename iterator_traits::value_type value_type; + typedef typename std::iterator_traits::value_type value_type; struct impl { From 922296f8c83130b41adbdcc52d47977514302ca2 Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Mon, 14 Sep 2015 08:16:43 -0400 Subject: [PATCH 11/13] Revert "Remove unused deprecated includes" --- include/boost/iterator/filter_iterator.hpp | 1 + include/boost/iterator/indirect_iterator.hpp | 6 +++--- include/boost/iterator/is_lvalue_iterator.hpp | 9 +++++---- .../boost/iterator/is_readable_iterator.hpp | 5 ++--- include/boost/iterator/iterator_adaptor.hpp | 2 ++ .../boost/iterator/iterator_archetypes.hpp | 1 + .../boost/iterator/iterator_categories.hpp | 5 ++--- include/boost/iterator/iterator_concepts.hpp | 18 ++++++++++-------- include/boost/iterator/iterator_facade.hpp | 3 +-- include/boost/iterator/iterator_traits.hpp | 13 ++++++------- include/boost/iterator/new_iterator_tests.hpp | 19 ++++++++++--------- .../boost/iterator/permutation_iterator.hpp | 8 ++++---- include/boost/iterator/reverse_iterator.hpp | 1 + include/boost/iterator/transform_iterator.hpp | 4 ++-- include/boost/iterator/zip_iterator.hpp | 1 + include/boost/pending/detail/int_iterator.hpp | 3 +-- include/boost/pointee.hpp | 4 +--- 17 files changed, 53 insertions(+), 50 deletions(-) diff --git a/include/boost/iterator/filter_iterator.hpp b/include/boost/iterator/filter_iterator.hpp index b87c02b..58aea33 100644 --- a/include/boost/iterator/filter_iterator.hpp +++ b/include/boost/iterator/filter_iterator.hpp @@ -7,6 +7,7 @@ #ifndef BOOST_FILTER_ITERATOR_23022003THW_HPP #define BOOST_FILTER_ITERATOR_23022003THW_HPP +#include #include #include diff --git a/include/boost/iterator/indirect_iterator.hpp b/include/boost/iterator/indirect_iterator.hpp index 7449d62..c16eb84 100644 --- a/include/boost/iterator/indirect_iterator.hpp +++ b/include/boost/iterator/indirect_iterator.hpp @@ -7,10 +7,12 @@ #ifndef BOOST_INDIRECT_ITERATOR_23022003THW_HPP #define BOOST_INDIRECT_ITERATOR_23022003THW_HPP +#include #include #include #include +#include #include @@ -23,8 +25,6 @@ #include #include -#include - #ifdef BOOST_MPL_CFG_NO_HAS_XXX # include # include @@ -45,7 +45,7 @@ namespace iterators { template struct indirect_base { - typedef typename std::iterator_traits::value_type dereferenceable; + typedef typename boost::detail::iterator_traits::value_type dereferenceable; typedef iterator_adaptor< indirect_iterator diff --git a/include/boost/iterator/is_lvalue_iterator.hpp b/include/boost/iterator/is_lvalue_iterator.hpp index 46f0483..e821da9 100644 --- a/include/boost/iterator/is_lvalue_iterator.hpp +++ b/include/boost/iterator/is_lvalue_iterator.hpp @@ -4,15 +4,16 @@ #ifndef IS_LVALUE_ITERATOR_DWA2003112_HPP # define IS_LVALUE_ITERATOR_DWA2003112_HPP +#include + #include +#include #include #include #include #include -#include - // should be the last #includes #include #include @@ -124,14 +125,14 @@ namespace detail template struct is_readable_lvalue_iterator_impl : is_lvalue_iterator_impl< - BOOST_DEDUCED_TYPENAME std::iterator_traits::value_type const + BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::value_type const >::template rebind {}; template struct is_non_const_lvalue_iterator_impl : is_lvalue_iterator_impl< - BOOST_DEDUCED_TYPENAME std::iterator_traits::value_type + BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::value_type >::template rebind {}; } // namespace detail diff --git a/include/boost/iterator/is_readable_iterator.hpp b/include/boost/iterator/is_readable_iterator.hpp index 26827c4..5bc2339 100644 --- a/include/boost/iterator/is_readable_iterator.hpp +++ b/include/boost/iterator/is_readable_iterator.hpp @@ -6,12 +6,11 @@ #include #include +#include #include #include -#include - // should be the last #include #include #include @@ -94,7 +93,7 @@ namespace detail template struct is_readable_iterator_impl2 : is_readable_iterator_impl< - BOOST_DEDUCED_TYPENAME std::iterator_traits::value_type const + BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::value_type const >::template rebind {}; } // namespace detail diff --git a/include/boost/iterator/iterator_adaptor.hpp b/include/boost/iterator/iterator_adaptor.hpp index f803fc6..87cfd05 100644 --- a/include/boost/iterator/iterator_adaptor.hpp +++ b/include/boost/iterator/iterator_adaptor.hpp @@ -8,6 +8,8 @@ #define BOOST_ITERATOR_ADAPTOR_23022003THW_HPP #include +#include +#include #include #include diff --git a/include/boost/iterator/iterator_archetypes.hpp b/include/boost/iterator/iterator_archetypes.hpp index 9b4b543..3e9d444 100644 --- a/include/boost/iterator/iterator_archetypes.hpp +++ b/include/boost/iterator/iterator_archetypes.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include diff --git a/include/boost/iterator/iterator_categories.hpp b/include/boost/iterator/iterator_categories.hpp index baf805a..71202c9 100644 --- a/include/boost/iterator/iterator_categories.hpp +++ b/include/boost/iterator/iterator_categories.hpp @@ -7,6 +7,7 @@ # define BOOST_ITERATOR_CATEGORIES_HPP # include +# include # include # include @@ -20,8 +21,6 @@ # include -#include - namespace boost { namespace iterators { @@ -117,7 +116,7 @@ struct iterator_category_to_traversal template struct iterator_traversal : iterator_category_to_traversal< - typename std::iterator_traits::iterator_category + typename boost::detail::iterator_traits::iterator_category > {}; diff --git a/include/boost/iterator/iterator_concepts.hpp b/include/boost/iterator/iterator_concepts.hpp index 415cc49..1a9f7d6 100644 --- a/include/boost/iterator/iterator_concepts.hpp +++ b/include/boost/iterator/iterator_concepts.hpp @@ -9,6 +9,9 @@ #include #include +// Use boost::detail::iterator_traits to work around some MSVC/Dinkumware problems. +#include + #include #include @@ -24,7 +27,6 @@ #include #include -#include #include @@ -42,8 +44,8 @@ namespace boost_concepts , boost::CopyConstructible { - typedef BOOST_DEDUCED_TYPENAME std::iterator_traits::value_type value_type; - typedef BOOST_DEDUCED_TYPENAME std::iterator_traits::reference reference; + typedef BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::value_type value_type; + typedef BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::reference reference; BOOST_CONCEPT_USAGE(ReadableIterator) { @@ -57,7 +59,7 @@ namespace boost_concepts template < typename Iterator - , typename ValueType = BOOST_DEDUCED_TYPENAME std::iterator_traits::value_type + , typename ValueType = BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::value_type > struct WritableIterator : boost::CopyConstructible @@ -73,7 +75,7 @@ namespace boost_concepts template < typename Iterator - , typename ValueType = BOOST_DEDUCED_TYPENAME std::iterator_traits::value_type + , typename ValueType = BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::value_type > struct WritableIteratorConcept : WritableIterator {}; @@ -90,7 +92,7 @@ namespace boost_concepts BOOST_concept(LvalueIterator,(Iterator)) { - typedef typename std::iterator_traits::value_type value_type; + typedef typename boost::detail::iterator_traits::value_type value_type; BOOST_CONCEPT_USAGE(LvalueIterator) { @@ -142,7 +144,7 @@ namespace boost_concepts : SinglePassIterator , boost::DefaultConstructible { - typedef typename std::iterator_traits::difference_type difference_type; + typedef typename boost::detail::iterator_traits::difference_type difference_type; BOOST_MPL_ASSERT((boost::is_integral)); BOOST_MPL_ASSERT_RELATION(std::numeric_limits::is_signed, ==, true); @@ -219,7 +221,7 @@ namespace boost_concepts boost::random_access_traversal_tag, boost::random_access_traversal_tag) { bool b; - typename std::iterator_traits::difference_type n; + typename boost::detail::iterator_traits::difference_type n; b = i1 < i2; b = i1 <= i2; b = i1 > i2; diff --git a/include/boost/iterator/iterator_facade.hpp b/include/boost/iterator/iterator_facade.hpp index 225c53a..7b11d0a 100644 --- a/include/boost/iterator/iterator_facade.hpp +++ b/include/boost/iterator/iterator_facade.hpp @@ -8,6 +8,7 @@ #define BOOST_ITERATOR_FACADE_23022003THW_HPP #include +#include #include #include #include @@ -36,8 +37,6 @@ #include #include -#include - #include // this goes last namespace boost { diff --git a/include/boost/iterator/iterator_traits.hpp b/include/boost/iterator/iterator_traits.hpp index 6582a68..1a5f1e0 100644 --- a/include/boost/iterator/iterator_traits.hpp +++ b/include/boost/iterator/iterator_traits.hpp @@ -5,10 +5,9 @@ #ifndef ITERATOR_TRAITS_DWA200347_HPP # define ITERATOR_TRAITS_DWA200347_HPP +# include # include -#include - namespace boost { namespace iterators { @@ -20,32 +19,32 @@ namespace iterators { template struct iterator_value { - typedef typename std::iterator_traits::value_type type; + typedef typename boost::detail::iterator_traits::value_type type; }; template struct iterator_reference { - typedef typename std::iterator_traits::reference type; + typedef typename boost::detail::iterator_traits::reference type; }; template struct iterator_pointer { - typedef typename std::iterator_traits::pointer type; + typedef typename boost::detail::iterator_traits::pointer type; }; template struct iterator_difference { - typedef typename std::iterator_traits::difference_type type; + typedef typename boost::detail::iterator_traits::difference_type type; }; template struct iterator_category { - typedef typename std::iterator_traits::iterator_category type; + typedef typename boost::detail::iterator_traits::iterator_category type; }; } // namespace iterators diff --git a/include/boost/iterator/new_iterator_tests.hpp b/include/boost/iterator/new_iterator_tests.hpp index cb9b107..caad700 100644 --- a/include/boost/iterator/new_iterator_tests.hpp +++ b/include/boost/iterator/new_iterator_tests.hpp @@ -32,6 +32,7 @@ # include # include # include // for detail::dummy_constructor +# include # include # include # include @@ -75,7 +76,7 @@ template void readable_iterator_test(const Iterator i1, T v) { Iterator i2(i1); // Copy Constructible - typedef typename std::iterator_traits::reference ref_t; + typedef typename detail::iterator_traits::reference ref_t; ref_t r1 = *i1; ref_t r2 = *i2; T v1 = r1; @@ -111,9 +112,9 @@ template void swappable_iterator_test(Iterator i, Iterator j) { Iterator i2(i), j2(j); - typename std::iterator_traits::value_type bi = *i, bj = *j; + typename detail::iterator_traits::value_type bi = *i, bj = *j; iter_swap(i2, j2); - typename std::iterator_traits::value_type ai = *i, aj = *j; + typename detail::iterator_traits::value_type ai = *i, aj = *j; BOOST_TEST(bi == aj && bj == ai); } @@ -121,8 +122,8 @@ template void constant_lvalue_iterator_test(Iterator i, T v1) { Iterator i2(i); - typedef typename std::iterator_traits::value_type value_type; - typedef typename std::iterator_traits::reference reference; + typedef typename detail::iterator_traits::value_type value_type; + typedef typename detail::iterator_traits::reference reference; BOOST_STATIC_ASSERT((is_same::value)); const T& v2 = *i2; BOOST_TEST(v1 == v2); @@ -136,8 +137,8 @@ template void non_const_lvalue_iterator_test(Iterator i, T v1, T v2) { Iterator i2(i); - typedef typename std::iterator_traits::value_type value_type; - typedef typename std::iterator_traits::reference reference; + typedef typename detail::iterator_traits::value_type value_type; + typedef typename detail::iterator_traits::reference reference; BOOST_STATIC_ASSERT((is_same::value)); T& v3 = *i2; BOOST_TEST(v1 == v3); @@ -228,7 +229,7 @@ void random_access_readable_iterator_test(Iterator i, int N, TrueVals vals) { BOOST_TEST(i == j + c); BOOST_TEST(*i == vals[c]); - typename std::iterator_traits::value_type x = j[c]; + typename detail::iterator_traits::value_type x = j[c]; BOOST_TEST(*i == x); BOOST_TEST(*i == *(j + c)); BOOST_TEST(*i == *(c + j)); @@ -244,7 +245,7 @@ void random_access_readable_iterator_test(Iterator i, int N, TrueVals vals) { BOOST_TEST(i == k - c); BOOST_TEST(*i == vals[N - 1 - c]); - typename std::iterator_traits::value_type x = j[N - 1 - c]; + typename detail::iterator_traits::value_type x = j[N - 1 - c]; BOOST_TEST(*i == x); Iterator q = k - c; BOOST_TEST(*i == *q); diff --git a/include/boost/iterator/permutation_iterator.hpp b/include/boost/iterator/permutation_iterator.hpp index 3876f3d..32648b0 100644 --- a/include/boost/iterator/permutation_iterator.hpp +++ b/include/boost/iterator/permutation_iterator.hpp @@ -21,13 +21,13 @@ template< class ElementIterator class permutation_iterator : public iterator_adaptor< permutation_iterator - , IndexIterator, typename std::iterator_traits::value_type - , use_default, typename std::iterator_traits::reference> + , IndexIterator, typename boost::detail::iterator_traits::value_type + , use_default, typename boost::detail::iterator_traits::reference> { typedef iterator_adaptor< permutation_iterator - , IndexIterator, typename std::iterator_traits::value_type - , use_default, typename std::iterator_traits::reference> super_t; + , IndexIterator, typename boost::detail::iterator_traits::value_type + , use_default, typename boost::detail::iterator_traits::reference> super_t; friend class iterator_core_access; diff --git a/include/boost/iterator/reverse_iterator.hpp b/include/boost/iterator/reverse_iterator.hpp index 7dcf645..3bef39e 100644 --- a/include/boost/iterator/reverse_iterator.hpp +++ b/include/boost/iterator/reverse_iterator.hpp @@ -8,6 +8,7 @@ #define BOOST_REVERSE_ITERATOR_23022003THW_HPP #include +#include #include namespace boost { diff --git a/include/boost/iterator/transform_iterator.hpp b/include/boost/iterator/transform_iterator.hpp index 67356ff..851f16f 100644 --- a/include/boost/iterator/transform_iterator.hpp +++ b/include/boost/iterator/transform_iterator.hpp @@ -7,6 +7,7 @@ #ifndef BOOST_TRANSFORM_ITERATOR_23022003THW_HPP #define BOOST_TRANSFORM_ITERATOR_23022003THW_HPP +#include #include #include #include @@ -21,12 +22,11 @@ #include #include -#include #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310)) # include -#endif +#endif #include diff --git a/include/boost/iterator/zip_iterator.hpp b/include/boost/iterator/zip_iterator.hpp index 61d1f17..83fa63b 100644 --- a/include/boost/iterator/zip_iterator.hpp +++ b/include/boost/iterator/zip_iterator.hpp @@ -9,6 +9,7 @@ # define BOOST_ZIP_ITERATOR_TMB_07_13_2003_HPP_ #include +#include #include #include #include // for enable_if_convertible diff --git a/include/boost/pending/detail/int_iterator.hpp b/include/boost/pending/detail/int_iterator.hpp index dcc7024..ca8372b 100644 --- a/include/boost/pending/detail/int_iterator.hpp +++ b/include/boost/pending/detail/int_iterator.hpp @@ -6,12 +6,11 @@ #ifndef BOOST_INT_ITERATOR_H #define BOOST_INT_ITERATOR_H +#include #if !defined BOOST_MSVC #include #endif #include -#include -#include //using namespace std; #ifndef BOOST_NO_OPERATORS_IN_NAMESPACE diff --git a/include/boost/pointee.hpp b/include/boost/pointee.hpp index f3bcf44..0f561b8 100644 --- a/include/boost/pointee.hpp +++ b/include/boost/pointee.hpp @@ -20,8 +20,6 @@ # include # include -#include - namespace boost { namespace detail @@ -35,7 +33,7 @@ namespace detail template struct iterator_pointee { - typedef typename std::iterator_traits::value_type value_type; + typedef typename iterator_traits::value_type value_type; struct impl { From b2b9ab156881e700858c5a104c47e006eddcc717 Mon Sep 17 00:00:00 2001 From: Marcel Raad Date: Mon, 14 Sep 2015 09:34:02 +0200 Subject: [PATCH 12/13] Remove unused deprecated includes A comment in boost/iterator.hpp and boost/detail/iterator.hpp mentions that the files are obsolete and will be deprecated. All they do is pull some types from namespace std into namespace boost. --- include/boost/iterator/filter_iterator.hpp | 1 - include/boost/iterator/indirect_iterator.hpp | 6 +++--- include/boost/iterator/is_lvalue_iterator.hpp | 9 ++++----- .../boost/iterator/is_readable_iterator.hpp | 5 +++-- include/boost/iterator/iterator_adaptor.hpp | 2 -- .../boost/iterator/iterator_archetypes.hpp | 1 - .../boost/iterator/iterator_categories.hpp | 5 +++-- include/boost/iterator/iterator_concepts.hpp | 18 ++++++++---------- include/boost/iterator/iterator_facade.hpp | 3 ++- include/boost/iterator/iterator_traits.hpp | 13 +++++++------ include/boost/iterator/new_iterator_tests.hpp | 19 +++++++++---------- .../boost/iterator/permutation_iterator.hpp | 8 ++++---- include/boost/iterator/reverse_iterator.hpp | 1 - include/boost/iterator/transform_iterator.hpp | 4 ++-- include/boost/iterator/zip_iterator.hpp | 1 - include/boost/pending/detail/int_iterator.hpp | 3 ++- include/boost/pending/iterator_tests.hpp | 2 +- include/boost/pointee.hpp | 4 +++- 18 files changed, 51 insertions(+), 54 deletions(-) diff --git a/include/boost/iterator/filter_iterator.hpp b/include/boost/iterator/filter_iterator.hpp index 58aea33..b87c02b 100644 --- a/include/boost/iterator/filter_iterator.hpp +++ b/include/boost/iterator/filter_iterator.hpp @@ -7,7 +7,6 @@ #ifndef BOOST_FILTER_ITERATOR_23022003THW_HPP #define BOOST_FILTER_ITERATOR_23022003THW_HPP -#include #include #include diff --git a/include/boost/iterator/indirect_iterator.hpp b/include/boost/iterator/indirect_iterator.hpp index c16eb84..7449d62 100644 --- a/include/boost/iterator/indirect_iterator.hpp +++ b/include/boost/iterator/indirect_iterator.hpp @@ -7,12 +7,10 @@ #ifndef BOOST_INDIRECT_ITERATOR_23022003THW_HPP #define BOOST_INDIRECT_ITERATOR_23022003THW_HPP -#include #include #include #include -#include #include @@ -25,6 +23,8 @@ #include #include +#include + #ifdef BOOST_MPL_CFG_NO_HAS_XXX # include # include @@ -45,7 +45,7 @@ namespace iterators { template struct indirect_base { - typedef typename boost::detail::iterator_traits::value_type dereferenceable; + typedef typename std::iterator_traits::value_type dereferenceable; typedef iterator_adaptor< indirect_iterator diff --git a/include/boost/iterator/is_lvalue_iterator.hpp b/include/boost/iterator/is_lvalue_iterator.hpp index e821da9..46f0483 100644 --- a/include/boost/iterator/is_lvalue_iterator.hpp +++ b/include/boost/iterator/is_lvalue_iterator.hpp @@ -4,16 +4,15 @@ #ifndef IS_LVALUE_ITERATOR_DWA2003112_HPP # define IS_LVALUE_ITERATOR_DWA2003112_HPP -#include - #include -#include #include #include #include #include +#include + // should be the last #includes #include #include @@ -125,14 +124,14 @@ namespace detail template struct is_readable_lvalue_iterator_impl : is_lvalue_iterator_impl< - BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::value_type const + BOOST_DEDUCED_TYPENAME std::iterator_traits::value_type const >::template rebind {}; template struct is_non_const_lvalue_iterator_impl : is_lvalue_iterator_impl< - BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::value_type + BOOST_DEDUCED_TYPENAME std::iterator_traits::value_type >::template rebind {}; } // namespace detail diff --git a/include/boost/iterator/is_readable_iterator.hpp b/include/boost/iterator/is_readable_iterator.hpp index 5bc2339..26827c4 100644 --- a/include/boost/iterator/is_readable_iterator.hpp +++ b/include/boost/iterator/is_readable_iterator.hpp @@ -6,11 +6,12 @@ #include #include -#include #include #include +#include + // should be the last #include #include #include @@ -93,7 +94,7 @@ namespace detail template struct is_readable_iterator_impl2 : is_readable_iterator_impl< - BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::value_type const + BOOST_DEDUCED_TYPENAME std::iterator_traits::value_type const >::template rebind {}; } // namespace detail diff --git a/include/boost/iterator/iterator_adaptor.hpp b/include/boost/iterator/iterator_adaptor.hpp index 87cfd05..f803fc6 100644 --- a/include/boost/iterator/iterator_adaptor.hpp +++ b/include/boost/iterator/iterator_adaptor.hpp @@ -8,8 +8,6 @@ #define BOOST_ITERATOR_ADAPTOR_23022003THW_HPP #include -#include -#include #include #include diff --git a/include/boost/iterator/iterator_archetypes.hpp b/include/boost/iterator/iterator_archetypes.hpp index 3e9d444..9b4b543 100644 --- a/include/boost/iterator/iterator_archetypes.hpp +++ b/include/boost/iterator/iterator_archetypes.hpp @@ -9,7 +9,6 @@ #include #include #include -#include #include diff --git a/include/boost/iterator/iterator_categories.hpp b/include/boost/iterator/iterator_categories.hpp index 71202c9..baf805a 100644 --- a/include/boost/iterator/iterator_categories.hpp +++ b/include/boost/iterator/iterator_categories.hpp @@ -7,7 +7,6 @@ # define BOOST_ITERATOR_CATEGORIES_HPP # include -# include # include # include @@ -21,6 +20,8 @@ # include +#include + namespace boost { namespace iterators { @@ -116,7 +117,7 @@ struct iterator_category_to_traversal template struct iterator_traversal : iterator_category_to_traversal< - typename boost::detail::iterator_traits::iterator_category + typename std::iterator_traits::iterator_category > {}; diff --git a/include/boost/iterator/iterator_concepts.hpp b/include/boost/iterator/iterator_concepts.hpp index 1a9f7d6..415cc49 100644 --- a/include/boost/iterator/iterator_concepts.hpp +++ b/include/boost/iterator/iterator_concepts.hpp @@ -9,9 +9,6 @@ #include #include -// Use boost::detail::iterator_traits to work around some MSVC/Dinkumware problems. -#include - #include #include @@ -27,6 +24,7 @@ #include #include +#include #include @@ -44,8 +42,8 @@ namespace boost_concepts , boost::CopyConstructible { - typedef BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::value_type value_type; - typedef BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::reference reference; + typedef BOOST_DEDUCED_TYPENAME std::iterator_traits::value_type value_type; + typedef BOOST_DEDUCED_TYPENAME std::iterator_traits::reference reference; BOOST_CONCEPT_USAGE(ReadableIterator) { @@ -59,7 +57,7 @@ namespace boost_concepts template < typename Iterator - , typename ValueType = BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::value_type + , typename ValueType = BOOST_DEDUCED_TYPENAME std::iterator_traits::value_type > struct WritableIterator : boost::CopyConstructible @@ -75,7 +73,7 @@ namespace boost_concepts template < typename Iterator - , typename ValueType = BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::value_type + , typename ValueType = BOOST_DEDUCED_TYPENAME std::iterator_traits::value_type > struct WritableIteratorConcept : WritableIterator {}; @@ -92,7 +90,7 @@ namespace boost_concepts BOOST_concept(LvalueIterator,(Iterator)) { - typedef typename boost::detail::iterator_traits::value_type value_type; + typedef typename std::iterator_traits::value_type value_type; BOOST_CONCEPT_USAGE(LvalueIterator) { @@ -144,7 +142,7 @@ namespace boost_concepts : SinglePassIterator , boost::DefaultConstructible { - typedef typename boost::detail::iterator_traits::difference_type difference_type; + typedef typename std::iterator_traits::difference_type difference_type; BOOST_MPL_ASSERT((boost::is_integral)); BOOST_MPL_ASSERT_RELATION(std::numeric_limits::is_signed, ==, true); @@ -221,7 +219,7 @@ namespace boost_concepts boost::random_access_traversal_tag, boost::random_access_traversal_tag) { bool b; - typename boost::detail::iterator_traits::difference_type n; + typename std::iterator_traits::difference_type n; b = i1 < i2; b = i1 <= i2; b = i1 > i2; diff --git a/include/boost/iterator/iterator_facade.hpp b/include/boost/iterator/iterator_facade.hpp index 7b11d0a..225c53a 100644 --- a/include/boost/iterator/iterator_facade.hpp +++ b/include/boost/iterator/iterator_facade.hpp @@ -8,7 +8,6 @@ #define BOOST_ITERATOR_FACADE_23022003THW_HPP #include -#include #include #include #include @@ -37,6 +36,8 @@ #include #include +#include + #include // this goes last namespace boost { diff --git a/include/boost/iterator/iterator_traits.hpp b/include/boost/iterator/iterator_traits.hpp index 1a5f1e0..6582a68 100644 --- a/include/boost/iterator/iterator_traits.hpp +++ b/include/boost/iterator/iterator_traits.hpp @@ -5,9 +5,10 @@ #ifndef ITERATOR_TRAITS_DWA200347_HPP # define ITERATOR_TRAITS_DWA200347_HPP -# include # include +#include + namespace boost { namespace iterators { @@ -19,32 +20,32 @@ namespace iterators { template struct iterator_value { - typedef typename boost::detail::iterator_traits::value_type type; + typedef typename std::iterator_traits::value_type type; }; template struct iterator_reference { - typedef typename boost::detail::iterator_traits::reference type; + typedef typename std::iterator_traits::reference type; }; template struct iterator_pointer { - typedef typename boost::detail::iterator_traits::pointer type; + typedef typename std::iterator_traits::pointer type; }; template struct iterator_difference { - typedef typename boost::detail::iterator_traits::difference_type type; + typedef typename std::iterator_traits::difference_type type; }; template struct iterator_category { - typedef typename boost::detail::iterator_traits::iterator_category type; + typedef typename std::iterator_traits::iterator_category type; }; } // namespace iterators diff --git a/include/boost/iterator/new_iterator_tests.hpp b/include/boost/iterator/new_iterator_tests.hpp index caad700..cb9b107 100644 --- a/include/boost/iterator/new_iterator_tests.hpp +++ b/include/boost/iterator/new_iterator_tests.hpp @@ -32,7 +32,6 @@ # include # include # include // for detail::dummy_constructor -# include # include # include # include @@ -76,7 +75,7 @@ template void readable_iterator_test(const Iterator i1, T v) { Iterator i2(i1); // Copy Constructible - typedef typename detail::iterator_traits::reference ref_t; + typedef typename std::iterator_traits::reference ref_t; ref_t r1 = *i1; ref_t r2 = *i2; T v1 = r1; @@ -112,9 +111,9 @@ template void swappable_iterator_test(Iterator i, Iterator j) { Iterator i2(i), j2(j); - typename detail::iterator_traits::value_type bi = *i, bj = *j; + typename std::iterator_traits::value_type bi = *i, bj = *j; iter_swap(i2, j2); - typename detail::iterator_traits::value_type ai = *i, aj = *j; + typename std::iterator_traits::value_type ai = *i, aj = *j; BOOST_TEST(bi == aj && bj == ai); } @@ -122,8 +121,8 @@ template void constant_lvalue_iterator_test(Iterator i, T v1) { Iterator i2(i); - typedef typename detail::iterator_traits::value_type value_type; - typedef typename detail::iterator_traits::reference reference; + typedef typename std::iterator_traits::value_type value_type; + typedef typename std::iterator_traits::reference reference; BOOST_STATIC_ASSERT((is_same::value)); const T& v2 = *i2; BOOST_TEST(v1 == v2); @@ -137,8 +136,8 @@ template void non_const_lvalue_iterator_test(Iterator i, T v1, T v2) { Iterator i2(i); - typedef typename detail::iterator_traits::value_type value_type; - typedef typename detail::iterator_traits::reference reference; + typedef typename std::iterator_traits::value_type value_type; + typedef typename std::iterator_traits::reference reference; BOOST_STATIC_ASSERT((is_same::value)); T& v3 = *i2; 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 == vals[c]); - typename detail::iterator_traits::value_type x = j[c]; + typename std::iterator_traits::value_type x = j[c]; BOOST_TEST(*i == x); BOOST_TEST(*i == *(j + c)); 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 == vals[N - 1 - c]); - typename detail::iterator_traits::value_type x = j[N - 1 - c]; + typename std::iterator_traits::value_type x = j[N - 1 - c]; BOOST_TEST(*i == x); Iterator q = k - c; BOOST_TEST(*i == *q); diff --git a/include/boost/iterator/permutation_iterator.hpp b/include/boost/iterator/permutation_iterator.hpp index 32648b0..3876f3d 100644 --- a/include/boost/iterator/permutation_iterator.hpp +++ b/include/boost/iterator/permutation_iterator.hpp @@ -21,13 +21,13 @@ template< class ElementIterator class permutation_iterator : public iterator_adaptor< permutation_iterator - , IndexIterator, typename boost::detail::iterator_traits::value_type - , use_default, typename boost::detail::iterator_traits::reference> + , IndexIterator, typename std::iterator_traits::value_type + , use_default, typename std::iterator_traits::reference> { typedef iterator_adaptor< permutation_iterator - , IndexIterator, typename boost::detail::iterator_traits::value_type - , use_default, typename boost::detail::iterator_traits::reference> super_t; + , IndexIterator, typename std::iterator_traits::value_type + , use_default, typename std::iterator_traits::reference> super_t; friend class iterator_core_access; diff --git a/include/boost/iterator/reverse_iterator.hpp b/include/boost/iterator/reverse_iterator.hpp index 3bef39e..7dcf645 100644 --- a/include/boost/iterator/reverse_iterator.hpp +++ b/include/boost/iterator/reverse_iterator.hpp @@ -8,7 +8,6 @@ #define BOOST_REVERSE_ITERATOR_23022003THW_HPP #include -#include #include namespace boost { diff --git a/include/boost/iterator/transform_iterator.hpp b/include/boost/iterator/transform_iterator.hpp index 851f16f..67356ff 100644 --- a/include/boost/iterator/transform_iterator.hpp +++ b/include/boost/iterator/transform_iterator.hpp @@ -7,7 +7,6 @@ #ifndef BOOST_TRANSFORM_ITERATOR_23022003THW_HPP #define BOOST_TRANSFORM_ITERATOR_23022003THW_HPP -#include #include #include #include @@ -22,11 +21,12 @@ #include #include +#include #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310)) # include - #endif + #include diff --git a/include/boost/iterator/zip_iterator.hpp b/include/boost/iterator/zip_iterator.hpp index 83fa63b..61d1f17 100644 --- a/include/boost/iterator/zip_iterator.hpp +++ b/include/boost/iterator/zip_iterator.hpp @@ -9,7 +9,6 @@ # define BOOST_ZIP_ITERATOR_TMB_07_13_2003_HPP_ #include -#include #include #include #include // for enable_if_convertible diff --git a/include/boost/pending/detail/int_iterator.hpp b/include/boost/pending/detail/int_iterator.hpp index ca8372b..dcc7024 100644 --- a/include/boost/pending/detail/int_iterator.hpp +++ b/include/boost/pending/detail/int_iterator.hpp @@ -6,11 +6,12 @@ #ifndef BOOST_INT_ITERATOR_H #define BOOST_INT_ITERATOR_H -#include #if !defined BOOST_MSVC #include #endif #include +#include +#include //using namespace std; #ifndef BOOST_NO_OPERATORS_IN_NAMESPACE diff --git a/include/boost/pending/iterator_tests.hpp b/include/boost/pending/iterator_tests.hpp index 37c839b..d515e12 100644 --- a/include/boost/pending/iterator_tests.hpp +++ b/include/boost/pending/iterator_tests.hpp @@ -215,7 +215,7 @@ void random_access_iterator_test(Iterator i, int N, TrueVals vals) const Iterator j = i; int c; - typedef typename boost::detail::iterator_traits::value_type value_type; + typedef typename std::iterator_traits::value_type value_type; for (c = 0; c < N-1; ++c) { assert(i == j + c); diff --git a/include/boost/pointee.hpp b/include/boost/pointee.hpp index 0f561b8..f3bcf44 100644 --- a/include/boost/pointee.hpp +++ b/include/boost/pointee.hpp @@ -20,6 +20,8 @@ # include # include +#include + namespace boost { namespace detail @@ -33,7 +35,7 @@ namespace detail template struct iterator_pointee { - typedef typename iterator_traits::value_type value_type; + typedef typename std::iterator_traits::value_type value_type; struct impl { From 443dfb990143a8cb6d9f508eebea5bb6bdf805ee Mon Sep 17 00:00:00 2001 From: Marcel Raad Date: Fri, 18 Sep 2015 10:15:11 +0200 Subject: [PATCH 13/13] Fix test compilation boost/iterator.hpp was implicitly dragged in via boost/operators.hpp, from which it was removed in https://github.com/boostorg/utility/commit/cb6500161b682a66438604e75ab901c46e42430d. It's not needed anyway, all it does is map boost::iterator to std::iterator. --- test/concept_tests.cpp | 7 +++++-- test/indirect_iterator_test.cpp | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/test/concept_tests.cpp b/test/concept_tests.cpp index f3d518a..f89cd54 100644 --- a/test/concept_tests.cpp +++ b/test/concept_tests.cpp @@ -7,13 +7,16 @@ #include #include +#include +#include + struct new_random_access : std::random_access_iterator_tag , boost::random_access_traversal_tag {}; struct new_iterator - : public boost::iterator< new_random_access, int > + : public std::iterator< new_random_access, int > { int& operator*() const { return *m_x; } new_iterator& operator++() { return *this; } @@ -33,7 +36,7 @@ struct new_iterator new_iterator operator+(std::ptrdiff_t, new_iterator x) { return x; } struct old_iterator - : public boost::iterator + : public std::iterator { int& operator*() const { return *m_x; } old_iterator& operator++() { return *this; } diff --git a/test/indirect_iterator_test.cpp b/test/indirect_iterator_test.cpp index c689673..7250651 100644 --- a/test/indirect_iterator_test.cpp +++ b/test/indirect_iterator_test.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #if !defined(__SGI_STL_PORT) \ && (defined(BOOST_MSVC_STD_ITERATOR) \ @@ -164,7 +165,7 @@ main() BOOST_STATIC_ASSERT( has_element_type< - boost::detail::iterator_traits::value_type + std::iterator_traits::value_type >::value );