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 14:00:52


#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 mlimber@…):

 I guessed that that is what was happening. Thanks for confirming.

 I would suggest that if that is intentionally part of the design, it is
 quite a surprising choice and reflects at least a defect in the
 documentation, if not the design or code.

 Moreover, if this is in fact intended, I do not understand the reasoning
 on why this is a good design choice. ''Prima facie'', I would not expect a
 ''copy'' of an iterator to share state with the original (except that they
 are iterating over the same range). I would expect this function to behave
 the same regardless of whether I used
 {{{boost::filesystem::directory_iterator}}} or
 {{{std::vector::const_iterator}}}:
 {{{
 #!div style="font-size: 80%"
   {{{#!cpp
 template<class Iter>
 void print( const Iter begin, const Iter end )
 {
     std::cout << std::distance( begin, end ) << "\n";
     for( const auto& entry : boost::make_iterator_range( begin, end ) )
     {
       std::cout << entry << "\n";
     }
 }
   }}}
 }}}

 But watch it fail here: coliru.stacked-crooked.com/a/ce85e7adb3c16bdc

 If I remove the call to {{{std::distance()}}}, it works as expected. This,
 I contend, is a defect of some kind.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12578#comment:4>
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