Boost logo

Boost :

Subject: [boost] [filesystem] C++11 range-based for statement and BOOST_FOREACH support
From: Beman Dawes (bdawes_at_[hidden])
Date: 2012-07-12 10:10:38


Support for the C++11 range-based for statement and BOOST_FOREACH for
directory_iterator and recursive_directory_iterator has been added to
trunk. This clears feature requests 5896 and 6521.

The range-based for has been tested against gcc 4.6, which works, and
against VC++2012 RC, which ICEs the compiler. The ICE has been
reported to Microsoft.

If anyone gives either C++11 range-based for or BOOST_FOREACH a try,
I'd appreciate hearing about any problems. Both of these are new to
me, and I'm nervous about getting the enabler free functions right.

Here is what usage looks like:

    for (directory_entry& x : directory_iterator("."))
    {
       std::cout << " " << x.path() << "\n";
    }

    BOOST_FOREACH(directory_entry& x, directory_iterator("."))
    {
       std::cout << " " << x.path() << "\n";
    }

Thanks,

--Beman


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk