Boost logo

Boost Users :

Subject: [Boost-users] [filesystem] directory_iterator and filter in 1.56.0
From: Braden McDaniel (braden_at_[hidden])
Date: 2014-09-10 15:00:10


This sort of thing worked in Boost 1.55.0:

   #include <boost/filesystem.hpp>
   #include <boost/range.hpp>
   #include <boost/range/adaptor/filtered.hpp>

   struct pred
   {
     bool operator()(const boost::filesystem::directory_entry & dirent)
const
     {
       return true;
     }
   };

   int main()
   {
     const auto dirent_range =
       
boost::make_iterator_range(boost::filesystem::directory_iterator("/"),
                                  
boost::filesystem::directory_iterator());
     const auto filtered_dirent_range =
       boost::adaptors::filter(dirent_range, pred());
   }

Not so in 1.56.0 [output from Apple's clang 3.4]:

   boost/concept_check.hpp:210:9: error:
     no viable conversion from 'boost::single_pass_traversal_tag' to
     'boost::forward_traversal_tag'
     Y y = x;
       ^ ~

The full error output is much more verbose and I can provide it if
desired; but the above is the gist of the situation, as I understand it:
directory_iterators are SinglePass iterators; filter operates on
ForwardTraversal iterators; and the SinglePass iterator cannot be
converted to the ForwardTraversal one.

Is this situation deliberate or an unintended side effect? Is there
some similarly succinct means of filtering a file/directory listing?

-- 
Braden McDaniel
<braden_at_[hidden]>

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