
On Thu, Apr 19, 2012 at 9:57 AM, Beman Dawes <bdawes@acm.org> 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