Connecting Tech Pros Worldwide Help | Site Map

define new iterators

  #1  
Old August 18th, 2005, 09:25 PM
PengYu.UT@gmail.com
Guest
 
Posts: n/a
Hi,

I have to define a composite class. I'm wondering if there are any easy
way to define its corresponding iterator class. Can I inherent the
iterator from some library?

Best wishes,
Peng

  #2  
Old August 19th, 2005, 06:15 AM
Alipha
Guest
 
Posts: n/a

re: define new iterators



PengYu.UT@gmail.com wrote:[color=blue]
> Hi,
>
> I have to define a composite class. I'm wondering if there are any easy
> way to define its corresponding iterator class. Can I inherent the
> iterator from some library?
>
> Best wishes,
> Peng[/color]

you should almost always inherit from std::iterator to have the
appropriate typedefs created for you and so that std::iterator_traits
will work for your class. but no functions are generated for you; you
have to write them yourself. however, boost (www.boost.org) has
iterator adapter and facet (sp?) classes, which (supposably) make it
easier to create iterators (once you understand how to use them).

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Function Objects with Iterators gexarchakos answers 6 February 12th, 2007 02:05 AM
Proposed new PEP: print to expand generators James J. Besemer answers 3 June 5th, 2006 12:15 AM
Iterators on Vector codefixer@gmail.com answers 3 August 24th, 2005 01:15 PM
Problems with iterators ans lists jhonyxxx answers 4 July 22nd, 2005 05:38 PM