Re: [Boost-bugs] [Boost C++ Libraries] #12578: Crash with boost::filesystem's directory_iterator and recursive_directory_iterator

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #12578: Crash with boost::filesystem's directory_iterator and recursive_directory_iterator
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-11-21 20:40:33


#12578: Crash with boost::filesystem's directory_iterator and
recursive_directory_iterator
-------------------------------+------------------------
  Reporter: anonymous | Owner: bemandawes
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: filesystem
   Version: Boost 1.61.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------+------------------------

Comment (by Charles Olivi <charles.olivi@…>):

 Beware that if you copy iterator the origin is not invalidated, it's just
 that the shared_ptr increases its ref_count.

 test the following code based on your example:
 - define a method that takes a fs::recursive_directory_iterator as
 parameter

   void process_iter(fs::recursive_directory_iterator myIter) {
      std::cout << *(myIter++) << std::endl;
   }

 - and then in main:

   int main(void) {
     fs::path aPath(".");

     fs::recursive_directory_iterator iter(aPath);

     fs::recursive_directory_iterator end;

     process_iter(iter);

     for( const auto& entry : boost::make_iterator_range(iter, end) {
       std::cout << entry;
     }

     return 0;
   }

 expected result is that process_iter call will pop the first element in
 current directory stream,
 successive calls in following loop will pop remaining elements, starting
 from the second one.
 in the end iter points to end().

 Hope this clarifies

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12578#comment:8>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:20 UTC