Looks great! BTW, I think this example will be really useful to people who
are trying to use old C data-structures inside of new C++ code.
It would be great to have a slist implementation in boost...
On Fri, 26 Jul 2002, David Abrahams wrote:
dave> OK, here's my (untested) singly-linked-list iterator:
dave>
dave> typedef std::string slist_data;
dave> struct slist_node
dave> {
dave> slist_node* next;
dave> slist_data data;
dave> };
dave>
dave> struct slist_policies : default_iterator_policies
dave> {
dave> template <class IteratorAdaptor>
dave> void increment(IteratorAdaptor& x) {
dave> x.base() = x.base()->next;
dave> }
dave>
dave> template <class IteratorAdaptor>
dave> typename IteratorAdaptor::reference dereference(IteratorAdaptor& x) {
dave> return x.base()->data;
dave> }
dave>
dave> // initialize, equal covered by default policies
dave> };
dave>
dave> typedef iterator_adaptor category_isstd::forward_iterator_tag > slist_iterator;
dave>
dave> typedef iterator_adaptor const, category_isstd::forward_iterator_tag > slist_const_iterator;
dave>
dave>
dave> -Dave
dave>
dave>
dave> -----------------------------------------------------------
dave> David Abrahams * Boost Consulting
dave> dave@boost-consulting.com * http://www.boost-consulting.com
dave>
dave>
dave> ----- Original Message -----
dave> From: "Jeremy Siek"
dave> To:
dave> Cc:
dave> Sent: Friday, July 26, 2002 10:58 AM
dave> Subject: Re: [Boost-Users] Re: [boost] Iterator Adaptor Poll
dave>
dave>
dave> > On Fri, 26 Jul 2002, David Abrahams wrote:
dave> > dave>
dave> > dave> Don't you think people will find an iterator which traverses the
dave> > dave> elements of a real sequence to be more-obvious? That's why I'm
dave> > dave> suggesting the singly-linked list iterator.
dave> >
dave> > The singly-linked list example was the second thing that popped into my
dave> > mind... I like that a lot too. Perhaps we should do both :)
dave> >
dave> > Cheers,
dave> > Jeremy
dave> >
dave> >
dave> > ----------------------------------------------------------------------
dave> > Jeremy Siek http://php.indiana.edu/~jsiek/
dave> > Ph.D. Student, Indiana Univ. B'ton email: jsiek@osl.iu.edu
dave> > C++ Booster (http://www.boost.org) office phone: (812) 855-3608
dave> > ----------------------------------------------------------------------
dave> >
dave> >
dave> > _______________________________________________
dave> > Unsubscribe & other changes:
dave> http://lists.boost.org/mailman/listinfo.cgi/boost
dave>
dave>
dave>
dave> Info: http://www.boost.org
dave> Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl
dave> Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com
dave>
dave>
dave> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
dave>
dave>
----------------------------------------------------------------------
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
----------------------------------------------------------------------