Subject: Re: [boost] [filesystem] C++11 range-based for statement and BOOST_FOREACH support
From: Nathan Ridge (zeratul976_at_[hidden])
Date: 2012-07-14 12:25:46
> > Hm.
> > Why not follow this design:
> > http://www.boost.org/doc/libs/1_50_0/libs/range/doc/html/range/reference/ranges/istream_range.html
> The implementation would be more elegant, but the user would have to write:
> BOOST_FOREACH(directory_entry& x, directory_range(directory_iterator(".")))
> instead of the simpler:
> BOOST_FOREACH(directory_entry& x, directory_iterator("."))
> I verified the above with an actual implementation and test.
I don't see why that's the case. In the posted link, the function istream_range()
takes an argument of type istream&, which is the same argument type that the
constructor of istream_iterator takes. Notice that istream_range() does *not*
take an actual istream_iterator as its constructor argument.
Similarly, I would expect directory_range() to take a path argument, and return
something like make_iterator_range(directory_iterator(p), directory_iterator()).