diff --git a/iterator_adaptor_test.cpp b/iterator_adaptor_test.cpp index 4007420..f3c48a4 100644 --- a/iterator_adaptor_test.cpp +++ b/iterator_adaptor_test.cpp @@ -9,6 +9,10 @@ // See http://www.boost.org for most recent version including documentation. // Revision History +// 09 Feb 01 Use new reverse_ and indirect_ interfaces. Replace +// BOOST_NO_STD_ITERATOR_TRAITS with +// BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION to prove we've +// normalized to core compiler capabilities (David Abrahams) // 08 Feb 01 Use Jeremy's new make_reverse_iterator form; add more // comprehensive testing. Force-decay array function arguments to // pointers. @@ -33,6 +37,7 @@ #include #include + #include #include #include @@ -43,7 +48,6 @@ struct my_iterator_tag : public std::random_access_iterator_tag { }; - using boost::dummyT; struct my_iter_traits { @@ -68,6 +72,7 @@ typedef boost::iterator_adaptor const_my_iterator; + struct mult_functor { typedef int result_type; typedef int argument_type; @@ -99,7 +104,7 @@ struct one_or_four { } }; -typedef std::vector storage; +typedef std::deque storage; typedef std::deque pointer_deque; typedef std::set iterator_set; @@ -120,11 +125,9 @@ void more_indirect_iterator_tests() } typedef boost::indirect_iterator_pair_generator< - pointer_deque::iterator, - const int* -#ifdef BOOST_NO_STD_ITERATOR_TRAITS - , boost::iterator - , boost::iterator + pointer_deque::iterator +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + , int #endif > IndirectDeque; @@ -150,16 +153,14 @@ void more_indirect_iterator_tests() typedef boost::indirect_iterator_generator< iterator_set::iterator -# ifdef BOOST_NO_STD_ITERATOR_TRAITS - , boost::iterator -# endif +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + , int +#endif >::type indirect_set_iterator; typedef boost::indirect_iterator_generator< - iterator_set::iterator -# ifdef BOOST_NO_STD_ITERATOR_TRAITS - , boost::iterator -# endif + iterator_set::iterator, + const int >::type const_indirect_set_iterator; indirect_set_iterator sb(iter_set.begin()); @@ -228,44 +229,29 @@ main() dummyT* ptr[N]; for (int k = 0; k < N; ++k) ptr[k] = array + k; - + typedef boost::indirect_iterator_generator +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + , dummyT #endif >::type indirect_iterator; - typedef boost::indirect_iterator_generator -#endif - >::type const_indirect_iterator; + typedef boost::indirect_iterator_generator::type const_indirect_iterator; indirect_iterator i = ptr; boost::random_access_iterator_test(i, N, array); - typedef boost::iterator InnerTraits; - boost::random_access_iterator_test(boost::make_indirect_iterator(ptr, InnerTraits()), N, array); - -#ifndef BOOST_NO_STD_ITERATOR_TRAITS - boost::random_access_iterator_test(boost::make_indirect_iterator(ptr), N, array); -#endif - + boost::random_access_iterator_test(boost::make_indirect_iterator(ptr), N, array); + const_indirect_iterator j = ptr; boost::random_access_iterator_test(j, N, array); dummyT*const* const_ptr = ptr; - typedef boost::iterator ConstInnerTraits; - - boost::random_access_iterator_test(boost::make_indirect_iterator(const_ptr, ConstInnerTraits()), N, array); - -#ifndef BOOST_NO_STD_ITERATOR_TRAITS - boost::random_access_iterator_test(boost::make_indirect_iterator(const_ptr), N, array); -#endif + + boost::random_access_iterator_test(boost::make_indirect_iterator(const_ptr), N, array); boost::const_nonconst_iterator_test(i, ++j); - more_indirect_iterator_tests(); } @@ -300,18 +286,22 @@ main() std::copy(array, array + N, reversed); std::reverse(reversed, reversed + N); - typedef boost::reverse_iterator_generator + typedef boost::reverse_iterator_generator::type reverse_iterator; - typedef boost::reverse_iterator_generator + + typedef boost::reverse_iterator_generator::type const_reverse_iterator; + reverse_iterator i = reversed + N; boost::random_access_iterator_test(i, N, array); - typedef boost::iterator ReverseTraits; - boost::random_access_iterator_test(boost::make_reverse_iterator(reversed + N), N, array); -#ifndef BOOST_NO_STD_ITERATOR_TRAITS +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION boost::random_access_iterator_test(boost::make_reverse_iterator(reversed + N), N, array); #endif @@ -319,12 +309,11 @@ main() boost::random_access_iterator_test(j, N, array); const dummyT* const_reversed = reversed; - typedef boost::iterator ConstReverseTraits; - boost::random_access_iterator_test(boost::make_reverse_iterator(const_reversed + N), N, array); -#ifndef BOOST_NO_STD_ITERATOR_TRAITS + +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION boost::random_access_iterator_test(boost::make_reverse_iterator(const_reversed + N), N, array); #endif - + boost::const_nonconst_iterator_test(i, ++j); } @@ -335,23 +324,25 @@ main() std::copy(array, array + N, std::back_inserter(reversed_container)); const std::deque::iterator reversed = reversed_container.begin(); std::reverse(reversed, reversed + N); - + typedef boost::reverse_iterator_generator< std::deque::iterator>::type reverse_iterator; typedef boost::reverse_iterator_generator< - std::deque::const_iterator>::type const_reverse_iterator; + std::deque::const_iterator, const dummyT>::type const_reverse_iterator; reverse_iterator i = reversed + N; boost::random_access_iterator_test(i, N, array); boost::random_access_iterator_test(boost::make_reverse_iterator(reversed + N), N, array); - const_reverse_iterator j = reversed + N; + const_reverse_iterator j = reverse_iterator(reversed + N); boost::random_access_iterator_test(j, N, array); const std::deque::const_iterator const_reversed = reversed; boost::random_access_iterator_test(boost::make_reverse_iterator(const_reversed + N), N, array); - - boost::const_nonconst_iterator_test(i, ++j); + +#if !defined(__GNUC__) || defined(__SGI_STL_PORT) // GCC deque iterators don't allow all const/non-const comparisons + boost::const_nonconst_iterator_test(i, ++j); +#endif } #endif @@ -379,7 +370,7 @@ main() boost::forward_iterator_test(boost::make_filter_iterator (array, array + N), dummyT(1), dummyT(4)); -#ifndef BOOST_NO_STD_ITERATOR_TRAITS +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION boost::forward_iterator_test(boost::make_filter_iterator( array, array + N, one_or_four()), dummyT(1), dummyT(4));