Boost logo

Boost :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2002-07-26 10:20:00


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<slist_node*, slist_policies, slist_data,
dave> category_is<std::forward_iterator_tag> > slist_iterator;
dave>
dave> typedef iterator_adaptor<slist_node const*, slist_policies, slist_data
dave> const, category_is<std::forward_iterator_tag> > slist_const_iterator;
dave>
dave>
dave> -Dave
dave>
dave>
dave> -----------------------------------------------------------
dave> David Abrahams * Boost Consulting
dave> dave_at_[hidden] * http://www.boost-consulting.com
dave>
dave>
dave> ----- Original Message -----
dave> From: "Jeremy Siek" <jsiek_at_[hidden]>
dave> To: <Boost-Users_at_[hidden]>
dave> Cc: <boost_at_[hidden]>
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_at_[hidden]
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> ------------------------ Yahoo! Groups Sponsor ---------------------~-->
dave> Will You Find True Love?
dave> Will You Meet the One?
dave> Free Love Reading by phone!
dave> http://us.click.yahoo.com/7dY7FD/R_ZEAA/Ey.GAA/EbFolB/TM
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_at_[hidden]>
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_at_[hidden]
 C++ Booster (http://www.boost.org) office phone: (812) 855-3608
----------------------------------------------------------------------


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk