Boost C++ Libraries: Ticket #11248: Some algorithms with requirement for SinglePassRange accept range only by const reference https://svn.boost.org/trac10/ticket/11248 <p> I came up with it when tried to use generator made by boost.coroutine with boost range algorithms. The following code doesn't compile with MSVC 2012 </p> <pre class="wiki">#include &lt;boost/range/distance.hpp&gt; #include &lt;boost/coroutine/all.hpp&gt; using namespace boost::range; using namespace boost::coroutines; asymmetric_coroutine&lt;int&gt;::pull_type make_dummy_range() { return asymmetric_coroutine&lt;int&gt;::pull_type([](asymmetric_coroutine&lt;int&gt;::push_type&amp; yield) { yield(1); }); } int _tmain(int argc, _TCHAR* argv[]) { boost::distance(make_dummy_range()); // error return 0; } </pre><p> with error </p> <pre class="wiki">D:\Work\3rdparty\boost_1_58_0\boost/concept_check.hpp(181): error C2079: 'boost::CopyConstructible&lt;TT&gt;::b' uses undefined struct 'boost::coroutines::pull_coroutine&lt;R&gt;::const_iterator' 1&gt; with 1&gt; [ 1&gt; TT=boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator 1&gt; ] 1&gt; and 1&gt; [ 1&gt; R=int 1&gt; ] 1&gt; D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(124) : see reference to class template instantiation 'boost::CopyConstructible&lt;TT&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; TT=boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator 1&gt; ] 1&gt; D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(147) : see reference to class template instantiation 'boost::range_detail::IncrementableIteratorConcept&lt;Iterator&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; Iterator=boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator 1&gt; ] 1&gt; D:\Work\3rdparty\boost_1_58_0\boost/concept/detail/msvc.hpp(29) : see reference to class template instantiation 'boost::range_detail::SinglePassIteratorConcept&lt;Iterator&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; Iterator=boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator 1&gt; ] 1&gt; D:\Work\3rdparty\boost_1_58_0\boost/concept/detail/msvc.hpp(28) : while compiling class template member function 'void boost::concepts::check&lt;Model&gt;::failed(Model *)' 1&gt; with 1&gt; [ 1&gt; Model=boost::range_detail::SinglePassIteratorConcept&lt;boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator&gt; 1&gt; ] 1&gt; D:\Work\3rdparty\boost_1_58_0\boost/concept/detail/msvc.hpp(66) : see reference to class template instantiation 'boost::concepts::check&lt;Model&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; Model=boost::range_detail::SinglePassIteratorConcept&lt;boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator&gt; 1&gt; ] 1&gt; D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(279) : see reference to class template instantiation 'boost::concepts::require&lt;Model&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; Model=boost::range_detail::SinglePassIteratorConcept&lt;boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator&gt; 1&gt; ] 1&gt; D:\Work\3rdparty\boost_1_58_0\boost/concept/detail/has_constraints.hpp(42) : see reference to class template instantiation 'boost::SinglePassRangeConcept&lt;T&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; T=boost::coroutines::pull_coroutine&lt;int&gt; 1&gt; ] 1&gt; D:\Work\3rdparty\boost_1_58_0\boost/concept/detail/msvc.hpp(58) : see reference to class template instantiation 'boost::concepts::not_satisfied&lt;Model&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; Model=boost::SinglePassRangeConcept&lt;boost::coroutines::pull_coroutine&lt;int&gt;&gt; 1&gt; ] 1&gt; D:\Work\3rdparty\boost_1_58_0\boost/range/algorithm/for_each.hpp(72) : see reference to class template instantiation 'boost::concepts::require&lt;Model&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; Model=boost::SinglePassRangeConcept&lt;boost::coroutines::pull_coroutine&lt;int&gt;&gt; 1&gt; ] 1&gt; coroutine_bug.cpp(29) : see reference to function template instantiation 'UnaryFunction boost::range::for_each&lt;boost::coroutines::pull_coroutine&lt;R&gt;,wmain::&lt;lambda_d9c6ee6ee85186807f477d3ab241bdd7&gt;&gt;(SinglePassRange &amp;,UnaryFunction)' being compiled 1&gt; with 1&gt; [ 1&gt; UnaryFunction=wmain::&lt;lambda_d9c6ee6ee85186807f477d3ab241bdd7&gt;, 1&gt; R=int, 1&gt; SinglePassRange=boost::coroutines::pull_coroutine&lt;int&gt; 1&gt; ] 1&gt;D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(364): error C2027: use of undefined type 'boost::coroutines::pull_coroutine&lt;R&gt;::const_iterator' 1&gt; with 1&gt; [ 1&gt; R=int 1&gt; ] 1&gt; D:\Work\3rdparty\boost_1_58_0\boost/coroutine/asymmetric_coroutine.hpp(812) : see declaration of 'boost::coroutines::pull_coroutine&lt;R&gt;::const_iterator' 1&gt; with 1&gt; [ 1&gt; R=int 1&gt; ] 1&gt; D:\Work\3rdparty\boost_1_58_0\boost/iterator/iterator_categories.hpp(119) : see reference to class template instantiation 'std::iterator_traits&lt;_Iter&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; _Iter=boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator 1&gt; ] 1&gt; D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(126) : see reference to class template instantiation 'boost::iterators::iterator_traversal&lt;Iterator&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; Iterator=boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator 1&gt; ] 1&gt;D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(364): error C2146: syntax error : missing ';' before identifier 'iterator_category' 1&gt;D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(364): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1&gt;D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(364): error C2602: 'std::iterator_traits&lt;_Iter&gt;::iterator_category' is not a member of a base class of 'std::iterator_traits&lt;_Iter&gt;' 1&gt; with 1&gt; [ 1&gt; _Iter=boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator 1&gt; ] 1&gt; D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(364) : see declaration of 'std::iterator_traits&lt;_Iter&gt;::iterator_category' 1&gt; with 1&gt; [ 1&gt; _Iter=boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator 1&gt; ] 1&gt;D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(364): error C2868: 'std::iterator_traits&lt;_Iter&gt;::iterator_category' : illegal syntax for using-declaration; expected qualified-name 1&gt; with 1&gt; [ 1&gt; _Iter=boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator 1&gt; ] 1&gt;D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(365): error C2027: use of undefined type 'boost::coroutines::pull_coroutine&lt;R&gt;::const_iterator' 1&gt; with 1&gt; [ 1&gt; R=int 1&gt; ] 1&gt; D:\Work\3rdparty\boost_1_58_0\boost/coroutine/asymmetric_coroutine.hpp(812) : see declaration of 'boost::coroutines::pull_coroutine&lt;R&gt;::const_iterator' 1&gt; with 1&gt; [ 1&gt; R=int 1&gt; ] 1&gt;D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(365): error C2146: syntax error : missing ';' before identifier 'value_type' 1&gt;D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(365): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1&gt;D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(365): error C2602: 'std::iterator_traits&lt;_Iter&gt;::value_type' is not a member of a base class of 'std::iterator_traits&lt;_Iter&gt;' 1&gt; with 1&gt; [ 1&gt; _Iter=boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator 1&gt; ] 1&gt; D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(365) : see declaration of 'std::iterator_traits&lt;_Iter&gt;::value_type' 1&gt; with 1&gt; [ 1&gt; _Iter=boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator 1&gt; ] 1&gt;D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(365): error C2868: 'std::iterator_traits&lt;_Iter&gt;::value_type' : illegal syntax for using-declaration; expected qualified-name 1&gt; with 1&gt; [ 1&gt; _Iter=boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator 1&gt; ] 1&gt;D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(366): error C2027: use of undefined type 'boost::coroutines::pull_coroutine&lt;R&gt;::const_iterator' 1&gt; with 1&gt; [ 1&gt; R=int 1&gt; ] 1&gt; D:\Work\3rdparty\boost_1_58_0\boost/coroutine/asymmetric_coroutine.hpp(812) : see declaration of 'boost::coroutines::pull_coroutine&lt;R&gt;::const_iterator' 1&gt; with 1&gt; [ 1&gt; R=int 1&gt; ] 1&gt;D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(366): error C2146: syntax error : missing ';' before identifier 'difference_type' 1&gt;D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(366): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1&gt;D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(366): error C2602: 'std::iterator_traits&lt;_Iter&gt;::difference_type' is not a member of a base class of 'std::iterator_traits&lt;_Iter&gt;' 1&gt; with 1&gt; [ 1&gt; _Iter=boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator 1&gt; ] 1&gt; D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(366) : see declaration of 'std::iterator_traits&lt;_Iter&gt;::difference_type' 1&gt; with 1&gt; [ 1&gt; _Iter=boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator 1&gt; ] 1&gt;D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(366): error C2868: 'std::iterator_traits&lt;_Iter&gt;::difference_type' : illegal syntax for using-declaration; expected qualified-name 1&gt; with 1&gt; [ 1&gt; _Iter=boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator 1&gt; ] 1&gt;D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(368): error C2027: use of undefined type 'boost::coroutines::pull_coroutine&lt;R&gt;::const_iterator' 1&gt; with 1&gt; [ 1&gt; R=int 1&gt; ] 1&gt; D:\Work\3rdparty\boost_1_58_0\boost/coroutine/asymmetric_coroutine.hpp(812) : see declaration of 'boost::coroutines::pull_coroutine&lt;R&gt;::const_iterator' 1&gt; with 1&gt; [ 1&gt; R=int 1&gt; ] 1&gt;D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(368): error C2146: syntax error : missing ';' before identifier 'pointer' 1&gt;D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(368): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1&gt;D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(368): error C2602: 'std::iterator_traits&lt;_Iter&gt;::pointer' is not a member of a base class of 'std::iterator_traits&lt;_Iter&gt;' 1&gt; with 1&gt; [ 1&gt; _Iter=boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator 1&gt; ] 1&gt; D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(368) : see declaration of 'std::iterator_traits&lt;_Iter&gt;::pointer' 1&gt; with 1&gt; [ 1&gt; _Iter=boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator 1&gt; ] 1&gt;D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(368): error C2868: 'std::iterator_traits&lt;_Iter&gt;::pointer' : illegal syntax for using-declaration; expected qualified-name 1&gt; with 1&gt; [ 1&gt; _Iter=boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator 1&gt; ] 1&gt;D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(369): error C2027: use of undefined type 'boost::coroutines::pull_coroutine&lt;R&gt;::const_iterator' 1&gt; with 1&gt; [ 1&gt; R=int 1&gt; ] 1&gt; D:\Work\3rdparty\boost_1_58_0\boost/coroutine/asymmetric_coroutine.hpp(812) : see declaration of 'boost::coroutines::pull_coroutine&lt;R&gt;::const_iterator' 1&gt; with 1&gt; [ 1&gt; R=int 1&gt; ] 1&gt;D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(369): error C2146: syntax error : missing ';' before identifier 'reference' 1&gt;D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(369): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1&gt;D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(369): error C2602: 'std::iterator_traits&lt;_Iter&gt;::reference' is not a member of a base class of 'std::iterator_traits&lt;_Iter&gt;' 1&gt; with 1&gt; [ 1&gt; _Iter=boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator 1&gt; ] 1&gt; D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(369) : see declaration of 'std::iterator_traits&lt;_Iter&gt;::reference' 1&gt; with 1&gt; [ 1&gt; _Iter=boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator 1&gt; ] 1&gt;D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(369): error C2868: 'std::iterator_traits&lt;_Iter&gt;::reference' : illegal syntax for using-declaration; expected qualified-name 1&gt; with 1&gt; [ 1&gt; _Iter=boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator 1&gt; ] 1&gt;D:\Work\3rdparty\boost_1_58_0\boost/mpl/eval_if.hpp(41): error C2516: 'boost::mpl::if_&lt;T1,T2,T3&gt;::type' : is not a legal base class 1&gt; with 1&gt; [ 1&gt; T1=boost::is_convertible&lt;int,std::output_iterator_tag&gt;, 1&gt; T2=boost::mpl::identity&lt;boost::iterators::incrementable_traversal_tag&gt;, 1&gt; T3=void 1&gt; ] 1&gt; D:\Work\3rdparty\boost_1_58_0\boost/mpl/if.hpp(70) : see declaration of 'boost::mpl::if_&lt;T1,T2,T3&gt;::type' 1&gt; with 1&gt; [ 1&gt; T1=boost::is_convertible&lt;int,std::output_iterator_tag&gt;, 1&gt; T2=boost::mpl::identity&lt;boost::iterators::incrementable_traversal_tag&gt;, 1&gt; T3=void 1&gt; ] 1&gt; D:\Work\3rdparty\boost_1_58_0\boost/mpl/eval_if.hpp(41) : see reference to class template instantiation 'boost::mpl::eval_if&lt;C,F1,F2&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; C=boost::is_convertible&lt;int,std::output_iterator_tag&gt;, 1&gt; F1=boost::mpl::identity&lt;boost::iterators::incrementable_traversal_tag&gt;, 1&gt; F2=void 1&gt; ] 1&gt; D:\Work\3rdparty\boost_1_58_0\boost/mpl/eval_if.hpp(41) : see reference to class template instantiation 'boost::mpl::eval_if&lt;C,F1,F2&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; C=boost::is_convertible&lt;int,std::input_iterator_tag&gt;, 1&gt; F1=boost::mpl::identity&lt;boost::iterators::single_pass_traversal_tag&gt;, 1&gt; F2=boost::mpl::eval_if&lt;boost::is_convertible&lt;int,std::output_iterator_tag&gt;,boost::mpl::identity&lt;boost::iterators::incrementable_traversal_tag&gt;,void&gt; 1&gt; ] 1&gt; D:\Work\3rdparty\boost_1_58_0\boost/mpl/eval_if.hpp(41) : see reference to class template instantiation 'boost::mpl::eval_if&lt;C,F1,F2&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; C=boost::is_convertible&lt;int,std::forward_iterator_tag&gt;, 1&gt; F1=boost::mpl::identity&lt;boost::iterators::forward_traversal_tag&gt;, 1&gt; F2=boost::mpl::eval_if&lt;boost::is_convertible&lt;int,std::input_iterator_tag&gt;,boost::mpl::identity&lt;boost::iterators::single_pass_traversal_tag&gt;,boost::mpl::eval_if&lt;boost::is_convertible&lt;int,std::output_iterator_tag&gt;,boost::mpl::identity&lt;boost::iterators::incrementable_traversal_tag&gt;,void&gt;&gt; 1&gt; ] 1&gt; D:\Work\3rdparty\boost_1_58_0\boost/mpl/eval_if.hpp(41) : see reference to class template instantiation 'boost::mpl::eval_if&lt;C,F1,F2&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; C=boost::is_convertible&lt;int,std::bidirectional_iterator_tag&gt;, 1&gt; F1=boost::mpl::identity&lt;boost::iterators::bidirectional_traversal_tag&gt;, 1&gt; F2=boost::mpl::eval_if&lt;boost::is_convertible&lt;int,std::forward_iterator_tag&gt;,boost::mpl::identity&lt;boost::iterators::forward_traversal_tag&gt;,boost::mpl::eval_if&lt;boost::is_convertible&lt;int,std::input_iterator_tag&gt;,boost::mpl::identity&lt;boost::iterators::single_pass_traversal_tag&gt;,boost::mpl::eval_if&lt;boost::is_convertible&lt;int,std::output_iterator_tag&gt;,boost::mpl::identity&lt;boost::iterators::incrementable_traversal_tag&gt;,void&gt;&gt;&gt; 1&gt; ] 1&gt; D:\Work\3rdparty\boost_1_58_0\boost/iterator/iterator_categories.hpp(99) : see reference to class template instantiation 'boost::mpl::eval_if&lt;C,F1,F2&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; C=boost::is_convertible&lt;int,std::random_access_iterator_tag&gt;, 1&gt; F1=boost::mpl::identity&lt;boost::iterators::random_access_traversal_tag&gt;, 1&gt; F2=boost::mpl::eval_if&lt;boost::is_convertible&lt;int,std::bidirectional_iterator_tag&gt;,boost::mpl::identity&lt;boost::iterators::bidirectional_traversal_tag&gt;,boost::mpl::eval_if&lt;boost::is_convertible&lt;int,std::forward_iterator_tag&gt;,boost::mpl::identity&lt;boost::iterators::forward_traversal_tag&gt;,boost::mpl::eval_if&lt;boost::is_convertible&lt;int,std::input_iterator_tag&gt;,boost::mpl::identity&lt;boost::iterators::single_pass_traversal_tag&gt;,boost::mpl::eval_if&lt;boost::is_convertible&lt;int,std::output_iterator_tag&gt;,boost::mpl::identity&lt;boost::iterators::incrementable_traversal_tag&gt;,void&gt;&gt;&gt;&gt; 1&gt; ] 1&gt; D:\Work\3rdparty\boost_1_58_0\boost/mpl/eval_if.hpp(41) : see reference to class template instantiation 'boost::iterators::detail::old_category_to_traversal&lt;Cat&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; Cat=int 1&gt; ] 1&gt; D:\Work\3rdparty\boost_1_58_0\boost/iterator/iterator_categories.hpp(113) : see reference to class template instantiation 'boost::mpl::eval_if&lt;C,F1,F2&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; C=boost::is_convertible&lt;int,boost::iterators::incrementable_traversal_tag&gt;, 1&gt; F1=boost::mpl::identity&lt;int&gt;, 1&gt; F2=boost::iterators::detail::old_category_to_traversal&lt;int&gt; 1&gt; ] 1&gt; D:\Work\3rdparty\boost_1_58_0\boost/iterator/iterator_categories.hpp(121) : see reference to class template instantiation 'boost::iterators::iterator_category_to_traversal&lt;Cat&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; Cat=int 1&gt; ] 1&gt;D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(126): error C2039: 'type' : is not a member of 'boost::iterators::iterator_traversal&lt;Iterator&gt;' 1&gt; with 1&gt; [ 1&gt; Iterator=boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator 1&gt; ] 1&gt;D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(126): error C2146: syntax error : missing ';' before identifier 'traversal_category' 1&gt;D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(126): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1&gt;D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(128): error C2065: 'traversal_category' : undeclared identifier 1&gt;D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(128): error C2923: 'boost::Convertible' : 'traversal_category' is not a valid template type argument for parameter 'X' 1&gt;D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(128): error C2893: Failed to specialize function template 'boost::concepts::require&lt;Model&gt; boost::concepts::require_(void (__cdecl *)(Model))' 1&gt; With the following template arguments: 1&gt; 'boost::Convertible' 1&gt;D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(128): error C2056: illegal expression 1&gt;D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(140): error C2079: 'boost::range_detail::IncrementableIteratorConcept&lt;Iterator&gt;::i' uses undefined struct 'boost::coroutines::pull_coroutine&lt;R&gt;::const_iterator' 1&gt; with 1&gt; [ 1&gt; Iterator=boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator 1&gt; ] 1&gt; and 1&gt; [ 1&gt; R=int 1&gt; ] 1&gt;D:\Work\3rdparty\boost_1_58_0\boost/concept_check.hpp(239): error C2079: 'boost::EqualityComparable&lt;TT&gt;::a' uses undefined struct 'boost::coroutines::pull_coroutine&lt;R&gt;::const_iterator' 1&gt; with 1&gt; [ 1&gt; TT=boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator 1&gt; ] 1&gt; and 1&gt; [ 1&gt; R=int 1&gt; ] 1&gt; D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(148) : see reference to class template instantiation 'boost::EqualityComparable&lt;TT&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; TT=boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator 1&gt; ] 1&gt;D:\Work\3rdparty\boost_1_58_0\boost/concept_check.hpp(239): error C2079: 'boost::EqualityComparable&lt;TT&gt;::b' uses undefined struct 'boost::coroutines::pull_coroutine&lt;R&gt;::const_iterator' 1&gt; with 1&gt; [ 1&gt; TT=boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator 1&gt; ] 1&gt; and 1&gt; [ 1&gt; R=int 1&gt; ] 1&gt;D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(150): error C2146: syntax error : missing ',' before identifier 'traversal_category' 1&gt;D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(150): error C2065: 'traversal_category' : undeclared identifier 1&gt;D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(150): error C2893: Failed to specialize function template 'boost::concepts::require&lt;Model&gt; boost::concepts::require_(void (__cdecl *)(Model))' 1&gt; With the following template arguments: 1&gt; 'boost::Convertible' 1&gt;D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(150): error C2056: illegal expression 1&gt;D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(174): error C2079: 'boost::range_detail::SinglePassIteratorConcept&lt;Iterator&gt;::i' uses undefined struct 'boost::coroutines::pull_coroutine&lt;R&gt;::const_iterator' 1&gt; with 1&gt; [ 1&gt; Iterator=boost::coroutines::pull_coroutine&lt;int&gt;::const_iterator 1&gt; ] 1&gt; and 1&gt; [ 1&gt; R=int 1&gt; ] 1&gt; 1&gt;Build FAILED. 1&gt; </pre><p> Generator models <a class="missing wiki">SinglePassRange</a> and modify itself will iterating, but distance accept range only by const reference </p> <pre class="wiki"> template&lt; class T &gt; inline BOOST_DEDUCED_TYPENAME range_difference&lt;T&gt;::type distance( const T&amp; r ) { return std::distance( boost::begin( r ), boost::end( r ) ); } </pre><p> I checked other algorithms and found that some of them have non const reference overload (for example count) </p> <pre class="wiki">template&lt;class SinglePassRange, class Value&gt; typename range_difference&lt;SinglePassRange&gt;::type count(SinglePassRange&amp; rng, const Value&amp; val); template&lt;class SinglePassRange, class Value&gt; typename range_difference&lt;const SinglePassRange&gt;::type count(const SinglePassRange&amp; rng, const Value&amp; val); </pre><p> I tried count instead of distance and I was suprised that it doesn't compile too. </p> <pre class="wiki">asymmetric_coroutine&lt;int&gt;::pull_type make_dummy_range() { return asymmetric_coroutine&lt;int&gt;::pull_type([](asymmetric_coroutine&lt;int&gt;::push_type&amp; yield) { yield(1); }); } int _tmain(int argc, _TCHAR* argv[]) { asymmetric_coroutine&lt;int&gt;::pull_type r = make_dummy_range(); boost::count(r, 1); //still complains on const_iterator return 0; } </pre><p> I don't understand why MSVC12 compiler still prefer const ref overload </p> <pre class="wiki">template&lt;class SinglePassRange, class Value&gt; typename range_difference&lt;const SinglePassRange&gt;::type count(const SinglePassRange&amp; rng, const Value&amp; val); </pre><p> but it is </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11248 Trac 1.4.3