Boost logo

Boost Users :

Subject: [Boost-users] [boost][filesystem] re-assign a recursive_directory_iterator
From: Sascha Ochsenknecht (s.ochsenknecht_at_[hidden])
Date: 2009-10-13 16:39:31


Hi,

should it be possible to re-assign a
filesystem::recursive_directory_iterator? I tried something like the
following (could strip out my code and build a small test case if needed
but this would take some time):

fs::path aPath = ...; // assign to some valid path

const fs::recursive_directory_iterator initial(path);
const fs::recursive_directory_iterator end();
fs::recursive_directory_iterator current(path);

// now increment current and do something with it (traverse directories
etc).
// ...

// Later I want to go back to initial position with:
current = initial;
// but this causes a crash later when traversing again, seems that the
(current == end) check gives wrong results and I dereference invalid current

// I tried also the following:
current = fs::recursive_directory_iterator(path);
// this doesn't crash but (current == end) seems to give also wrong results

I don't want to create 'current' as a temporary, so constructing a new
'current' when needed. In my case it is a class member. Anyhow, I can
implement a workaround for me.

Is it a bug or is it not wanted to re-assign the iterator?
If it is not wanted to re-assign, maybe the assignment operator should
be disabled?

Thanks in advance,
Sascha


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net