This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: WIP: Implement Filesystem TS
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: libstdc++ at gcc dot gnu dot org
- Date: Tue, 5 Aug 2014 09:34:03 +0100
- Subject: Re: WIP: Implement Filesystem TS
- Authentication-results: sourceware.org; auth=none
- References: <20140804135012 dot GQ2361 at redhat dot com> <20140804171148 dot GS2361 at redhat dot com> <alpine dot DEB dot 2 dot 11 dot 1408042023310 dot 18985 at stedding dot saclay dot inria dot fr> <20140804223622 dot GA6927 at redhat dot com>
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 ...