How to make a copy of boost :: filesystem :: directory_iterator?

I know this sounds silly, but look at this simple example (the working directory should have more than one item):

#define BOOST_FILESYSTEM_VERSION 3
#include <boost/filesystem.hpp>
#include <cassert>

int main()
{
    using namespace boost::filesystem;
    directory_iterator it("./");
    directory_iterator it_copy = it;
    ++it;
    assert(it_copy != it);
    return 0;
}

it_copychanging along with it! (boost 1.45) What considerations might lead to such a design ( directory_iterator- is this something like smart ptr)?

I just need to save a copy directory_iteratorto use it later.

+5
source share
1 answer

If you look at reference , you will notice that it is advertised as boost::single_pass_traversal_tag.

( ) Input Iterator STL (, , , ).

( ):

i == j , ++i == ++j.

, . , STL , . STL, .

+6

All Articles