diff --git a/include/boost/function_output_iterator.hpp b/include/boost/function_output_iterator.hpp index 9720f3f..dd8c44d 100644 --- a/include/boost/function_output_iterator.hpp +++ b/include/boost/function_output_iterator.hpp @@ -14,6 +14,7 @@ #include namespace boost { +namespace iterators { template class function_output_iterator { @@ -33,13 +34,13 @@ namespace boost { struct output_proxy { output_proxy(UnaryFunction& f) : m_f(f) { } template output_proxy& operator=(const T& value) { - m_f(value); - return *this; + m_f(value); + return *this; } UnaryFunction& m_f; }; output_proxy operator*() { return output_proxy(m_f); } - self& operator++() { return *this; } + self& operator++() { return *this; } self& operator++(int) { return *this; } private: UnaryFunction m_f; @@ -51,6 +52,11 @@ namespace boost { return function_output_iterator(f); } +} // namespace iterators + +using iterators::function_output_iterator; +using iterators::make_function_output_iterator; + } // namespace boost #endif // BOOST_FUNCTION_OUTPUT_ITERATOR_HPP diff --git a/include/boost/generator_iterator.hpp b/include/boost/generator_iterator.hpp index ebf478b..0fe1569 100644 --- a/include/boost/generator_iterator.hpp +++ b/include/boost/generator_iterator.hpp @@ -17,6 +17,7 @@ #include namespace boost { +namespace iterators { template class generator_iterator @@ -33,7 +34,7 @@ class generator_iterator , single_pass_traversal_tag , typename Generator::result_type const& > super_t; - + public: generator_iterator() {} generator_iterator(Generator* g) : m_g(g), m_value((*m_g)()) {} @@ -73,8 +74,12 @@ make_generator_iterator(Generator & gen) return result_t(&gen); } +} // namespace iterators + +using iterators::generator_iterator; +using iterators::generator_iterator_generator; +using iterators::make_generator_iterator; + } // namespace boost - #endif // BOOST_ITERATOR_ADAPTOR_GENERATOR_ITERATOR_HPP - diff --git a/include/boost/indirect_reference.hpp b/include/boost/indirect_reference.hpp index 5fbb342..3279cd0 100644 --- a/include/boost/indirect_reference.hpp +++ b/include/boost/indirect_reference.hpp @@ -17,7 +17,7 @@ # include # include -namespace boost { +namespace boost { namespace detail { @@ -37,7 +37,7 @@ struct indirect_reference > { }; - + } // namespace boost #endif // INDIRECT_REFERENCE_DWA200415_HPP diff --git a/include/boost/iterator/counting_iterator.hpp b/include/boost/iterator/counting_iterator.hpp index 1298a31..d90980e 100644 --- a/include/boost/iterator/counting_iterator.hpp +++ b/include/boost/iterator/counting_iterator.hpp @@ -13,6 +13,7 @@ # include namespace boost { +namespace iterators { template < class Incrementable @@ -30,13 +31,13 @@ namespace detail { // For a while, this wasn't true, but we rely on it below. This is a regression assert. BOOST_STATIC_ASSERT(::boost::is_integral::value); - + # ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS - + BOOST_STATIC_CONSTANT(bool, value = std::numeric_limits::is_specialized); - + # else - + # if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) BOOST_STATIC_CONSTANT( bool, value = ( @@ -46,20 +47,20 @@ namespace detail # else BOOST_STATIC_CONSTANT(bool, value = ::boost::is_arithmetic::value); # endif - + # endif }; template struct is_numeric - : mpl::bool_<(::boost::detail::is_numeric_impl::value)> + : mpl::bool_<(::boost::iterators::detail::is_numeric_impl::value)> {}; # if defined(BOOST_HAS_LONG_LONG) template <> struct is_numeric< ::boost::long_long_type> : mpl::true_ {}; - + template <> struct is_numeric< ::boost::ulong_long_type> : mpl::true_ {}; @@ -69,7 +70,7 @@ namespace detail template <> struct is_numeric : mpl::true_ {}; - + template struct numeric_difference { @@ -77,7 +78,7 @@ namespace detail }; BOOST_STATIC_ASSERT(is_numeric::value); - + template struct counting_iterator_base { @@ -89,7 +90,7 @@ namespace detail , iterator_traversal > >::type traversal; - + typedef typename detail::ia_dflt_help< Difference , mpl::eval_if< @@ -98,7 +99,7 @@ namespace detail , iterator_difference > >::type difference; - + typedef iterator_adaptor< counting_iterator // self , Incrementable // Base @@ -106,7 +107,7 @@ namespace detail # ifndef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY const // MSVC won't strip this. Instead we enable Thomas' // criterion (see boost/iterator/detail/facade_iterator_category.hpp) -# endif +# endif , traversal , Incrementable const& // reference , difference @@ -136,7 +137,7 @@ namespace detail { static Difference distance(Incrementable1 x, Incrementable2 y) { - return numeric_distance(x, y); + return boost::detail::numeric_distance(x, y); } }; } @@ -154,14 +155,14 @@ class counting_iterator typedef typename detail::counting_iterator_base< Incrementable, CategoryOrTraversal, Difference >::type super_t; - + friend class iterator_core_access; public: typedef typename super_t::difference_type difference_type; counting_iterator() { } - + counting_iterator(counting_iterator const& rhs) : super_t(rhs.base()) {} counting_iterator(Incrementable x) @@ -177,10 +178,10 @@ class counting_iterator ) : super_t(t.base()) {} -# endif +# endif private: - + typename super_t::reference dereference() const { return this->base_reference(); @@ -209,7 +210,11 @@ make_counting_iterator(Incrementable x) return result_t(x); } +} // namespace iterators -} // namespace boost::iterator +using iterators::counting_iterator; +using iterators::make_counting_iterator; + +} // namespace boost #endif // COUNTING_ITERATOR_DWA200348_HPP diff --git a/include/boost/iterator/detail/any_conversion_eater.hpp b/include/boost/iterator/detail/any_conversion_eater.hpp index 25fa644..429421f 100644 --- a/include/boost/iterator/detail/any_conversion_eater.hpp +++ b/include/boost/iterator/detail/any_conversion_eater.hpp @@ -4,7 +4,9 @@ #ifndef ANY_CONVERSION_EATER_DWA20031117_HPP # define ANY_CONVERSION_EATER_DWA20031117_HPP -namespace boost { namespace detail { +namespace boost { +namespace iterators { +namespace detail { // This type can be used in traits to "eat" up the one user-defined // implicit conversion allowed. @@ -14,6 +16,6 @@ struct any_conversion_eater any_conversion_eater(T const&); }; -}} // namespace boost::detail +}}} // namespace boost::iterators::detail #endif // ANY_CONVERSION_EATER_DWA20031117_HPP diff --git a/include/boost/iterator/detail/facade_iterator_category.hpp b/include/boost/iterator/detail/facade_iterator_category.hpp index 2572db0..67fdf44 100644 --- a/include/boost/iterator/detail/facade_iterator_category.hpp +++ b/include/boost/iterator/detail/facade_iterator_category.hpp @@ -30,10 +30,13 @@ // iterator_category deduction for iterator_facade // -// forward declaration -namespace boost { struct use_default; } +namespace boost { +namespace iterators { -namespace boost { namespace detail { +// forward declaration +struct use_default; + +namespace detail { struct input_output_iterator_tag : std::input_iterator_tag @@ -63,9 +66,9 @@ struct iterator_writability_disabled , boost::detail::indirect_traits::is_reference_to_const , is_const > -# else +# else : is_const -# endif +# endif {}; @@ -96,7 +99,7 @@ struct iterator_facade_default_category , typename mpl::eval_if< mpl::and_< is_convertible - + // check for readability , is_convertible > @@ -146,7 +149,7 @@ struct iterator_category_with_traversal BOOST_MPL_ASSERT_NOT((is_iterator_traversal)); # if !BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310)) BOOST_MPL_ASSERT((is_iterator_traversal)); -# endif +# endif }; // Computes an iterator_category tag whose traversal is Traversal and @@ -155,11 +158,11 @@ template struct facade_iterator_category_impl { BOOST_MPL_ASSERT_NOT((is_iterator_category)); - + typedef typename iterator_facade_default_category< Traversal,ValueParam,Reference >::type category; - + typedef typename mpl::if_< is_same< Traversal @@ -183,7 +186,7 @@ struct facade_iterator_category { }; -}} // namespace boost::detail +}}} // namespace boost::iterators::detail # include diff --git a/include/boost/iterator/detail/minimum_category.hpp b/include/boost/iterator/detail/minimum_category.hpp index 1f4444f..dc9af5b 100644 --- a/include/boost/iterator/detail/minimum_category.hpp +++ b/include/boost/iterator/detail/minimum_category.hpp @@ -9,7 +9,9 @@ # include -namespace boost { namespace detail { +namespace boost { +namespace iterators { +namespace detail { // // Returns the minimum category type or error_type // if T1 and T2 are unrelated. @@ -17,7 +19,7 @@ namespace boost { namespace detail { // For compilers not supporting is_convertible this only // works with the new boost return and traversal category // types. The exact boost _types_ are required. No derived types -// will work. +// will work. // // template @@ -25,7 +27,7 @@ struct minimum_category_impl; template struct error_not_related_by_convertibility; - + template <> struct minimum_category_impl { @@ -66,17 +68,17 @@ struct minimum_category_impl template struct minimum_category { - typedef minimum_category_impl< + typedef minimum_category_impl< ::boost::is_convertible::value , ::boost::is_convertible::value > outer; typedef typename outer::template apply inner; typedef typename inner::type type; - + BOOST_MPL_AUX_LAMBDA_SUPPORT(2,minimum_category,(T1,T2)) }; - + template <> struct minimum_category { @@ -86,7 +88,7 @@ struct minimum_category BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2,minimum_category,(mpl::_1,mpl::_2)) }; - -}} // namespace boost::detail + +}}} // namespace boost::iterators::detail #endif // MINIMUM_CATEGORY_DWA20031119_HPP diff --git a/include/boost/iterator/filter_iterator.hpp b/include/boost/iterator/filter_iterator.hpp index 4282acc..58aea33 100644 --- a/include/boost/iterator/filter_iterator.hpp +++ b/include/boost/iterator/filter_iterator.hpp @@ -14,8 +14,9 @@ #include #include -namespace boost -{ +namespace boost { +namespace iterators { + template class filter_iterator; @@ -39,7 +40,7 @@ namespace boost > type; }; } - + template class filter_iterator : public detail::filter_iterator_base::type @@ -68,7 +69,7 @@ namespace boost // Don't allow use of this constructor if Predicate is a // function pointer type, since it will be 0. BOOST_STATIC_ASSERT(is_class::value); -#endif +#endif satisfy_predicate(); } @@ -108,14 +109,14 @@ namespace boost }; template - filter_iterator + inline filter_iterator make_filter_iterator(Predicate f, Iterator x, Iterator end = Iterator()) { return filter_iterator(f,x,end); } template - filter_iterator + inline filter_iterator make_filter_iterator( typename iterators::enable_if< is_class @@ -126,6 +127,11 @@ namespace boost return filter_iterator(x,end); } +} // namespace iterators + +using iterators::filter_iterator; +using iterators::make_filter_iterator; + } // namespace boost #endif // BOOST_FILTER_ITERATOR_23022003THW_HPP diff --git a/include/boost/iterator/function_input_iterator.hpp b/include/boost/iterator/function_input_iterator.hpp index c4b5cb3..8a793df 100644 --- a/include/boost/iterator/function_input_iterator.hpp +++ b/include/boost/iterator/function_input_iterator.hpp @@ -20,6 +20,8 @@ namespace boost { +namespace iterators { + namespace impl { template @@ -33,7 +35,7 @@ namespace boost { { public: function_input_iterator() {} - function_input_iterator(Function & f_, Input state_ = Input()) + function_input_iterator(Function & f_, Input state_ = Input()) : f(&f_), state(state_) {} void increment() { @@ -44,7 +46,7 @@ namespace boost { ++state; } - typename Function::result_type const & + typename Function::result_type const & dereference() const { return (value ? value : value = (*f)()).get(); } @@ -109,7 +111,7 @@ namespace boost { } // namespace impl template - class function_input_iterator + class function_input_iterator : public mpl::if_< function_types::is_function_pointer, impl::function_pointer_input_iterator, @@ -154,7 +156,14 @@ namespace boost { bool operator==(infinite &) const { return false; }; bool operator==(infinite const &) const { return false; }; }; -} + +} // namespace iterators + +using iterators::function_input_iterator; +using iterators::make_function_input_iterator; +using iterators::infinite; + +} // namespace boost #endif diff --git a/include/boost/iterator/indirect_iterator.hpp b/include/boost/iterator/indirect_iterator.hpp index abff7e7..c16eb84 100644 --- a/include/boost/iterator/indirect_iterator.hpp +++ b/include/boost/iterator/indirect_iterator.hpp @@ -30,12 +30,13 @@ # include # include # include -#endif +#endif #include // must be last #include -namespace boost -{ +namespace boost { +namespace iterators { + template class indirect_iterator; @@ -44,8 +45,8 @@ namespace boost template struct indirect_base { - typedef typename iterator_traits::value_type dereferenceable; - + typedef typename boost::detail::iterator_traits::value_type dereferenceable; + typedef iterator_adaptor< indirect_iterator , Iter @@ -69,7 +70,7 @@ namespace boost struct indirect_base {}; } // namespace detail - + template < class Iterator , class Value = use_default @@ -107,14 +108,14 @@ namespace boost : super_t(y.base()) {} - private: + private: typename super_t::reference dereference() const { # if BOOST_WORKAROUND(__BORLANDC__, < 0x5A0 ) return const_cast(**this->base()); # else return **this->base(); -# endif +# endif } }; @@ -132,6 +133,11 @@ namespace boost return indirect_iterator(x); } +} // namespace iterators + +using iterators::indirect_iterator; +using iterators::make_indirect_iterator; + } // namespace boost #include diff --git a/include/boost/iterator/interoperable.hpp b/include/boost/iterator/interoperable.hpp index c13dd9b..6f3c872 100644 --- a/include/boost/iterator/interoperable.hpp +++ b/include/boost/iterator/interoperable.hpp @@ -14,8 +14,8 @@ # include // must appear last -namespace boost -{ +namespace boost { +namespace iterators { // // Meta function that determines whether two @@ -27,7 +27,7 @@ namespace boost // standards requirements on constant/mutable container // iterators (23.1 [lib.container.requirements]). // - // For compilers that don't support is_convertible + // For compilers that don't support is_convertible // is_interoperable gives false positives. See comments // on operator implementation for consequences. // @@ -40,9 +40,13 @@ namespace boost is_convertible< A, B > , is_convertible< B, A > > # endif - { + { }; +} // namespace iterators + +using iterators::is_interoperable; + } // namespace boost # include diff --git a/include/boost/iterator/is_lvalue_iterator.hpp b/include/boost/iterator/is_lvalue_iterator.hpp index 3beb90d..20c4f38 100644 --- a/include/boost/iterator/is_lvalue_iterator.hpp +++ b/include/boost/iterator/is_lvalue_iterator.hpp @@ -18,7 +18,9 @@ #ifndef BOOST_NO_IS_CONVERTIBLE namespace boost { - + +namespace iterators { + namespace detail { #ifndef BOOST_NO_LVALUE_RETURN_DETECTION @@ -26,20 +28,20 @@ namespace detail // to the expression's result if is an lvalue, or // not_an_lvalue() otherwise. struct not_an_lvalue {}; - + template T& lvalue_preserver(T&, int); - + template not_an_lvalue lvalue_preserver(U const&, ...); - + # define BOOST_LVALUE_PRESERVER(expr) detail::lvalue_preserver(expr,0) - + #else - + # define BOOST_LVALUE_PRESERVER(expr) expr - -#endif + +#endif // Guts of is_lvalue_iterator. Value is the iterator's value_type // and the result is computed in the nested rebind template. @@ -55,12 +57,12 @@ namespace detail static char tester(conversion_eater, int); static char (& tester(any_conversion_eater, ...) )[2]; - + template struct rebind { static It& x; - + BOOST_STATIC_CONSTANT( bool , value = ( @@ -75,7 +77,7 @@ namespace detail }; #undef BOOST_LVALUE_PRESERVER - + // // void specializations to handle std input and output iterators // @@ -135,11 +137,16 @@ namespace detail // Define the trait with full mpl lambda capability and various broken // compiler workarounds BOOST_TT_AUX_BOOL_TRAIT_DEF1( - is_lvalue_iterator,T,::boost::detail::is_readable_lvalue_iterator_impl::value) - + is_lvalue_iterator,T,::boost::iterators::detail::is_readable_lvalue_iterator_impl::value) + BOOST_TT_AUX_BOOL_TRAIT_DEF1( - is_non_const_lvalue_iterator,T,::boost::detail::is_non_const_lvalue_iterator_impl::value) - + is_non_const_lvalue_iterator,T,::boost::iterators::detail::is_non_const_lvalue_iterator_impl::value) + +} // namespace iterators + +using iterators::is_lvalue_iterator; +using iterators::is_non_const_lvalue_iterator; + } // namespace boost #endif diff --git a/include/boost/iterator/is_readable_iterator.hpp b/include/boost/iterator/is_readable_iterator.hpp index 60d6ff0..3f08b92 100644 --- a/include/boost/iterator/is_readable_iterator.hpp +++ b/include/boost/iterator/is_readable_iterator.hpp @@ -16,7 +16,9 @@ #ifndef BOOST_NO_IS_CONVERTIBLE namespace boost { - + +namespace iterators { + namespace detail { // Guts of is_readable_iterator. Value is the iterator's value_type @@ -26,12 +28,12 @@ namespace detail { static char tester(Value&, int); static char (& tester(any_conversion_eater, ...) )[2]; - + template struct rebind { static It& x; - + BOOST_STATIC_CONSTANT( bool , value = ( @@ -44,7 +46,7 @@ namespace detail }; #undef BOOST_READABLE_PRESERVER - + // // void specializations to handle std input and output iterators // @@ -97,8 +99,12 @@ namespace detail // Define the trait with full mpl lambda capability and various broken // compiler workarounds BOOST_TT_AUX_BOOL_TRAIT_DEF1( - is_readable_iterator,T,::boost::detail::is_readable_iterator_impl2::value) - + is_readable_iterator,T,::boost::iterators::detail::is_readable_iterator_impl2::value) + +} // namespace iterators + +using iterators::is_readable_iterator; + } // namespace boost #endif diff --git a/include/boost/iterator/iterator_adaptor.hpp b/include/boost/iterator/iterator_adaptor.hpp index ed8a82f..87cfd05 100644 --- a/include/boost/iterator/iterator_adaptor.hpp +++ b/include/boost/iterator/iterator_adaptor.hpp @@ -31,28 +31,33 @@ #include -namespace boost -{ +namespace boost { +namespace iterators { + // Used as a default template argument internally, merely to // indicate "use the default", this can also be passed by users // explicitly in order to specify that the default should be used. struct use_default; - -# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - // the incompleteness of use_default causes massive problems for - // is_convertible (naturally). This workaround is fortunately not - // needed for vc6/vc7. - template - struct is_convertible - : mpl::false_ {}; -# endif - + +} // namespace iterators + +using iterators::use_default; + +// the incompleteness of use_default causes massive problems for +// is_convertible (naturally). This workaround is fortunately not +// needed for vc6/vc7. +template +struct is_convertible + : mpl::false_ {}; + +namespace iterators { + namespace detail { - // + // // Result type used in enable_if_convertible meta function. - // This can be an incomplete type, as only pointers to + // This can be an incomplete type, as only pointers to // enable_if_convertible< ... >::type are used. // We could have used void for this, but conversion to // void* is just to easy. @@ -73,7 +78,7 @@ namespace boost // public iterator_adaptor< adapted_iterator, Iterator > // { // public: - // + // // ... // // template @@ -92,23 +97,23 @@ namespace boost // and not at the actual instantiation. // // enable_if_interoperable can be safely used in user code. It falls back to - // always enabled for compilers that don't support enable_if or is_convertible. - // There is no need for compiler specific workarounds in user code. + // always enabled for compilers that don't support enable_if or is_convertible. + // There is no need for compiler specific workarounds in user code. // // The operators implementation relies on boost::is_convertible not returning // false positives for user/library defined iterator types. See comments // on operator implementation for consequences. // # if defined(BOOST_NO_IS_CONVERTIBLE) || defined(BOOST_NO_SFINAE) - + template struct enable_if_convertible { - typedef boost::detail::enable_type type; + typedef boost::iterators::detail::enable_type type; }; - + # elif BOOST_WORKAROUND(_MSC_FULL_VER, BOOST_TESTED_AT(13102292)) - + // For some reason vc7.1 needs us to "cut off" instantiation // of is_convertible in a few cases. template @@ -118,22 +123,22 @@ namespace boost is_same , is_convertible > - , boost::detail::enable_type + , boost::iterators::detail::enable_type > {}; - -# else - + +# else + template struct enable_if_convertible : iterators::enable_if< is_convertible - , boost::detail::enable_type + , boost::iterators::detail::enable_type > {}; - + # endif - + // // Default template argument handling for iterator_adaptor // @@ -165,9 +170,9 @@ namespace boost { typedef iterator_facade< Derived - + # ifdef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY - , typename boost::detail::ia_dflt_help< + , typename boost::iterators::detail::ia_dflt_help< Value , mpl::eval_if< is_same @@ -176,17 +181,17 @@ namespace boost > >::type # else - , typename boost::detail::ia_dflt_help< + , typename boost::iterators::detail::ia_dflt_help< Value, iterator_value >::type # endif - - , typename boost::detail::ia_dflt_help< + + , typename boost::iterators::detail::ia_dflt_help< Traversal , iterator_traversal >::type - , typename boost::detail::ia_dflt_help< + , typename boost::iterators::detail::ia_dflt_help< Reference , mpl::eval_if< is_same @@ -195,13 +200,13 @@ namespace boost > >::type - , typename boost::detail::ia_dflt_help< + , typename boost::iterators::detail::ia_dflt_help< Difference, iterator_difference >::type > type; }; - + // workaround for aC++ CR JAGaf33512 template inline void iterator_adaptor_assert_traversal () @@ -209,7 +214,7 @@ namespace boost BOOST_STATIC_ASSERT((is_convertible::value)); } } - + // // Iterator Adaptor // @@ -244,14 +249,14 @@ namespace boost , class Difference = use_default > class iterator_adaptor - : public boost::detail::iterator_adaptor_base< + : public boost::iterators::detail::iterator_adaptor_base< Derived, Base, Value, Traversal, Reference, Difference >::type { friend class iterator_core_access; protected: - typedef typename boost::detail::iterator_adaptor_base< + typedef typename boost::iterators::detail::iterator_adaptor_base< Derived, Base, Value, Traversal, Reference, Difference >::type super_t; public: @@ -270,7 +275,7 @@ namespace boost protected: // for convenience in derived classes typedef iterator_adaptor iterator_adaptor_; - + // // lvalue access to the Base object for Derived // @@ -286,13 +291,13 @@ namespace boost // to prevent temptation for Derived classes to use it, which // will often result in an error. Derived classes should use // base_reference(), above, to get direct access to m_iterator. - // + // typename super_t::reference dereference() const { return *m_iterator; } template < class OtherDerived, class OtherIterator, class V, class C, class R, class D - > + > bool equal(iterator_adaptor const& x) const { // Maybe readd with same_distance @@ -307,17 +312,17 @@ namespace boost >::type my_traversal; # define BOOST_ITERATOR_ADAPTOR_ASSERT_TRAVERSAL(cat) \ - boost::detail::iterator_adaptor_assert_traversal(); + boost::iterators::detail::iterator_adaptor_assert_traversal(); void advance(typename super_t::difference_type n) { BOOST_ITERATOR_ADAPTOR_ASSERT_TRAVERSAL(random_access_traversal_tag) m_iterator += n; } - + void increment() { ++m_iterator; } - void decrement() + void decrement() { BOOST_ITERATOR_ADAPTOR_ASSERT_TRAVERSAL(bidirectional_traversal_tag) --m_iterator; @@ -325,7 +330,7 @@ namespace boost template < class OtherDerived, class OtherIterator, class V, class C, class R, class D - > + > typename super_t::difference_type distance_to( iterator_adaptor const& y) const { @@ -338,11 +343,16 @@ namespace boost } # undef BOOST_ITERATOR_ADAPTOR_ASSERT_TRAVERSAL - + private: // data members Base m_iterator; }; +} // namespace iterators + +using iterators::iterator_adaptor; +using iterators::enable_if_convertible; + } // namespace boost #include diff --git a/include/boost/iterator/iterator_archetypes.hpp b/include/boost/iterator/iterator_archetypes.hpp index ef60d9c..3e9d444 100644 --- a/include/boost/iterator/iterator_archetypes.hpp +++ b/include/boost/iterator/iterator_archetypes.hpp @@ -31,6 +31,7 @@ #include namespace boost { +namespace iterators { template struct access_archetype; @@ -38,7 +39,7 @@ struct access_archetype; template struct traversal_archetype; -namespace iterator_archetypes +namespace archetypes { enum { readable_iterator_bit = 1 @@ -50,19 +51,19 @@ namespace iterator_archetypes // Not quite tags, since dispatching wouldn't work. typedef mpl::int_::type readable_iterator_t; typedef mpl::int_::type writable_iterator_t; - + typedef mpl::int_< (readable_iterator_bit|writable_iterator_bit) >::type readable_writable_iterator_t; - + typedef mpl::int_< (readable_iterator_bit|lvalue_iterator_bit) >::type readable_lvalue_iterator_t; - + typedef mpl::int_< (lvalue_iterator_bit|writable_iterator_bit) >::type writable_lvalue_iterator_t; - + typedef mpl::int_::type swappable_iterator_t; typedef mpl::int_::type lvalue_iterator_t; @@ -121,15 +122,15 @@ namespace detail : mpl::eval_if< is_convertible , mpl::eval_if< - iterator_archetypes::has_access< + archetypes::has_access< AccessCategory - , iterator_archetypes::writable_iterator_t + , archetypes::writable_iterator_t > , mpl::identity > , mpl::if_< - iterator_archetypes::has_access< + archetypes::has_access< AccessCategory - , iterator_archetypes::readable_iterator_t + , archetypes::readable_iterator_t > , readable_operator_brackets , no_operator_brackets @@ -138,7 +139,7 @@ namespace detail , mpl::identity >::type {}; - + template struct traversal_archetype_impl { @@ -156,11 +157,11 @@ namespace detail typedef typename traversal_archetype_impl::template archetype base; - + traversal_archetype_() {} traversal_archetype_(ctor_arg arg) - : base(arg) + : base(arg) {} }; @@ -191,7 +192,7 @@ namespace detail explicit archetype(ctor_arg arg) : traversal_archetype_(arg) {} - + typedef std::ptrdiff_t difference_type; }; }; @@ -199,7 +200,7 @@ namespace detail template bool operator==(traversal_archetype_ const&, traversal_archetype_ const&) { return true; } - + template <> struct traversal_archetype_impl { @@ -207,7 +208,7 @@ namespace detail struct archetype : public traversal_archetype_ { - archetype() + archetype() : traversal_archetype_(ctor_arg()) {} }; @@ -230,7 +231,7 @@ namespace detail { template struct archetype - : public traversal_archetype_ + : public traversal_archetype_ { Derived& operator+=(std::ptrdiff_t) { return static_object::get(); } Derived& operator-=(std::ptrdiff_t) { return static_object::get(); } @@ -289,7 +290,7 @@ namespace detail template struct undefined; - + template struct iterator_access_archetype_impl { @@ -306,7 +307,7 @@ struct iterator_access_archetype template <> struct iterator_access_archetype_impl< - iterator_archetypes::readable_iterator_t + archetypes::readable_iterator_t > { template @@ -324,7 +325,7 @@ struct iterator_access_archetype_impl< template <> struct iterator_access_archetype_impl< - iterator_archetypes::writable_iterator_t + archetypes::writable_iterator_t > { template @@ -341,13 +342,13 @@ struct iterator_access_archetype_impl< template <> struct iterator_access_archetype_impl< - iterator_archetypes::readable_writable_iterator_t + archetypes::readable_writable_iterator_t > { template struct archetype : public virtual iterator_access_archetype< - Value, iterator_archetypes::readable_iterator_t + Value, archetypes::readable_iterator_t > { typedef detail::read_write_proxy reference; @@ -357,12 +358,12 @@ struct iterator_access_archetype_impl< }; template <> -struct iterator_access_archetype_impl +struct iterator_access_archetype_impl { template struct archetype : public virtual iterator_access_archetype< - Value, iterator_archetypes::readable_iterator_t + Value, archetypes::readable_iterator_t > { typedef Value& reference; @@ -371,26 +372,26 @@ struct iterator_access_archetype_impl() const { return 0; } }; }; - + template <> -struct iterator_access_archetype_impl +struct iterator_access_archetype_impl { template struct archetype : public virtual iterator_access_archetype< - Value, iterator_archetypes::readable_lvalue_iterator_t + Value, archetypes::readable_lvalue_iterator_t > { BOOST_STATIC_ASSERT((!is_const::value)); }; }; - + template struct iterator_archetype; - + template -struct traversal_archetype_base +struct traversal_archetype_base : detail::operator_brackets< typename remove_cv::type , AccessCategory @@ -412,12 +413,12 @@ namespace detail , traversal_archetype_base { typedef iterator_access_archetype access; - + typedef typename detail::facade_iterator_category< TraversalCategory , typename mpl::eval_if< - iterator_archetypes::has_access< - AccessCategory, iterator_archetypes::writable_iterator_t + archetypes::has_access< + AccessCategory, archetypes::writable_iterator_t > , remove_const , add_const @@ -450,18 +451,18 @@ struct iterator_archetype , public detail::iterator_archetype_base< Value, AccessCategory, TraversalCategory >::workaround_iterator_base -# endif +# endif { // Derivation from std::iterator above caused references to nested // types to be ambiguous, so now we have to redeclare them all // here. # if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, < 310) \ || BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(0x20101)) - + typedef detail::iterator_archetype_base< Value,AccessCategory,TraversalCategory > base; - + typedef typename base::value_type value_type; typedef typename base::reference reference; typedef typename base::pointer pointer; @@ -492,7 +493,17 @@ struct iterator_archetype # endif }; +} // namespace iterators + +// Backward compatibility names +namespace iterator_archetypes = iterators::archetypes; +using iterators::access_archetype; +using iterators::traversal_archetype; +using iterators::iterator_archetype; +using iterators::undefined; +using iterators::iterator_access_archetype_impl; +using iterators::traversal_archetype_base; + } // namespace boost - #endif // BOOST_ITERATOR_ARCHETYPES_HPP diff --git a/include/boost/iterator/iterator_categories.hpp b/include/boost/iterator/iterator_categories.hpp index 24bf4e2..20baf6d 100644 --- a/include/boost/iterator/iterator_categories.hpp +++ b/include/boost/iterator/iterator_categories.hpp @@ -22,6 +22,7 @@ # include namespace boost { +namespace iterators { // // Traversal Categories @@ -29,34 +30,34 @@ namespace boost { struct no_traversal_tag {}; -struct incrementable_traversal_tag +struct incrementable_traversal_tag : no_traversal_tag { // incrementable_traversal_tag() {} // incrementable_traversal_tag(std::output_iterator_tag const&) {}; }; - + struct single_pass_traversal_tag : incrementable_traversal_tag { // single_pass_traversal_tag() {} // single_pass_traversal_tag(std::input_iterator_tag const&) {}; }; - + struct forward_traversal_tag : single_pass_traversal_tag { // forward_traversal_tag() {} // forward_traversal_tag(std::forward_iterator_tag const&) {}; }; - + struct bidirectional_traversal_tag : forward_traversal_tag { // bidirectional_traversal_tag() {}; // bidirectional_traversal_tag(std::bidirectional_iterator_tag const&) {}; }; - + struct random_access_traversal_tag : bidirectional_traversal_tag { @@ -65,7 +66,7 @@ struct random_access_traversal_tag }; namespace detail -{ +{ // // Convert a "strictly old-style" iterator category to a traversal // tag. This is broken out into a separate metafunction to reduce @@ -122,7 +123,7 @@ namespace detail > { }; - + } // namespace detail @@ -134,7 +135,7 @@ struct iterator_category_to_traversal : mpl::eval_if< // if already convertible to a traversal tag, we're done. is_convertible , mpl::identity - , boost::detail::old_category_to_traversal + , boost::iterators::detail::old_category_to_traversal > {}; @@ -165,6 +166,17 @@ struct iterator_traversal {}; # endif +} // namespace iterators + +using iterators::no_traversal_tag; +using iterators::incrementable_traversal_tag; +using iterators::single_pass_traversal_tag; +using iterators::forward_traversal_tag; +using iterators::bidirectional_traversal_tag; +using iterators::random_access_traversal_tag; +using iterators::iterator_category_to_traversal; +using iterators::iterator_traversal; + } // namespace boost #include diff --git a/include/boost/iterator/iterator_concepts.hpp b/include/boost/iterator/iterator_concepts.hpp index ced1112..ae6c4b3 100644 --- a/include/boost/iterator/iterator_concepts.hpp +++ b/include/boost/iterator/iterator_concepts.hpp @@ -56,7 +56,7 @@ namespace boost_concepts private: Iterator i; }; - + template < typename Iterator , typename ValueType = BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::value_type @@ -78,7 +78,7 @@ namespace boost_concepts , typename ValueType = BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::value_type > struct WritableIteratorConcept : WritableIterator {}; - + BOOST_concept(SwappableIterator,(Iterator)) { BOOST_CONCEPT_USAGE(SwappableIterator) @@ -93,7 +93,7 @@ namespace boost_concepts BOOST_concept(LvalueIterator,(Iterator)) { typedef typename boost::detail::iterator_traits::value_type value_type; - + BOOST_CONCEPT_USAGE(LvalueIterator) { value_type& r = const_cast(*i); @@ -103,7 +103,7 @@ namespace boost_concepts Iterator i; }; - + //=========================================================================== // Iterator Traversal Concepts @@ -145,7 +145,7 @@ namespace boost_concepts , boost::DefaultConstructible { 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); @@ -155,7 +155,7 @@ namespace boost_concepts , boost::forward_traversal_tag > )); }; - + BOOST_concept(BidirectionalTraversal,(Iterator)) : ForwardTraversal { @@ -192,14 +192,14 @@ namespace boost_concepts i = i - n; n = i - j; } - + private: typename BidirectionalTraversal::difference_type n; Iterator i, j; }; //=========================================================================== - // Iterator Interoperability + // Iterator Interoperability namespace detail { @@ -248,18 +248,18 @@ namespace boost_concepts BOOST_concept(InteroperableIterator,(Iterator)(ConstIterator)) { private: - typedef typename boost::detail::pure_traversal_tag< + typedef typename boost::iterators::detail::pure_traversal_tag< typename boost::iterator_traversal< Iterator >::type >::type traversal_category; - typedef typename boost::detail::pure_traversal_tag< + typedef typename boost::iterators::detail::pure_traversal_tag< typename boost::iterator_traversal< ConstIterator >::type >::type const_traversal_category; - + public: BOOST_CONCEPT_ASSERT((SinglePassIterator)); BOOST_CONCEPT_ASSERT((SinglePassIterator)); @@ -271,7 +271,7 @@ namespace boost_concepts ci = i; } - + private: Iterator i; ConstIterator ci; diff --git a/include/boost/iterator/iterator_facade.hpp b/include/boost/iterator/iterator_facade.hpp index 5ac1cb6..c08a869 100644 --- a/include/boost/iterator/iterator_facade.hpp +++ b/include/boost/iterator/iterator_facade.hpp @@ -38,8 +38,9 @@ #include // this goes last -namespace boost -{ +namespace boost { +namespace iterators { + // This forward declaration is required for the friend declaration // in iterator_core_access template class iterator_facade; @@ -118,7 +119,7 @@ namespace boost // Not the real associated pointer type typedef typename mpl::eval_if< - boost::detail::iterator_writability_disabled + boost::iterators::detail::iterator_writability_disabled , add_pointer , add_pointer >::type pointer; @@ -462,15 +463,15 @@ namespace boost # endif # define BOOST_ITERATOR_FACADE_INTEROP_HEAD(prefix, op, result_type) \ - BOOST_ITERATOR_FACADE_INTEROP_HEAD_IMPL(prefix, op, result_type, boost::detail::enable_if_interoperable) + BOOST_ITERATOR_FACADE_INTEROP_HEAD_IMPL(prefix, op, result_type, boost::iterators::detail::enable_if_interoperable) # define BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS_HEAD(prefix, op, result_type) \ - BOOST_ITERATOR_FACADE_INTEROP_HEAD_IMPL(prefix, op, result_type, boost::detail::enable_if_interoperable_and_random_access_traversal) + BOOST_ITERATOR_FACADE_INTEROP_HEAD_IMPL(prefix, op, result_type, boost::iterators::detail::enable_if_interoperable_and_random_access_traversal) # define BOOST_ITERATOR_FACADE_PLUS_HEAD(prefix,args) \ template \ prefix typename boost::iterators::enable_if< \ - boost::detail::is_traversal_at_least< TC, boost::random_access_traversal_tag >, \ + boost::iterators::detail::is_traversal_at_least< TC, boost::iterators::random_access_traversal_tag >, \ Derived \ >::type operator+ args @@ -496,7 +497,7 @@ namespace boost friend class detail::iterator_facade_base; # define BOOST_ITERATOR_FACADE_RELATION(op) \ - BOOST_ITERATOR_FACADE_INTEROP_HEAD(friend,op, boost::detail::always_bool2); + BOOST_ITERATOR_FACADE_INTEROP_HEAD(friend,op, boost::iterators::detail::always_bool2); BOOST_ITERATOR_FACADE_RELATION(==) BOOST_ITERATOR_FACADE_RELATION(!=) @@ -504,7 +505,7 @@ namespace boost # undef BOOST_ITERATOR_FACADE_RELATION # define BOOST_ITERATOR_FACADE_RANDOM_ACCESS_RELATION(op) \ - BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS_HEAD(friend,op, boost::detail::always_bool2); + BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS_HEAD(friend,op, boost::iterators::detail::always_bool2); BOOST_ITERATOR_FACADE_RANDOM_ACCESS_RELATION(<) BOOST_ITERATOR_FACADE_RANDOM_ACCESS_RELATION(>) @@ -514,7 +515,7 @@ namespace boost # undef BOOST_ITERATOR_FACADE_RANDOM_ACCESS_RELATION BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS_HEAD( - friend, -, boost::detail::choose_difference_type) + friend, -, boost::iterators::detail::choose_difference_type) ; BOOST_ITERATOR_FACADE_PLUS_HEAD( @@ -614,18 +615,18 @@ namespace boost > class iterator_facade_base< Derived, Value, CategoryOrTraversal, Reference, Difference, false, false > # ifdef BOOST_ITERATOR_FACADE_NEEDS_ITERATOR_BASE - : public boost::detail::iterator_facade_types< + : public boost::iterators::detail::iterator_facade_types< Value, CategoryOrTraversal, Reference, Difference >::base # undef BOOST_ITERATOR_FACADE_NEEDS_ITERATOR_BASE # endif { private: - typedef boost::detail::iterator_facade_types< + typedef boost::iterators::detail::iterator_facade_types< Value, CategoryOrTraversal, Reference, Difference > associated_types; - typedef boost::detail::operator_arrow_dispatch< + typedef boost::iterators::detail::operator_arrow_dispatch< Reference , typename associated_types::pointer > operator_arrow_dispatch_; @@ -716,12 +717,12 @@ namespace boost typedef typename base_type::difference_type difference_type; public: - typename boost::detail::operator_brackets_result::type + typename boost::iterators::detail::operator_brackets_result::type operator[](difference_type n) const { - typedef boost::detail::use_operator_brackets_proxy use_proxy; + typedef boost::iterators::detail::use_operator_brackets_proxy use_proxy; - return boost::detail::make_operator_brackets_result( + return boost::iterators::detail::make_operator_brackets_result( this->derived() + n , use_proxy() ); @@ -776,13 +777,13 @@ namespace boost }; template - inline typename boost::detail::postfix_increment_result::type + inline typename boost::iterators::detail::postfix_increment_result::type operator++( iterator_facade& i , int ) { - typename boost::detail::postfix_increment_result::type + typename boost::iterators::detail::postfix_increment_result::type tmp(*static_cast(&i)); ++i; @@ -881,7 +882,7 @@ namespace boost # define BOOST_ITERATOR_FACADE_RELATION(op, return_prefix, base_op) \ BOOST_ITERATOR_FACADE_INTEROP( \ op \ - , boost::detail::always_bool2 \ + , boost::iterators::detail::always_bool2 \ , return_prefix \ , base_op \ ) @@ -898,8 +899,8 @@ namespace boost /* For those compilers that do not support enable_if */ \ BOOST_STATIC_ASSERT(( \ is_interoperable< Derived1, Derived2 >::value && \ - boost::detail::is_traversal_at_least< typename iterator_category< Derived1 >::type, random_access_traversal_tag >::value && \ - boost::detail::is_traversal_at_least< typename iterator_category< Derived2 >::type, random_access_traversal_tag >::value \ + boost::iterators::detail::is_traversal_at_least< typename iterator_category< Derived1 >::type, random_access_traversal_tag >::value && \ + boost::iterators::detail::is_traversal_at_least< typename iterator_category< Derived2 >::type, random_access_traversal_tag >::value \ )); \ return_prefix iterator_core_access::base_op( \ *static_cast(&lhs) \ @@ -911,7 +912,7 @@ namespace boost # define BOOST_ITERATOR_FACADE_RANDOM_ACCESS_RELATION(op, return_prefix, base_op) \ BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS( \ op \ - , boost::detail::always_bool2 \ + , boost::iterators::detail::always_bool2 \ , return_prefix \ , base_op \ ) @@ -926,7 +927,7 @@ namespace boost // operator- requires an additional part in the static assertion BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS( - - , boost::detail::choose_difference_type + , boost::iterators::detail::choose_difference_type , return , distance_from ) @@ -941,15 +942,15 @@ namespace boost return tmp += n; \ } -BOOST_ITERATOR_FACADE_PLUS(( - iterator_facade const& i - , typename Derived::difference_type n -)) + BOOST_ITERATOR_FACADE_PLUS(( + iterator_facade const& i + , typename Derived::difference_type n + )) -BOOST_ITERATOR_FACADE_PLUS(( - typename Derived::difference_type n + BOOST_ITERATOR_FACADE_PLUS(( + typename Derived::difference_type n , iterator_facade const& i -)) + )) # undef BOOST_ITERATOR_FACADE_PLUS # undef BOOST_ITERATOR_FACADE_PLUS_HEAD @@ -958,6 +959,11 @@ BOOST_ITERATOR_FACADE_PLUS(( # undef BOOST_ITERATOR_FACADE_INTEROP_RANDOM_ACCESS_HEAD # undef BOOST_ITERATOR_FACADE_INTEROP_HEAD_IMPL +} // namespace iterators + +using iterators::iterator_core_access; +using iterators::iterator_facade; + } // namespace boost #include diff --git a/include/boost/iterator/iterator_traits.hpp b/include/boost/iterator/iterator_traits.hpp index 39e08c0..1a5f1e0 100644 --- a/include/boost/iterator/iterator_traits.hpp +++ b/include/boost/iterator/iterator_traits.hpp @@ -8,7 +8,8 @@ # include # include -namespace boost { +namespace boost { +namespace iterators { // Macro for supporting old compilers, no longer needed but kept // for backwards compatibility (it was documented). @@ -20,20 +21,20 @@ struct iterator_value { typedef typename boost::detail::iterator_traits::value_type type; }; - + template struct iterator_reference { typedef typename boost::detail::iterator_traits::reference type; }; - - + + template struct iterator_pointer { typedef typename boost::detail::iterator_traits::pointer type; }; - + template struct iterator_difference { @@ -46,6 +47,14 @@ struct iterator_category typedef typename boost::detail::iterator_traits::iterator_category type; }; -} // namespace boost::iterator +} // namespace iterators + +using iterators::iterator_value; +using iterators::iterator_reference; +using iterators::iterator_pointer; +using iterators::iterator_difference; +using iterators::iterator_category; + +} // namespace boost #endif // ITERATOR_TRAITS_DWA200347_HPP diff --git a/include/boost/iterator/permutation_iterator.hpp b/include/boost/iterator/permutation_iterator.hpp index 23d1198..32648b0 100644 --- a/include/boost/iterator/permutation_iterator.hpp +++ b/include/boost/iterator/permutation_iterator.hpp @@ -13,28 +13,28 @@ #include -namespace boost -{ +namespace boost { +namespace iterators { template< class ElementIterator , class IndexIterator> class permutation_iterator - : public iterator_adaptor< + : public iterator_adaptor< permutation_iterator - , IndexIterator, typename detail::iterator_traits::value_type - , use_default, typename detail::iterator_traits::reference> + , IndexIterator, typename boost::detail::iterator_traits::value_type + , use_default, typename boost::detail::iterator_traits::reference> { - typedef iterator_adaptor< + typedef iterator_adaptor< permutation_iterator - , IndexIterator, typename detail::iterator_traits::value_type - , use_default, typename detail::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; public: permutation_iterator() : m_elt_iter() {} - explicit permutation_iterator(ElementIterator x, IndexIterator y) + explicit permutation_iterator(ElementIterator x, IndexIterator y) : super_t(y), m_elt_iter(x) {} template @@ -54,18 +54,22 @@ private: template friend class permutation_iterator; #else public: -#endif +#endif ElementIterator m_elt_iter; }; template -permutation_iterator +inline permutation_iterator make_permutation_iterator( ElementIterator e, IndexIterator i ) { return permutation_iterator( e, i ); } +} // namespace iterators + +using iterators::permutation_iterator; +using iterators::make_permutation_iterator; } // namespace boost diff --git a/include/boost/iterator/reverse_iterator.hpp b/include/boost/iterator/reverse_iterator.hpp index 79cc7f2..3bef39e 100644 --- a/include/boost/iterator/reverse_iterator.hpp +++ b/include/boost/iterator/reverse_iterator.hpp @@ -11,8 +11,8 @@ #include #include -namespace boost -{ +namespace boost { +namespace iterators { // // @@ -28,7 +28,7 @@ namespace boost public: reverse_iterator() {} - explicit reverse_iterator(Iterator x) + explicit reverse_iterator(Iterator x) : super_t(x) {} template @@ -41,7 +41,7 @@ namespace boost private: typename super_t::reference dereference() const { return *boost::prior(this->base()); } - + void increment() { --this->base_reference(); } void decrement() { ++this->base_reference(); } @@ -59,11 +59,16 @@ namespace boost }; template - reverse_iterator make_reverse_iterator(BidirectionalIterator x) + inline reverse_iterator make_reverse_iterator(BidirectionalIterator x) { return reverse_iterator(x); } +} // namespace iterators + +using iterators::reverse_iterator; +using iterators::make_reverse_iterator; + } // namespace boost #endif // BOOST_REVERSE_ITERATOR_23022003THW_HPP diff --git a/include/boost/iterator/transform_iterator.hpp b/include/boost/iterator/transform_iterator.hpp index 168cb53..851f16f 100644 --- a/include/boost/iterator/transform_iterator.hpp +++ b/include/boost/iterator/transform_iterator.hpp @@ -26,16 +26,17 @@ #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310)) # include -#endif +#endif #include -namespace boost -{ +namespace boost { +namespace iterators { + template class transform_iterator; - namespace detail + namespace detail { // Compute the iterator_adaptor instantiation to be used for transform_iterator template @@ -72,10 +73,10 @@ namespace boost template class transform_iterator - : public boost::detail::transform_iterator_base::type + : public boost::iterators::detail::transform_iterator_base::type { typedef typename - boost::detail::transform_iterator_base::type + boost::iterators::detail::transform_iterator_base::type super_t; friend class iterator_core_access; @@ -95,7 +96,7 @@ namespace boost // don't provide this constructor if UnaryFunc is a // function pointer type, since it will be 0. Too dangerous. BOOST_STATIC_ASSERT(is_class::value); -#endif +#endif } template < @@ -108,7 +109,7 @@ namespace boost , typename enable_if_convertible::type* = 0 #if !BOOST_WORKAROUND(BOOST_MSVC, == 1310) , typename enable_if_convertible::type* = 0 -#endif +#endif ) : super_t(t.base()), m_f(t.functor()) {} @@ -126,7 +127,7 @@ namespace boost }; template - transform_iterator + inline transform_iterator make_transform_iterator(Iterator it, UnaryFunc fun) { return transform_iterator(it, fun); @@ -140,7 +141,7 @@ namespace boost // function pointer in the iterator be 0, leading to a runtime // crash. template - typename iterators::enable_if< + inline typename iterators::enable_if< is_class // We should probably find a cheaper test than is_class<> , transform_iterator >::type @@ -151,13 +152,18 @@ namespace boost #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) template - transform_iterator< Return (*)(Argument), Iterator, Return> + inline transform_iterator< Return (*)(Argument), Iterator, Return> make_transform_iterator(Iterator it, Return (*fun)(Argument)) { return transform_iterator(it, fun); } #endif +} // namespace iterators + +using iterators::transform_iterator; +using iterators::make_transform_iterator; + } // namespace boost #include diff --git a/include/boost/iterator/zip_iterator.hpp b/include/boost/iterator/zip_iterator.hpp index cc30388..fbbc1e7 100644 --- a/include/boost/iterator/zip_iterator.hpp +++ b/include/boost/iterator/zip_iterator.hpp @@ -27,6 +27,7 @@ #include namespace boost { +namespace iterators { // Zip iterator forward declaration for zip_iterator_base template @@ -60,7 +61,7 @@ namespace boost { { public: advance_iterator(DiffType step) : m_step(step) {} - + template void operator()(Iterator& it) const { it += m_step; } @@ -87,9 +88,9 @@ namespace boost { { template struct apply - { + { typedef typename - iterator_traits::reference + boost::detail::iterator_traits::reference type; }; @@ -97,7 +98,7 @@ namespace boost { typename apply::type operator()(Iterator const& it) { return *it; } }; - + // The namespace tuple_impl_specific provides two meta- // algorithms and two algorithms for tuples. @@ -108,7 +109,7 @@ namespace boost { // template struct tuple_meta_transform; - + template struct tuple_meta_transform_impl { @@ -119,7 +120,7 @@ namespace boost { >::type , typename tuple_meta_transform< typename Tuple::tail_type - , UnaryMetaFun + , UnaryMetaFun >::type > type; }; @@ -133,14 +134,14 @@ namespace boost { > { }; - - // Meta-accumulate algorithm for tuples. Note: The template - // parameter StartType corresponds to the initial value in + + // 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 @@ -154,7 +155,7 @@ namespace boost { , typename tuple_meta_accumulate< typename Tuple::tail_type , BinaryMetaFun - , StartType + , StartType >::type >::type type; }; @@ -175,7 +176,7 @@ namespace boost { > > { - }; + }; #if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \ || ( \ @@ -183,17 +184,17 @@ namespace boost { ) // 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 +#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 @@ -211,22 +212,22 @@ namespace boost { // Arg* operator()(Arg x); // }; template - tuples::null_type BOOST_TUPLE_ALGO(tuple_transform) + inline tuples::null_type BOOST_TUPLE_ALGO(tuple_transform) (tuples::null_type const&, Fun BOOST_TUPLE_ALGO_TERMINATOR) { return tuples::null_type(); } template - typename tuple_meta_transform< + inline typename tuple_meta_transform< Tuple , Fun >::type - + BOOST_TUPLE_ALGO(tuple_transform)( - const Tuple& t, + const Tuple& t, Fun f BOOST_TUPLE_ALGO_RECURSE ) - { + { typedef typename tuple_meta_transform< BOOST_DEDUCED_TYPENAME Tuple::tail_type , Fun @@ -237,58 +238,58 @@ namespace boost { 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< + inline typename tuple_meta_transform< Tuple , Fun >::type - + tuple_transform( - const Tuple& t, + 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)( + inline 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)( + inline Fun BOOST_TUPLE_ALGO(tuple_for_each)( Tuple& t , Fun f BOOST_TUPLE_ALGO_RECURSE) - { + { f( t.get_head() ); return tuple_for_each(t.get_tail(), f); } - + #ifdef BOOST_TUPLE_ALGO_DISPATCH template - Fun + inline Fun tuple_for_each( - Tuple& t, + 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 @@ -298,12 +299,9 @@ namespace boost { { return true; } template - bool tuple_equal( - Tuple1 const& t1, - Tuple2 const& t2 - ) - { - return t1.get_head() == t2.get_head() && + inline bool tuple_equal(Tuple1 const& t1, Tuple2 const& t2) + { + return t1.get_head() == t2.get_head() && tuple_equal(t1.get_tail(), t2.get_tail()); } } @@ -313,7 +311,7 @@ namespace boost { template struct iterator_reference { - typedef typename iterator_traits::reference type; + typedef typename boost::detail::iterator_traits::reference type; }; #ifdef BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT @@ -329,14 +327,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, + IteratorTuple, iterator_reference > { @@ -352,14 +350,14 @@ namespace boost { IteratorTuple , pure_traversal_tag > >::type tuple_of_traversal_tags; - + typedef typename tuple_impl_specific::tuple_meta_accumulate< tuple_of_traversal_tags , minimum_category<> , random_access_traversal_tag >::type type; }; - + // 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 @@ -370,7 +368,7 @@ namespace boost { : 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 @@ -381,13 +379,13 @@ namespace boost { struct apply : mpl::and_ {}; }; -# endif +# 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 @@ -396,30 +394,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< + typedef typename boost::detail::iterator_traits< typename tuples::element<0, IteratorTuple>::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 @@ -432,34 +430,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 @@ -478,15 +476,15 @@ 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( + { + return detail::tuple_impl_specific::tuple_transform( get_iterator_tuple(), detail::dereference_iterator() ); @@ -502,7 +500,7 @@ 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( @@ -514,7 +512,7 @@ namespace boost { // Advancing a zip iterator means to advance all iterators in the // iterator tuple. void advance(typename super_t::difference_type n) - { + { detail::tuple_impl_specific::tuple_for_each( m_iterator_tuple, detail::advance_iterator(n) @@ -523,48 +521,53 @@ namespace boost { // Incrementing a zip iterator means to increment all iterators in // the iterator tuple. void increment() - { + { detail::tuple_impl_specific::tuple_for_each( m_iterator_tuple, detail::increment_iterator() ); } - + // Decrementing a zip iterator means to decrement all iterators in // the iterator tuple. void decrement() - { + { detail::tuple_impl_specific::tuple_for_each( m_iterator_tuple, detail::decrement_iterator() ); } - + // Distance is calculated using the first iterator in the tuple. template typename super_t::difference_type distance_to( const zip_iterator& other ) const - { - return boost::tuples::get<0>(other.get_iterator_tuple()) - + { + return boost::tuples::get<0>(other.get_iterator_tuple()) - boost::tuples::get<0>(this->get_iterator_tuple()); } - + // Data Members // ============ - + // The iterator tuple. IteratorTuple m_iterator_tuple; - + }; // Make function for zip iterator // - template - zip_iterator + template + inline zip_iterator make_zip_iterator(IteratorTuple t) { return zip_iterator(t); } -} +} // namespace iterators + +using iterators::zip_iterator; +using iterators::make_zip_iterator; + +} // namespace boost #endif diff --git a/include/boost/pending/detail/int_iterator.hpp b/include/boost/pending/detail/int_iterator.hpp index e3bae34..ca8372b 100644 --- a/include/boost/pending/detail/int_iterator.hpp +++ b/include/boost/pending/detail/int_iterator.hpp @@ -15,6 +15,7 @@ #ifndef BOOST_NO_OPERATORS_IN_NAMESPACE namespace boost { +namespace iterators { #endif // this should use random_access_iterator_helper but I've had @@ -61,13 +62,19 @@ inline int_iterator operator+(IntT n, int_iterator t) { t += n; return t; } #ifndef BOOST_NO_OPERATORS_IN_NAMESPACE +} /* namespace iterators */ + +using iterators::int_iterator; + } /* namespace boost */ #endif #ifdef BOOST_NO_OPERATORS_IN_NAMESPACE namespace boost { - using ::int_iterator; -} +using ::int_iterator; +namespace iterators { +using ::int_iterator; +}} #endif diff --git a/include/boost/pending/iterator_tests.hpp b/include/boost/pending/iterator_tests.hpp index f9d6e9c..37c839b 100644 --- a/include/boost/pending/iterator_tests.hpp +++ b/include/boost/pending/iterator_tests.hpp @@ -29,11 +29,11 @@ namespace boost { // use this for the value type -struct dummyT { +struct dummyT { dummyT() { } dummyT(detail::dummy_constructor) { } dummyT(int x) : m_x(x) { } - int foo() const { return m_x; } + int foo() const { return m_x; } bool operator==(const dummyT& d) const { return m_x == d.m_x; } int m_x; }; @@ -41,9 +41,10 @@ struct dummyT { } namespace boost { +namespace iterators { // Tests whether type Iterator satisfies the requirements for a -// TrivialIterator. +// TrivialIterator. // Preconditions: i != j, *i == val template void trivial_iterator_test(const Iterator i, const Iterator j, T val) @@ -84,7 +85,7 @@ void mutable_trivial_iterator_test(const Iterator i, const Iterator j, T val) // Preconditions: *i == v1, *++i == v2 template -void input_iterator_test(Iterator i, T v1, T v2) +void input_iterator_test(Iterator i, T v1, T v2) { Iterator i1(i); @@ -150,7 +151,7 @@ template <> struct lvalue_test { #endif template -void forward_iterator_test(Iterator i, T v1, T v2) +void forward_iterator_test(Iterator i, T v1, T v2) { input_iterator_test(i, v1, v2); @@ -215,7 +216,7 @@ void random_access_iterator_test(Iterator i, int N, TrueVals vals) int c; typedef typename boost::detail::iterator_traits::value_type value_type; - + for (c = 0; c < N-1; ++c) { assert(i == j + c); assert(*i == vals[c]); @@ -234,7 +235,7 @@ void random_access_iterator_test(Iterator i, int N, TrueVals vals) assert(i == k - c); assert(*i == vals[N - 1 - c]); assert(*i == boost::implicit_cast(j[N - 1 - c])); - Iterator q = k - c; + Iterator q = k - c; assert(*i == *q); assert(i > j); assert(i >= j); @@ -260,6 +261,18 @@ void const_nonconst_iterator_test(Iterator i, ConstIterator j) assert(i == k); } +} // namespace iterators + +using iterators::undefined; +using iterators::trivial_iterator_test; +using iterators::mutable_trivial_iterator_test; +using iterators::input_iterator_test; +using iterators::lvalue_test; +using iterators::forward_iterator_test; +using iterators::bidirectional_iterator_test; +using iterators::random_access_iterator_test; +using iterators::const_nonconst_iterator_test; + } // namespace boost #endif // BOOST_ITERATOR_TESTS_HPP diff --git a/include/boost/shared_container_iterator.hpp b/include/boost/shared_container_iterator.hpp index 7d8ecd3..e803bd6 100644 --- a/include/boost/shared_container_iterator.hpp +++ b/include/boost/shared_container_iterator.hpp @@ -13,6 +13,7 @@ #include namespace boost { +namespace iterators { template class shared_container_iterator : public iterator_adaptor< @@ -37,7 +38,7 @@ public: }; template -shared_container_iterator +inline shared_container_iterator make_shared_container_iterator(typename Container::iterator iter, boost::shared_ptr const& container) { typedef shared_container_iterator iterator; @@ -47,7 +48,7 @@ make_shared_container_iterator(typename Container::iterator iter, template -std::pair< +inline std::pair< shared_container_iterator, shared_container_iterator > make_shared_container_range(boost::shared_ptr const& container) { @@ -57,6 +58,12 @@ make_shared_container_range(boost::shared_ptr const& container) { make_shared_container_iterator(container->end(),container)); } +} // namespace iterators + +using iterators::shared_container_iterator; +using iterators::make_shared_container_iterator; +using iterators::make_shared_container_range; } // namespace boost + #endif // SHARED_CONTAINER_ITERATOR_RG08102002_HPP diff --git a/test/unit_tests.cpp b/test/unit_tests.cpp index c53627d..bcad0d6 100644 --- a/test/unit_tests.cpp +++ b/test/unit_tests.cpp @@ -29,30 +29,30 @@ void operator_arrow_test() template struct static_assert_min_cat : static_assert_same< - typename boost::detail::minimum_category::type, Min + typename boost::iterators::detail::minimum_category::type, Min > {}; void category_test() { - using namespace boost; - using namespace boost::detail; - + using namespace boost::iterators; + using namespace boost::iterators::detail; + BOOST_STATIC_ASSERT(( !boost::is_convertible< std::input_iterator_tag , input_output_iterator_tag>::value)); - + BOOST_STATIC_ASSERT(( !boost::is_convertible< std::output_iterator_tag , input_output_iterator_tag>::value)); - + BOOST_STATIC_ASSERT(( boost::is_convertible< input_output_iterator_tag , std::input_iterator_tag>::value)); - + BOOST_STATIC_ASSERT(( boost::is_convertible< input_output_iterator_tag @@ -64,7 +64,7 @@ void category_test() boost::is_convertible< std::forward_iterator_tag , input_output_iterator_tag>::value)); -#endif +#endif int test = static_assert_min_cat< std::input_iterator_tag,input_output_iterator_tag, std::input_iterator_tag @@ -78,7 +78,7 @@ void category_test() test = static_assert_min_cat< input_output_iterator_tag,std::forward_iterator_tag, input_output_iterator_tag >::value; -#endif +#endif test = static_assert_min_cat< std::input_iterator_tag,std::forward_iterator_tag, std::input_iterator_tag @@ -93,8 +93,8 @@ void category_test() test = static_assert_min_cat< std::output_iterator_tag,std::random_access_iterator_tag, std::output_iterator_tag >::value; -#endif - +#endif + (void)test; } diff --git a/test/zip_iterator_test.cpp b/test/zip_iterator_test.cpp index 8062f08..fd7628f 100644 --- a/test/zip_iterator_test.cpp +++ b/test/zip_iterator_test.cpp @@ -4,7 +4,7 @@ // http://www.boost.org/LICENSE_1_0.txt) // -// File: +// File: // ===== // zip_iterator_test_main.cpp @@ -57,7 +57,7 @@ template struct pure_traversal - : boost::detail::pure_traversal_tag< + : boost::iterators::detail::pure_traversal_tag< typename boost::iterator_traversal::type > {}; @@ -82,13 +82,13 @@ void category_test() ); } /// - + ///////////////////////////////////////////////////////////////////////////// // // Das Main Funktion // ///////////////////////////////////////////////////////////////////////////// - + int main( void ) { @@ -105,16 +105,16 @@ int main( void ) 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.; @@ -141,9 +141,9 @@ int main( void ) ) ); - boost::tuples::tuple val_tuple( + boost::tuples::tuple val_tuple( *zip_it_mixed); - + boost::tuples::tuple ref_tuple( *zip_it_mixed); @@ -177,7 +177,7 @@ int main( void ) std::cout << "Zip iterators with 12 components: " << std::flush; - + // Declare 12 containers // std::list li1; @@ -210,30 +210,30 @@ int main( void ) // typedefs for cons lists of iterators. typedef boost::tuples::cons< - std::set::iterator, + std::set::iterator, boost::tuples::tuple< std::vector::iterator, - std::list::iterator, - std::set::iterator, + std::list::iterator, + std::set::iterator, std::vector::iterator, - std::list::iterator, - std::set::iterator, + std::list::iterator, + std::set::iterator, std::vector::iterator, - std::list::iterator, - std::set::iterator, + std::list::iterator, + std::set::iterator, std::vector::const_iterator >::inherited > cons_11_its_type; // typedef boost::tuples::cons< - std::list::const_iterator, + 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&, + const int&, boost::tuples::tuple< int&, int&, @@ -249,7 +249,7 @@ int main( void ) > cons_11_refs_type; // typedef boost::tuples::cons< - const int&, + const int&, cons_11_refs_type > cons_12_refs_type; @@ -259,19 +259,19 @@ int main( void ) // Declare a 12-element zip iterator. zip_it_12_type zip_it_12( cons_12_its_type( - li1.begin(), + li1.begin(), cons_11_its_type( se1.begin(), boost::make_tuple( ve1.begin(), - li2.begin(), - se2.begin(), + li2.begin(), + se2.begin(), ve2.begin(), - li3.begin(), - se3.begin(), + li3.begin(), + se3.begin(), ve3.begin(), - li4.begin(), - se4.begin(), + li4.begin(), + se4.begin(), ve4.begin() ) ) @@ -281,7 +281,7 @@ int main( void ) // 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; @@ -315,12 +315,12 @@ int main( void ) 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, std::vector::const_iterator - > + > > zip_it_begin( boost::make_tuple( @@ -331,9 +331,9 @@ int main( void ) boost::zip_iterator< boost::tuples::tuple< - std::vector::const_iterator, + std::vector::const_iterator, std::vector::const_iterator - > + > > zip_it_run( boost::make_tuple( @@ -344,9 +344,9 @@ int main( void ) boost::zip_iterator< boost::tuples::tuple< - std::vector::const_iterator, + std::vector::const_iterator, std::vector::const_iterator - > + > > zip_it_end( boost::make_tuple( @@ -379,7 +379,7 @@ int main( void ) // Zip iterator decrementing and dereferencing // ///////////////////////////////////////////////////////////////////////////// - + std::cout << "Zip iterator -- and *: " << std::flush; @@ -408,13 +408,13 @@ int main( void ) // Zip iterator copy construction and equality // ///////////////////////////////////////////////////////////////////////////// - - std::cout << "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, std::vector::const_iterator > > zip_it_run_copy(zip_it_run); @@ -435,10 +435,10 @@ int main( void ) // 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; @@ -455,14 +455,14 @@ int main( void ) // 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) && zip_it_run == zip_it_run_copy ) { @@ -480,18 +480,18 @@ int main( void ) // 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) && + 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 ) { @@ -509,14 +509,14 @@ int main( void ) // 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) && + if( zip_it_run > zip_it_run_copy && + !( zip_it_run > ++zip_it_run_copy) && zip_it_run == zip_it_run_copy ) { @@ -534,17 +534,17 @@ int main( void ) // 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) + 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; @@ -589,13 +589,13 @@ int main( void ) 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; @@ -612,12 +612,12 @@ int main( void ) // 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 ) { @@ -641,7 +641,7 @@ int main( void ) // 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 ) { @@ -659,13 +659,13 @@ int main( void ) // 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 ) @@ -684,7 +684,7 @@ int main( void ) // Making zip iterators // ///////////////////////////////////////////////////////////////////////////// - + std::cout << "Making zip iterators: " << std::flush; @@ -694,13 +694,13 @@ int main( void ) std::copy( boost::make_zip_iterator( boost::make_tuple( - vect1.begin(), + vect1.begin(), vect2.begin() ) ), boost::make_zip_iterator( boost::make_tuple( - vect1.end(), + vect1.end(), vect2.end() ) ), @@ -729,19 +729,19 @@ int main( void ) // 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(), + intset.begin(), vect2.begin() ) ); @@ -751,10 +751,10 @@ int main( void ) std::set::iterator, std::vector::const_iterator > - > + > zip_it_half_const( boost::make_tuple( - intset.begin(), + intset.begin(), vect2.begin() ) ); @@ -764,10 +764,10 @@ int main( void ) std::set::iterator, std::vector::iterator > - > + > zip_it_non_const( boost::make_tuple( - intset.begin(), + intset.begin(), vect2.begin() ) ); @@ -776,7 +776,7 @@ int main( void ) 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) && @@ -801,7 +801,7 @@ int main( void ) 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< @@ -819,11 +819,11 @@ int main( void ) // typedef boost::zip_iterator< boost::tuples::tuple< - std::vector::const_iterator, + 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