|
Boost : |
Subject: Re: [boost] [filesystem] #6521 Directory listing using C++11 range-based for loops
From: Beman Dawes (bdawes_at_[hidden])
Date: 2012-04-19 11:29:27
On Thu, Apr 19, 2012 at 9:57 AM, Beman Dawes <bdawes_at_[hidden]> wrote:
> Ticket #6521 requests adding:
>
> class directory{
> path p_;
> public:
> inline directory(path p):p_(p){}
> directory_iterator begin(){
> return directory_iterator(p_);
> }
> directory_iterator end(){
> return directory_iterator();
> }
> };
>
> so that that a range-based for loop can be used:
>
> for (auto itr : directory("."))
> {
> cout << itr.path() << endl;
> }
>
> The above works as expected on GCC 4.6 and VC++ 11 beta.
>
> Is that the best way for filesystem directory iteration to support
> range-based for?
Ticket #5896, Range directory iterators, suggests basing a solution on
boost::iterator_range<bfs::directory_iterator>, and that's an obvious
alternative to explore.
--Beman
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk