This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: WIP: Implement Filesystem TS


On 04/08/14 23:36 +0100, Jonathan Wakely wrote:
One solution would be for recursive_directory_iterator to not use
directory_iterator, but work with a stack of unique_ptr<_Dir> objects
instead, re-implementing the required directory_iterator members that
operate on the _Dir object. I didn't try that, but I think it would
work.

Or it could just use std::stack<_Dir> ... but I think I did try that
and hit some issues. Maybe I should try again because ...

My recursive_directory_iterator implementation instead uses
shared_ptr<stack<pair<_Dir, directory_iterator>>>, where the
shared_ptr<_Dir> held by each directory_iterator shares ownership with
the shared_ptr<stack<...>> (using the shared_ptr aliasing constructor)
so there is only a single control block for the whole group of
objects.

I've realised there's a problem with this code, I'm not correctly
breaking the reference cycles when a recursive_directory_iterator is
destroyed with depth() != 0, so leaking memory. I'll fix that ...


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]