|
Boost Users : |
From: Daniel Krügler (dsp_at_[hidden])
Date: 2008-04-14 04:07:04
Brad wrote:
> Hi guys and gals,
>
> I'm new to boost and this is my first attempt to use bind (big step LOL).
>
> I'm trying to do this:
>
> bfs::path p( "." );
> bfs::directory_iterator dir_iter( p );
> for_each( dir_iter.begin(), dir_iter.end(), boost::bind(
> &purgeOlder, _1 ) )
>
> but I get:
>
> purgefiles.cpp:53: error: 'class boost::filesystem::directory_iterator'
> has no member named 'begin'
> purgefiles.cpp:53: error: 'class boost::filesystem::directory_iterator'
> has no member named 'end'
>
> It would appear directory_iterator does not have these members which are
> common on the other containers, am I missing something? Is there a way
> to do this using bind?
This has nothing to do with bind. As you say, begin()/end() would
be available for a *container*, but - as the name says -
directory_iterator is just an iterator, not a container. If you follow
the documentation, you will find out, that the default constructed
directory_iterator corresponds to "end" and that there exists one
further c'tor that accepts a path - this is the one you should use
in replacement for begin.
For a better understanding of the idea behind that you should compare
directory_iterator with existing std iterator adaptors, like the insert
iterators or the stream iterators.
HTH & Greetings from Bremen,
Daniel Krügler
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net