Boost C++ Libraries: Ticket #11228: Unable to compile a filtered recursive_directory_iterator range. https://svn.boost.org/trac10/ticket/11228 <p> From <a class="ext-link" href="http://stackoverflow.com/q/29823931/264476"><span class="icon">​</span>http://stackoverflow.com/q/29823931/264476</a>. </p> <p> The following code fails to compile with 1.58.0 while it was compiling with 1.55. </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;boost/filesystem.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/range.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/range/algorithm.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/range/adaptors.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;vector&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;iostream&gt;</span><span class="cp"></span> <span class="k">namespace</span> <span class="n">fs</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">filesystem</span><span class="p">;</span> <span class="k">using</span> <span class="k">namespace</span> <span class="n">boost</span><span class="o">::</span><span class="n">adaptors</span><span class="p">;</span> <span class="kt">int</span> <span class="nf">main</span><span class="p">()</span> <span class="p">{</span> <span class="n">fs</span><span class="o">::</span><span class="n">recursive_directory_iterator</span> <span class="n">beg</span><span class="p">(</span><span class="s">&quot;.&quot;</span><span class="p">),</span> <span class="n">end</span><span class="p">;</span> <span class="k">auto</span> <span class="n">fileFilter</span> <span class="o">=</span> <span class="p">[](</span><span class="n">fs</span><span class="o">::</span><span class="n">path</span> <span class="k">const</span> <span class="o">&amp;</span> <span class="n">path</span><span class="p">)</span> <span class="p">{</span> <span class="k">return</span> <span class="n">is_regular_file</span><span class="p">(</span><span class="n">path</span><span class="p">);</span> <span class="p">};</span> <span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="n">fs</span><span class="o">::</span><span class="n">path</span><span class="o">&gt;</span> <span class="n">paths</span><span class="p">;</span> <span class="n">copy</span><span class="p">(</span><span class="n">boost</span><span class="o">::</span><span class="n">make_iterator_range</span><span class="p">(</span><span class="n">beg</span><span class="p">,</span> <span class="n">end</span><span class="p">)</span> <span class="o">|</span> <span class="n">filtered</span><span class="p">(</span><span class="n">fileFilter</span><span class="p">),</span> <span class="n">std</span><span class="o">::</span><span class="n">back_inserter</span><span class="p">(</span><span class="n">paths</span><span class="p">));</span> <span class="k">for</span><span class="p">(</span><span class="k">auto</span><span class="o">&amp;</span> <span class="nl">p</span> <span class="p">:</span> <span class="n">paths</span><span class="p">)</span> <span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="n">p</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">;</span> <span class="p">}</span> </pre></div></div><p> With the following error: </p> <pre class="wiki">In file included from /usr/local/include/boost/range/concepts.hpp:19:0, from /usr/local/include/boost/range/size_type.hpp:20, from /usr/local/include/boost/range/size.hpp:21, from /usr/local/include/boost/range/functions.hpp:20, from /usr/local/include/boost/range.hpp:18, from main.cpp:5: /usr/local/include/boost/concept_check.hpp: In instantiation of 'boost::Convertible&lt;X, Y&gt;::~Convertible() [with X = boost::iterators::single_pass_traversal_tag; Y = boost::iterators::forward_traversal_tag]': /usr/local/include/boost/concept/detail/general.hpp:38:28: required from 'static void boost::concepts::requirement&lt;boost::concepts::failed************ Model::************&gt;::failed() [with Model = boost::Convertible&lt;boost::iterators::single_pass_traversal_tag, boost::iterators::forward_traversal_tag&gt;]' /usr/local/include/boost/range/concepts.hpp:189:13: required from 'struct boost::range_detail::ForwardIteratorConcept&lt;boost::filesystem::recursive_directory_iterator&gt;' /usr/local/include/boost/concept/detail/has_constraints.hpp:32:62: required by substitution of 'template&lt;class Model&gt; boost::concepts::detail::yes boost::concepts::detail::has_constraints_(Model*, boost::concepts::detail::wrap_constraints&lt;Model, (&amp; Model:: constraints)&gt;*) [with Model = boost::range_detail::ForwardIteratorConcept&lt;boost::filesystem::recursive_directory_iterator&gt;]' /usr/local/include/boost/concept/detail/has_constraints.hpp:42:5: required from 'const bool boost::concepts::not_satisfied&lt;boost::range_detail::ForwardIteratorConcept&lt;boost::filesystem::recursive_directory_iterator&gt; &gt;::value' /usr/local/include/boost/concept/detail/has_constraints.hpp:45:31: required from 'struct boost::concepts::not_satisfied&lt;boost::range_detail::ForwardIteratorConcept&lt;boost::filesystem::recursive_directory_iterator&gt; &gt;' /usr/local/include/boost/mpl/if.hpp:67:11: [ skipping 4 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ] /usr/local/include/boost/concept/detail/has_constraints.hpp:42:5: required from 'const bool boost::concepts::not_satisfied&lt;boost::ForwardRangeConcept&lt;const boost::iterator_range&lt;boost::filesystem::recursive_directory_iterator&gt; &gt; &gt;::value' /usr/local/include/boost/concept/detail/has_constraints.hpp:45:31: required from 'struct boost::concepts::not_satisfied&lt;boost::ForwardRangeConcept&lt;const boost::iterator_range&lt;boost::filesystem::recursive_directory_iterator&gt; &gt; &gt;' /usr/local/include/boost/mpl/if.hpp:67:11: required from 'struct boost::mpl::if_&lt;boost::concepts::not_satisfied&lt;boost::ForwardRangeConcept&lt;const boost::iterator_range&lt;boost::filesystem::recursive_directory_iterator&gt; &gt; &gt;, boost::concepts::constraint&lt;boost::ForwardRangeConcept&lt;const boost::iterator_range&lt;boost::filesystem::recursive_directory_iterator&gt; &gt; &gt;, boost::concepts::requirement&lt;boost::concepts::failed************ boost::ForwardRangeConcept&lt;const boost::iterator_range&lt;boost::filesystem::recursive_directory_iterator&gt; &gt;::************&gt; &gt;' /usr/local/include/boost/concept/detail/general.hpp:50:8: required from 'struct boost::concepts::requirement_&lt;void (*)(boost::ForwardRangeConcept&lt;const boost::iterator_range&lt;boost::filesystem::recursive_directory_iterator&gt; &gt;)&gt;' /usr/local/include/boost/range/algorithm/find_end.hpp:50:5: required from 'boost::range_detail::filtered_range&lt;Predicate, const ForwardRange&gt; boost::range_detail::operator|(const ForwardRange&amp;, const boost::range_detail::filter_holder&lt;Predicate&gt;&amp;) [with ForwardRange = boost::iterator_range&lt;boost::filesystem::recursive_directory_iterator&gt;; Predicate = main()::&lt;lambda(const boost::filesystem::path&amp;)&gt;]' main.cpp:20:68: required from here /usr/local/include/boost/concept_check.hpp:210:13: error: conversion from 'boost::iterators::single_pass_traversal_tag' to non-scalar type 'boost::iterators::forward_traversal_tag' requested Y y = x; ^ In file included from /usr/local/include/boost/range/size_type.hpp:20:0, from /usr/local/include/boost/range/size.hpp:21, from /usr/local/include/boost/range/functions.hpp:20, from /usr/local/include/boost/range.hpp:18, from main.cpp:5: /usr/local/include/boost/range/concepts.hpp: In instantiation of 'boost::range_detail::ForwardIteratorConcept&lt;Iterator&gt;::~ForwardIteratorConcept() [with Iterator = boost::filesystem::recursive_directory_iterator]': /usr/local/include/boost/concept/detail/general.hpp:38:28: required from 'static void boost::concepts::requirement&lt;boost::concepts::failed************ Model::************&gt;::failed() [with Model = boost::range_detail::ForwardIteratorConcept&lt;boost::filesystem::recursive_directory_iterator&gt;]' /usr/local/include/boost/range/concepts.hpp:319:9: required from 'struct boost::ForwardRangeConcept&lt;const boost::iterator_range&lt;boost::filesystem::recursive_directory_iterator&gt; &gt;' /usr/local/include/boost/concept/detail/has_constraints.hpp:32:62: required by substitution of 'template&lt;class Model&gt; boost::concepts::detail::yes boost::concepts::detail::has_constraints_(Model*, boost::concepts::detail::wrap_constraints&lt;Model, (&amp; Model:: constraints)&gt;*) [with Model = boost::ForwardRangeConcept&lt;const boost::iterator_range&lt;boost::filesystem::recursive_directory_iterator&gt; &gt;]' /usr/local/include/boost/concept/detail/has_constraints.hpp:42:5: required from 'const bool boost::concepts::not_satisfied&lt;boost::ForwardRangeConcept&lt;const boost::iterator_range&lt;boost::filesystem::recursive_directory_iterator&gt; &gt; &gt;::value' /usr/local/include/boost/concept/detail/has_constraints.hpp:45:31: required from 'struct boost::concepts::not_satisfied&lt;boost::ForwardRangeConcept&lt;const boost::iterator_range&lt;boost::filesystem::recursive_directory_iterator&gt; &gt; &gt;' /usr/local/include/boost/mpl/if.hpp:67:11: required from 'struct boost::mpl::if_&lt;boost::concepts::not_satisfied&lt;boost::ForwardRangeConcept&lt;const boost::iterator_range&lt;boost::filesystem::recursive_directory_iterator&gt; &gt; &gt;, boost::concepts::constraint&lt;boost::ForwardRangeConcept&lt;const boost::iterator_range&lt;boost::filesystem::recursive_directory_iterator&gt; &gt; &gt;, boost::concepts::requirement&lt;boost::concepts::failed************ boost::ForwardRangeConcept&lt;const boost::iterator_range&lt;boost::filesystem::recursive_directory_iterator&gt; &gt;::************&gt; &gt;' /usr/local/include/boost/concept/detail/general.hpp:50:8: required from 'struct boost::concepts::requirement_&lt;void (*)(boost::ForwardRangeConcept&lt;const boost::iterator_range&lt;boost::filesystem::recursive_directory_iterator&gt; &gt;)&gt;' /usr/local/include/boost/range/algorithm/find_end.hpp:50:5: required from 'boost::range_detail::filtered_range&lt;Predicate, const ForwardRange&gt; boost::range_detail::operator|(const ForwardRange&amp;, const boost::range_detail::filter_holder&lt;Predicate&gt;&amp;) [with ForwardRange = boost::iterator_range&lt;boost::filesystem::recursive_directory_iterator&gt;; Predicate = main()::&lt;lambda(const boost::filesystem::path&amp;)&gt;]' main.cpp:20:68: required from here /usr/local/include/boost/range/concepts.hpp:201:32: error: no matching function for call to 'boost::filesystem::recursive_directory_iterator::recursive_directory_iterator(boost::mpl::eval_if&lt;boost::mpl::and_&lt;boost::is_convertible&lt;boost::filesystem::directory_entry&amp;, const boost::filesystem::directory_entry&amp;&gt;, boost::mpl::not_&lt;boost::is_convertible&lt;boost::iterators::single_pass_traversal_tag, boost::iterators::forward_traversal_tag&gt; &gt;, mpl_::bool_&lt;true&gt;, mpl_::bool_&lt;true&gt;, mpl_::bool_&lt;true&gt; &gt;, boost::mpl::if_&lt;boost::iterators::detail::is_non_proxy_reference&lt;boost::filesystem::directory_entry&amp;, boost::filesystem::directory_entry&gt;, boost::iterators::detail::postfix_increment_proxy&lt;boost::filesystem::recursive_directory_iterator&gt;, boost::iterators::detail::writable_postfix_increment_proxy&lt;boost::filesystem::recursive_directory_iterator&gt; &gt;, boost::mpl::identity&lt;boost::filesystem::recursive_directory_iterator&gt; &gt;::type)' Iterator i2(i++); ^ /usr/local/include/boost/range/concepts.hpp:201:32: note: candidates are: In file included from /usr/local/include/boost/filesystem.hpp:17:0, from main.cpp:4: /usr/local/include/boost/filesystem/operations.hpp:1066:5: note: boost::filesystem::recursive_directory_iterator::recursive_directory_iterator(const boost::filesystem::path&amp;, boost::system::error_code&amp;) recursive_directory_iterator(const path&amp; dir_path, ^ /usr/local/include/boost/filesystem/operations.hpp:1066:5: note: candidate expects 2 arguments, 1 provided /usr/local/include/boost/filesystem/operations.hpp:1055:5: note: boost::filesystem::recursive_directory_iterator::recursive_directory_iterator(const boost::filesystem::path&amp;, boost::filesystem::symlink_option, boost::system::error_code&amp;) recursive_directory_iterator(const path&amp; dir_path, ^ /usr/local/include/boost/filesystem/operations.hpp:1055:5: note: candidate expects 3 arguments, 1 provided /usr/local/include/boost/filesystem/operations.hpp:1045:14: note: boost::filesystem::recursive_directory_iterator::recursive_directory_iterator(const boost::filesystem::path&amp;, boost::filesystem::symlink_option) explicit recursive_directory_iterator(const path&amp; dir_path, ^ /usr/local/include/boost/filesystem/operations.hpp:1045:14: note: no known conversion for argument 1 from 'boost::mpl::eval_if&lt;boost::mpl::and_&lt;boost::is_convertible&lt;boost::filesystem::directory_entry&amp;, const boost::filesystem::directory_entry&amp;&gt;, boost::mpl::not_&lt;boost::is_convertible&lt;boost::iterators::single_pass_traversal_tag, boost::iterators::forward_traversal_tag&gt; &gt;, mpl_::bool_&lt;true&gt;, mpl_::bool_&lt;true&gt;, mpl_::bool_&lt;true&gt; &gt;, boost::mpl::if_&lt;boost::iterators::detail::is_non_proxy_reference&lt;boost::filesystem::directory_entry&amp;, boost::filesystem::directory_entry&gt;, boost::iterators::detail::postfix_increment_proxy&lt;boost::filesystem::recursive_directory_iterator&gt;, boost::iterators::detail::writable_postfix_increment_proxy&lt;boost::filesystem::recursive_directory_iterator&gt; &gt;, boost::mpl::identity&lt;boost::filesystem::recursive_directory_iterator&gt; &gt;::type {aka boost::iterators::detail::postfix_increment_proxy&lt;boost::filesystem::recursive_directory_iterator&gt;}' to 'const boost::filesystem::path&amp;' /usr/local/include/boost/filesystem/operations.hpp:1043:5: note: boost::filesystem::recursive_directory_iterator::recursive_directory_iterator() recursive_directory_iterator(){} // creates the "end" iterator ^ /usr/local/include/boost/filesystem/operations.hpp:1043:5: note: candidate expects 0 arguments, 1 provided /usr/local/include/boost/filesystem/operations.hpp:1035:9: note: boost::filesystem::recursive_directory_iterator::recursive_directory_iterator(const boost::filesystem::recursive_directory_iterator&amp;) class recursive_directory_iterator ^ /usr/local/include/boost/filesystem/operations.hpp:1035:9: note: no known conversion for argument 1 from 'boost::mpl::eval_if&lt;boost::mpl::and_&lt;boost::is_convertible&lt;boost::filesystem::directory_entry&amp;, const boost::filesystem::directory_entry&amp;&gt;, boost::mpl::not_&lt;boost::is_convertible&lt;boost::iterators::single_pass_traversal_tag, boost::iterators::forward_traversal_tag&gt; &gt;, mpl_::bool_&lt;true&gt;, mpl_::bool_&lt;true&gt;, mpl_::bool_&lt;true&gt; &gt;, boost::mpl::if_&lt;boost::iterators::detail::is_non_proxy_reference&lt;boost::filesystem::directory_entry&amp;, boost::filesystem::directory_entry&gt;, boost::iterators::detail::postfix_increment_proxy&lt;boost::filesystem::recursive_directory_iterator&gt;, boost::iterators::detail::writable_postfix_increment_proxy&lt;boost::filesystem::recursive_directory_iterator&gt; &gt;, boost::mpl::identity&lt;boost::filesystem::recursive_directory_iterator&gt; &gt;::type {aka boost::iterators::detail::postfix_increment_proxy&lt;boost::filesystem::recursive_directory_iterator&gt;}' to 'const boost::filesystem::recursive_directory_iterator&amp;' /usr/local/include/boost/filesystem/operations.hpp:1035:9: note: boost::filesystem::recursive_directory_iterator::recursive_directory_iterator(boost::filesystem::recursive_directory_iterator&amp;&amp;) /usr/local/include/boost/filesystem/operations.hpp:1035:9: note: no known conversion for argument 1 from 'boost::mpl::eval_if&lt;boost::mpl::and_&lt;boost::is_convertible&lt;boost::filesystem::directory_entry&amp;, const boost::filesystem::directory_entry&amp;&gt;, boost::mpl::not_&lt;boost::is_convertible&lt;boost::iterators::single_pass_traversal_tag, boost::iterators::forward_traversal_tag&gt; &gt;, mpl_::bool_&lt;true&gt;, mpl_::bool_&lt;true&gt;, mpl_::bool_&lt;true&gt; &gt;, boost::mpl::if_&lt;boost::iterators::detail::is_non_proxy_reference&lt;boost::filesystem::directory_entry&amp;, boost::filesystem::directory_entry&gt;, boost::iterators::detail::postfix_increment_proxy&lt;boost::filesystem::recursive_directory_iterator&gt;, boost::iterators::detail::writable_postfix_increment_proxy&lt;boost::filesystem::recursive_directory_iterator&gt; &gt;, boost::mpl::identity&lt;boost::filesystem::recursive_directory_iterator&gt; &gt;::type {aka boost::iterators::detail::postfix_increment_proxy&lt;boost::filesystem::recursive_directory_iterator&gt;}' to 'boost::filesystem::recursive_directory_iterator&amp;&amp;' </pre><p> Setting <code>BOOST_RANGE_ENABLE_CONCEPT_ASSERT 0</code> allows to compile. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11228 Trac 1.4.3 Beman Dawes Mon, 31 Aug 2015 00:41:20 GMT status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/11228#comment:1 https://svn.boost.org/trac10/ticket/11228#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.59.0</span> </li> </ul> <p> This seems to be working now, at least with VC++2015. Presumably that is because of the fix to Boost.Range for <a class="ext-link" href="https://svn.boost.org/trac/boost/ticket/10989"><span class="icon">​</span>https://svn.boost.org/trac/boost/ticket/10989</a> </p> <p> It really does not look like a filesystem problem to me, so I've closed it as fixed. </p> <p> Thanks, </p> <p> --Beman </p> Ticket