Boost C++ Libraries: Ticket #11234: boost::asymmetric_coroutine doesn't compile when used with boost::range::algorithms https://svn.boost.org/trac10/ticket/11234 <p> I've tried to use generators produced by boost::asymmetric_coroutines together with boost::range::algorithms (for example find_if) and it fails to compile. </p> <p> Following code raise compilation error </p> <pre class="wiki"> #include &lt;boost/range/algorithm/count.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); }); } template&lt;typename Range&gt; void const_func(const Range&amp; r) { auto b = boost::begin(r); } int _tmain(int argc, _TCHAR* argv[]) { const_func(make_dummy_range()); return 0; } </pre><pre class="wiki">c:\users\taras\documents\visual studio 2012\projects\coroutine_bug\coroutine_bug\coroutine_bug.cpp(23): 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; c:\users\taras\documents\visual studio 2012\projects\coroutine_bug\coroutine_bug\coroutine_bug.cpp(28) : see reference to function template instantiation 'void const_func&lt;boost::coroutines::pull_coroutine&lt;R&gt;&gt;(const Range &amp;)' being compiled 1&gt; with 1&gt; [ 1&gt; R=int, 1&gt; Range=boost::coroutines::pull_coroutine&lt;int&gt; 1&gt; ] 1&gt;c:\users\taras\documents\visual studio 2012\projects\coroutine_bug\coroutine_bug\coroutine_bug.cpp(23): error C2514: 'boost::coroutines::pull_coroutine&lt;R&gt;::const_iterator' : class has no constructors 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; 1&gt;Build FAILED. </pre><p> The problem is that boost::asymmetric_coroutine::const_iterator is declared but never defined, see boost/coroutine/asymmetric_coroutine.hpp:180 </p> <p> I detected this problem while was trying to migrate from Boost 1.55. With Boost 1.55 this code compiles and everything is fine. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11234 Trac 1.4.3 olli Sat, 25 Apr 2015 15:20:53 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/11234#comment:1 https://svn.boost.org/trac10/ticket/11234#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">wontfix</span> </li> </ul> <p> const_iterator must not be defined - it will never be const because each incrementation will modify/changed the associated coroutine. removing the declaration for const_iteration from the header will not help. </p> Ticket kozlov.taras@… Mon, 27 Apr 2015 09:37:12 GMT <link>https://svn.boost.org/trac10/ticket/11234#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11234#comment:2</guid> <description> <p> First of all boost coroutines and ranges can't be used together at the moment. This is definitly a bug. And ok, probably it should be fixed in Boost.Range </p> <p> I want to clearify problem again. Using generator together with ANY non mutating Boost.Range algorithm yields compiler error </p> <p> Example </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[]) { boost::for_each(make_dummy_range(), ...); //error boost::max_element(make_dummy_range()); //error boost::distance(make_dummy_range()); //error boost::find(make_dummy_range(), 1); //error } </pre><p> I put this bug to boost.coroutines for two reasons. </p> <ol><li>It is known problem that <a class="missing wiki">SinglePassRange</a> can't define perfect const_iterator, but it is also common and convinient workaround to override range_const_iterator to return mutable iterator. So any algorithm which accept const Range&amp; can work with it. </li></ol><ol start="2"><li>Coroutines in Boost 1.55 already provided const_iterator, so Boost 1.58 just broken some existing code. </li></ol> </description> <category>Ticket</category> </item> <item> <dc:creator>olli</dc:creator> <pubDate>Wed, 29 Apr 2015 18:34:58 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11234#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11234#comment:3</guid> <description> <p> commit pushed to branch develop </p> </description> <category>Ticket</category> </item> </channel> </rss>