
OK, here's my (untested) singly-linked-list iterator: typedef std::string slist_data; struct slist_node { slist_node* next; slist_data data; }; struct slist_policies : default_iterator_policies { template <class IteratorAdaptor> void increment(IteratorAdaptor& x) { x.base() = x.base()->next; } template <class IteratorAdaptor> typename IteratorAdaptor::reference dereference(IteratorAdaptor& x) { return x.base()->data; } // initialize, equal covered by default policies }; typedef iterator_adaptor<slist_node*, slist_policies, slist_data, category_is<std::forward_iterator_tag> > slist_iterator; typedef iterator_adaptor<slist_node const*, slist_policies, slist_data const, category_is<std::forward_iterator_tag> > slist_const_iterator; -Dave ----------------------------------------------------------- David Abrahams * Boost Consulting dave@boost-consulting.com * http://www.boost-consulting.com ----- Original Message ----- From: "Jeremy Siek" <jsiek@osl.iu.edu> To: <Boost-Users@yahoogroups.com> Cc: <boost@lists.boost.org> Sent: Friday, July 26, 2002 10:58 AM Subject: Re: [Boost-Users] Re: [boost] Iterator Adaptor Poll
On Fri, 26 Jul 2002, David Abrahams wrote: dave> dave> Don't you think people will find an iterator which traverses the dave> elements of a real sequence to be more-obvious? That's why I'm dave> suggesting the singly-linked list iterator.
The singly-linked list example was the second thing that popped into my mind... I like that a lot too. Perhaps we should do both :)
Cheers, Jeremy
---------------------------------------------------------------------- Jeremy Siek http://php.indiana.edu/~jsiek/ Ph.D. Student, Indiana Univ. B'ton email: jsiek@osl.iu.edu C++ Booster (http://www.boost.org) office phone: (812) 855-3608 ----------------------------------------------------------------------
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost