id summary reporter owner description type status milestone component version severity resolution keywords cc 11248 Some algorithms with requirement for SinglePassRange accept range only by const reference Taras Kozlov Neil Groves "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 {{{ #include #include using namespace boost::range; using namespace boost::coroutines; asymmetric_coroutine::pull_type make_dummy_range() { return asymmetric_coroutine::pull_type([](asymmetric_coroutine::push_type& yield) { yield(1); }); } int _tmain(int argc, _TCHAR* argv[]) { boost::distance(make_dummy_range()); // error return 0; } }}} with error {{{ D:\Work\3rdparty\boost_1_58_0\boost/concept_check.hpp(181): error C2079: 'boost::CopyConstructible::b' uses undefined struct 'boost::coroutines::pull_coroutine::const_iterator' 1> with 1> [ 1> TT=boost::coroutines::pull_coroutine::const_iterator 1> ] 1> and 1> [ 1> R=int 1> ] 1> D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(124) : see reference to class template instantiation 'boost::CopyConstructible' being compiled 1> with 1> [ 1> TT=boost::coroutines::pull_coroutine::const_iterator 1> ] 1> D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(147) : see reference to class template instantiation 'boost::range_detail::IncrementableIteratorConcept' being compiled 1> with 1> [ 1> Iterator=boost::coroutines::pull_coroutine::const_iterator 1> ] 1> D:\Work\3rdparty\boost_1_58_0\boost/concept/detail/msvc.hpp(29) : see reference to class template instantiation 'boost::range_detail::SinglePassIteratorConcept' being compiled 1> with 1> [ 1> Iterator=boost::coroutines::pull_coroutine::const_iterator 1> ] 1> D:\Work\3rdparty\boost_1_58_0\boost/concept/detail/msvc.hpp(28) : while compiling class template member function 'void boost::concepts::check::failed(Model *)' 1> with 1> [ 1> Model=boost::range_detail::SinglePassIteratorConcept::const_iterator> 1> ] 1> D:\Work\3rdparty\boost_1_58_0\boost/concept/detail/msvc.hpp(66) : see reference to class template instantiation 'boost::concepts::check' being compiled 1> with 1> [ 1> Model=boost::range_detail::SinglePassIteratorConcept::const_iterator> 1> ] 1> D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(279) : see reference to class template instantiation 'boost::concepts::require' being compiled 1> with 1> [ 1> Model=boost::range_detail::SinglePassIteratorConcept::const_iterator> 1> ] 1> D:\Work\3rdparty\boost_1_58_0\boost/concept/detail/has_constraints.hpp(42) : see reference to class template instantiation 'boost::SinglePassRangeConcept' being compiled 1> with 1> [ 1> T=boost::coroutines::pull_coroutine 1> ] 1> D:\Work\3rdparty\boost_1_58_0\boost/concept/detail/msvc.hpp(58) : see reference to class template instantiation 'boost::concepts::not_satisfied' being compiled 1> with 1> [ 1> Model=boost::SinglePassRangeConcept> 1> ] 1> D:\Work\3rdparty\boost_1_58_0\boost/range/algorithm/for_each.hpp(72) : see reference to class template instantiation 'boost::concepts::require' being compiled 1> with 1> [ 1> Model=boost::SinglePassRangeConcept> 1> ] 1> coroutine_bug.cpp(29) : see reference to function template instantiation 'UnaryFunction boost::range::for_each,wmain::>(SinglePassRange &,UnaryFunction)' being compiled 1> with 1> [ 1> UnaryFunction=wmain::, 1> R=int, 1> SinglePassRange=boost::coroutines::pull_coroutine 1> ] 1>D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(364): error C2027: use of undefined type 'boost::coroutines::pull_coroutine::const_iterator' 1> with 1> [ 1> R=int 1> ] 1> D:\Work\3rdparty\boost_1_58_0\boost/coroutine/asymmetric_coroutine.hpp(812) : see declaration of 'boost::coroutines::pull_coroutine::const_iterator' 1> with 1> [ 1> R=int 1> ] 1> D:\Work\3rdparty\boost_1_58_0\boost/iterator/iterator_categories.hpp(119) : see reference to class template instantiation 'std::iterator_traits<_Iter>' being compiled 1> with 1> [ 1> _Iter=boost::coroutines::pull_coroutine::const_iterator 1> ] 1> D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(126) : see reference to class template instantiation 'boost::iterators::iterator_traversal' being compiled 1> with 1> [ 1> Iterator=boost::coroutines::pull_coroutine::const_iterator 1> ] 1>D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(364): error C2146: syntax error : missing ';' before identifier 'iterator_category' 1>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>D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(364): error C2602: 'std::iterator_traits<_Iter>::iterator_category' is not a member of a base class of 'std::iterator_traits<_Iter>' 1> with 1> [ 1> _Iter=boost::coroutines::pull_coroutine::const_iterator 1> ] 1> D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(364) : see declaration of 'std::iterator_traits<_Iter>::iterator_category' 1> with 1> [ 1> _Iter=boost::coroutines::pull_coroutine::const_iterator 1> ] 1>D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(364): error C2868: 'std::iterator_traits<_Iter>::iterator_category' : illegal syntax for using-declaration; expected qualified-name 1> with 1> [ 1> _Iter=boost::coroutines::pull_coroutine::const_iterator 1> ] 1>D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(365): error C2027: use of undefined type 'boost::coroutines::pull_coroutine::const_iterator' 1> with 1> [ 1> R=int 1> ] 1> D:\Work\3rdparty\boost_1_58_0\boost/coroutine/asymmetric_coroutine.hpp(812) : see declaration of 'boost::coroutines::pull_coroutine::const_iterator' 1> with 1> [ 1> R=int 1> ] 1>D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(365): error C2146: syntax error : missing ';' before identifier 'value_type' 1>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>D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(365): error C2602: 'std::iterator_traits<_Iter>::value_type' is not a member of a base class of 'std::iterator_traits<_Iter>' 1> with 1> [ 1> _Iter=boost::coroutines::pull_coroutine::const_iterator 1> ] 1> D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(365) : see declaration of 'std::iterator_traits<_Iter>::value_type' 1> with 1> [ 1> _Iter=boost::coroutines::pull_coroutine::const_iterator 1> ] 1>D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(365): error C2868: 'std::iterator_traits<_Iter>::value_type' : illegal syntax for using-declaration; expected qualified-name 1> with 1> [ 1> _Iter=boost::coroutines::pull_coroutine::const_iterator 1> ] 1>D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(366): error C2027: use of undefined type 'boost::coroutines::pull_coroutine::const_iterator' 1> with 1> [ 1> R=int 1> ] 1> D:\Work\3rdparty\boost_1_58_0\boost/coroutine/asymmetric_coroutine.hpp(812) : see declaration of 'boost::coroutines::pull_coroutine::const_iterator' 1> with 1> [ 1> R=int 1> ] 1>D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(366): error C2146: syntax error : missing ';' before identifier 'difference_type' 1>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>D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(366): error C2602: 'std::iterator_traits<_Iter>::difference_type' is not a member of a base class of 'std::iterator_traits<_Iter>' 1> with 1> [ 1> _Iter=boost::coroutines::pull_coroutine::const_iterator 1> ] 1> D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(366) : see declaration of 'std::iterator_traits<_Iter>::difference_type' 1> with 1> [ 1> _Iter=boost::coroutines::pull_coroutine::const_iterator 1> ] 1>D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(366): error C2868: 'std::iterator_traits<_Iter>::difference_type' : illegal syntax for using-declaration; expected qualified-name 1> with 1> [ 1> _Iter=boost::coroutines::pull_coroutine::const_iterator 1> ] 1>D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(368): error C2027: use of undefined type 'boost::coroutines::pull_coroutine::const_iterator' 1> with 1> [ 1> R=int 1> ] 1> D:\Work\3rdparty\boost_1_58_0\boost/coroutine/asymmetric_coroutine.hpp(812) : see declaration of 'boost::coroutines::pull_coroutine::const_iterator' 1> with 1> [ 1> R=int 1> ] 1>D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(368): error C2146: syntax error : missing ';' before identifier 'pointer' 1>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>D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(368): error C2602: 'std::iterator_traits<_Iter>::pointer' is not a member of a base class of 'std::iterator_traits<_Iter>' 1> with 1> [ 1> _Iter=boost::coroutines::pull_coroutine::const_iterator 1> ] 1> D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(368) : see declaration of 'std::iterator_traits<_Iter>::pointer' 1> with 1> [ 1> _Iter=boost::coroutines::pull_coroutine::const_iterator 1> ] 1>D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(368): error C2868: 'std::iterator_traits<_Iter>::pointer' : illegal syntax for using-declaration; expected qualified-name 1> with 1> [ 1> _Iter=boost::coroutines::pull_coroutine::const_iterator 1> ] 1>D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(369): error C2027: use of undefined type 'boost::coroutines::pull_coroutine::const_iterator' 1> with 1> [ 1> R=int 1> ] 1> D:\Work\3rdparty\boost_1_58_0\boost/coroutine/asymmetric_coroutine.hpp(812) : see declaration of 'boost::coroutines::pull_coroutine::const_iterator' 1> with 1> [ 1> R=int 1> ] 1>D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(369): error C2146: syntax error : missing ';' before identifier 'reference' 1>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>D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(369): error C2602: 'std::iterator_traits<_Iter>::reference' is not a member of a base class of 'std::iterator_traits<_Iter>' 1> with 1> [ 1> _Iter=boost::coroutines::pull_coroutine::const_iterator 1> ] 1> D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(369) : see declaration of 'std::iterator_traits<_Iter>::reference' 1> with 1> [ 1> _Iter=boost::coroutines::pull_coroutine::const_iterator 1> ] 1>D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xutility(369): error C2868: 'std::iterator_traits<_Iter>::reference' : illegal syntax for using-declaration; expected qualified-name 1> with 1> [ 1> _Iter=boost::coroutines::pull_coroutine::const_iterator 1> ] 1>D:\Work\3rdparty\boost_1_58_0\boost/mpl/eval_if.hpp(41): error C2516: 'boost::mpl::if_::type' : is not a legal base class 1> with 1> [ 1> T1=boost::is_convertible, 1> T2=boost::mpl::identity, 1> T3=void 1> ] 1> D:\Work\3rdparty\boost_1_58_0\boost/mpl/if.hpp(70) : see declaration of 'boost::mpl::if_::type' 1> with 1> [ 1> T1=boost::is_convertible, 1> T2=boost::mpl::identity, 1> T3=void 1> ] 1> D:\Work\3rdparty\boost_1_58_0\boost/mpl/eval_if.hpp(41) : see reference to class template instantiation 'boost::mpl::eval_if' being compiled 1> with 1> [ 1> C=boost::is_convertible, 1> F1=boost::mpl::identity, 1> F2=void 1> ] 1> D:\Work\3rdparty\boost_1_58_0\boost/mpl/eval_if.hpp(41) : see reference to class template instantiation 'boost::mpl::eval_if' being compiled 1> with 1> [ 1> C=boost::is_convertible, 1> F1=boost::mpl::identity, 1> F2=boost::mpl::eval_if,boost::mpl::identity,void> 1> ] 1> D:\Work\3rdparty\boost_1_58_0\boost/mpl/eval_if.hpp(41) : see reference to class template instantiation 'boost::mpl::eval_if' being compiled 1> with 1> [ 1> C=boost::is_convertible, 1> F1=boost::mpl::identity, 1> F2=boost::mpl::eval_if,boost::mpl::identity,boost::mpl::eval_if,boost::mpl::identity,void>> 1> ] 1> D:\Work\3rdparty\boost_1_58_0\boost/mpl/eval_if.hpp(41) : see reference to class template instantiation 'boost::mpl::eval_if' being compiled 1> with 1> [ 1> C=boost::is_convertible, 1> F1=boost::mpl::identity, 1> F2=boost::mpl::eval_if,boost::mpl::identity,boost::mpl::eval_if,boost::mpl::identity,boost::mpl::eval_if,boost::mpl::identity,void>>> 1> ] 1> D:\Work\3rdparty\boost_1_58_0\boost/iterator/iterator_categories.hpp(99) : see reference to class template instantiation 'boost::mpl::eval_if' being compiled 1> with 1> [ 1> C=boost::is_convertible, 1> F1=boost::mpl::identity, 1> F2=boost::mpl::eval_if,boost::mpl::identity,boost::mpl::eval_if,boost::mpl::identity,boost::mpl::eval_if,boost::mpl::identity,boost::mpl::eval_if,boost::mpl::identity,void>>>> 1> ] 1> 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' being compiled 1> with 1> [ 1> Cat=int 1> ] 1> D:\Work\3rdparty\boost_1_58_0\boost/iterator/iterator_categories.hpp(113) : see reference to class template instantiation 'boost::mpl::eval_if' being compiled 1> with 1> [ 1> C=boost::is_convertible, 1> F1=boost::mpl::identity, 1> F2=boost::iterators::detail::old_category_to_traversal 1> ] 1> 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' being compiled 1> with 1> [ 1> Cat=int 1> ] 1>D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(126): error C2039: 'type' : is not a member of 'boost::iterators::iterator_traversal' 1> with 1> [ 1> Iterator=boost::coroutines::pull_coroutine::const_iterator 1> ] 1>D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(126): error C2146: syntax error : missing ';' before identifier 'traversal_category' 1>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>D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(128): error C2065: 'traversal_category' : undeclared identifier 1>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>D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(128): error C2893: Failed to specialize function template 'boost::concepts::require boost::concepts::require_(void (__cdecl *)(Model))' 1> With the following template arguments: 1> 'boost::Convertible' 1>D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(128): error C2056: illegal expression 1>D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(140): error C2079: 'boost::range_detail::IncrementableIteratorConcept::i' uses undefined struct 'boost::coroutines::pull_coroutine::const_iterator' 1> with 1> [ 1> Iterator=boost::coroutines::pull_coroutine::const_iterator 1> ] 1> and 1> [ 1> R=int 1> ] 1>D:\Work\3rdparty\boost_1_58_0\boost/concept_check.hpp(239): error C2079: 'boost::EqualityComparable::a' uses undefined struct 'boost::coroutines::pull_coroutine::const_iterator' 1> with 1> [ 1> TT=boost::coroutines::pull_coroutine::const_iterator 1> ] 1> and 1> [ 1> R=int 1> ] 1> D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(148) : see reference to class template instantiation 'boost::EqualityComparable' being compiled 1> with 1> [ 1> TT=boost::coroutines::pull_coroutine::const_iterator 1> ] 1>D:\Work\3rdparty\boost_1_58_0\boost/concept_check.hpp(239): error C2079: 'boost::EqualityComparable::b' uses undefined struct 'boost::coroutines::pull_coroutine::const_iterator' 1> with 1> [ 1> TT=boost::coroutines::pull_coroutine::const_iterator 1> ] 1> and 1> [ 1> R=int 1> ] 1>D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(150): error C2146: syntax error : missing ',' before identifier 'traversal_category' 1>D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(150): error C2065: 'traversal_category' : undeclared identifier 1>D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(150): error C2893: Failed to specialize function template 'boost::concepts::require boost::concepts::require_(void (__cdecl *)(Model))' 1> With the following template arguments: 1> 'boost::Convertible' 1>D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(150): error C2056: illegal expression 1>D:\Work\3rdparty\boost_1_58_0\boost/range/concepts.hpp(174): error C2079: 'boost::range_detail::SinglePassIteratorConcept::i' uses undefined struct 'boost::coroutines::pull_coroutine::const_iterator' 1> with 1> [ 1> Iterator=boost::coroutines::pull_coroutine::const_iterator 1> ] 1> and 1> [ 1> R=int 1> ] 1> 1>Build FAILED. 1> }}} Generator models SinglePassRange and modify itself will iterating, but distance accept range only by const reference {{{ template< class T > inline BOOST_DEDUCED_TYPENAME range_difference::type distance( const T& r ) { return std::distance( boost::begin( r ), boost::end( r ) ); } }}} I checked other algorithms and found that some of them have non const reference overload (for example count) {{{ template typename range_difference::type count(SinglePassRange& rng, const Value& val); template typename range_difference::type count(const SinglePassRange& rng, const Value& val); }}} I tried count instead of distance and I was suprised that it doesn't compile too. {{{ asymmetric_coroutine::pull_type make_dummy_range() { return asymmetric_coroutine::pull_type([](asymmetric_coroutine::push_type& yield) { yield(1); }); } int _tmain(int argc, _TCHAR* argv[]) { asymmetric_coroutine::pull_type r = make_dummy_range(); boost::count(r, 1); //still complains on const_iterator return 0; } }}} I don't understand why MSVC12 compiler still prefer const ref overload {{{ template typename range_difference::type count(const SinglePassRange& rng, const Value& val); }}} but it is" Bugs new To Be Determined range Boost 1.57.0 Problem