try a new interface

[SVN r9063]
This commit is contained in:
Dave Abrahams
2001-02-09 21:06:47 +00:00
parent e96b00cb56
commit f00e99be29

View File

@ -33,6 +33,7 @@
#include <algorithm> #include <algorithm>
#include <functional> #include <functional>
#include <boost/iterator_adaptors.hpp> #include <boost/iterator_adaptors.hpp>
#include <boost/pending/iterator_tests.hpp> #include <boost/pending/iterator_tests.hpp>
#include <boost/pending/integer_range.hpp> #include <boost/pending/integer_range.hpp>
@ -43,7 +44,6 @@
struct my_iterator_tag : public std::random_access_iterator_tag { }; struct my_iterator_tag : public std::random_access_iterator_tag { };
using boost::dummyT; using boost::dummyT;
struct my_iter_traits { struct my_iter_traits {
@ -68,6 +68,7 @@ typedef boost::iterator_adaptor<dummyT*,
typedef boost::iterator_adaptor<const dummyT*, typedef boost::iterator_adaptor<const dummyT*,
boost::default_iterator_policies, my_const_iter_traits> const_my_iterator; boost::default_iterator_policies, my_const_iter_traits> const_my_iterator;
struct mult_functor { struct mult_functor {
typedef int result_type; typedef int result_type;
typedef int argument_type; typedef int argument_type;
@ -99,7 +100,7 @@ struct one_or_four {
} }
}; };
typedef std::vector<int> storage; typedef std::deque<int> storage;
typedef std::deque<int*> pointer_deque; typedef std::deque<int*> pointer_deque;
typedef std::set<storage::iterator> iterator_set; typedef std::set<storage::iterator> iterator_set;
@ -120,11 +121,9 @@ void more_indirect_iterator_tests()
} }
typedef boost::indirect_iterator_pair_generator< typedef boost::indirect_iterator_pair_generator<
pointer_deque::iterator, pointer_deque::iterator
const int* #ifndef BOOST_NO_STD_ITERATOR_TRAITS
#ifdef BOOST_NO_STD_ITERATOR_TRAITS , int, int*, int&, const int*, const int&
, boost::iterator<std::random_access_iterator_tag,int,std::ptrdiff_t,const int*,const int&>
, boost::iterator<std::random_access_iterator_tag,int>
#endif #endif
> IndirectDeque; > IndirectDeque;
@ -150,16 +149,11 @@ void more_indirect_iterator_tests()
typedef boost::indirect_iterator_generator< typedef boost::indirect_iterator_generator<
iterator_set::iterator iterator_set::iterator
# ifdef BOOST_NO_STD_ITERATOR_TRAITS
, boost::iterator<std::random_access_iterator_tag,int>
# endif
>::type indirect_set_iterator; >::type indirect_set_iterator;
typedef boost::indirect_iterator_generator< typedef boost::indirect_iterator_generator<
iterator_set::iterator iterator_set::iterator,
# ifdef BOOST_NO_STD_ITERATOR_TRAITS const int
, boost::iterator<std::random_access_iterator_tag,int,std::ptrdiff_t,const int*,const int&>
# endif
>::type const_indirect_set_iterator; >::type const_indirect_set_iterator;
indirect_set_iterator sb(iter_set.begin()); indirect_set_iterator sb(iter_set.begin());
@ -228,44 +222,40 @@ main()
dummyT* ptr[N]; dummyT* ptr[N];
for (int k = 0; k < N; ++k) for (int k = 0; k < N; ++k)
ptr[k] = array + k; ptr[k] = array + k;
typedef boost::indirect_iterator_generator<dummyT**
#ifdef BOOST_NO_STD_ITERATOR_TRAITS
, boost::iterator<std::random_access_iterator_tag,dummyT>
#endif
>::type indirect_iterator;
typedef boost::indirect_iterator_generator<dummyT** typedef boost::indirect_iterator_generator<dummyT**
#ifdef BOOST_NO_STD_ITERATOR_TRAITS #ifdef BOOST_NO_STD_ITERATOR_TRAITS
, boost::iterator<std::random_access_iterator_tag,dummyT,std::ptrdiff_t,const dummyT*,const dummyT&> , dummyT
#endif #endif
>::type const_indirect_iterator; >::type indirect_iterator;
typedef boost::indirect_iterator_generator<dummyT**, const dummyT>::type const_indirect_iterator;
indirect_iterator i = ptr; indirect_iterator i = ptr;
boost::random_access_iterator_test(i, N, array); boost::random_access_iterator_test(i, N, array);
typedef boost::iterator<std::random_access_iterator_tag, dummyT> InnerTraits; typedef boost::iterator<std::random_access_iterator_tag, dummyT> InnerTraits;
boost::random_access_iterator_test(boost::make_indirect_iterator(ptr, InnerTraits()), N, array);
// boost::random_access_iterator_test(boost::make_indirect_iterator(ptr, InnerTraits()), N, array);
#ifndef BOOST_NO_STD_ITERATOR_TRAITS #ifndef BOOST_NO_STD_ITERATOR_TRAITS
boost::random_access_iterator_test(boost::make_indirect_iterator(ptr), N, array); // boost::random_access_iterator_test(boost::make_indirect_iterator(ptr), N, array);
#endif #endif
const_indirect_iterator j = ptr; const_indirect_iterator j = ptr;
boost::random_access_iterator_test(j, N, array); boost::random_access_iterator_test(j, N, array);
dummyT*const* const_ptr = ptr; dummyT*const* const_ptr = ptr;
typedef boost::iterator<std::random_access_iterator_tag,dummyT,std::ptrdiff_t,const dummyT*,const dummyT&> ConstInnerTraits; typedef boost::iterator<std::random_access_iterator_tag,dummyT,std::ptrdiff_t,const dummyT*,const dummyT&> ConstInnerTraits;
// boost::random_access_iterator_test(boost::make_indirect_iterator(const_ptr, ConstInnerTraits()), N, array);
boost::random_access_iterator_test(boost::make_indirect_iterator(const_ptr, ConstInnerTraits()), N, array);
#ifndef BOOST_NO_STD_ITERATOR_TRAITS #ifndef BOOST_NO_STD_ITERATOR_TRAITS
boost::random_access_iterator_test(boost::make_indirect_iterator(const_ptr), N, array); // boost::random_access_iterator_test(boost::make_indirect_iterator(const_ptr), N, array);
#endif #endif
boost::const_nonconst_iterator_test(i, ++j); boost::const_nonconst_iterator_test(i, ++j);
more_indirect_iterator_tests(); more_indirect_iterator_tests();
} }
@ -345,13 +335,15 @@ main()
boost::random_access_iterator_test(i, N, array); boost::random_access_iterator_test(i, N, array);
boost::random_access_iterator_test(boost::make_reverse_iterator(reversed + N), 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); boost::random_access_iterator_test(j, N, array);
const std::deque<dummyT>::const_iterator const_reversed = reversed; const std::deque<dummyT>::const_iterator const_reversed = reversed;
boost::random_access_iterator_test(boost::make_reverse_iterator(const_reversed + N), N, array); 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 #endif