Adding the following
namespace boost
{
namespace coroutines
{
using boost::begin;
using boost::end;
}
}
solves the problem, however this would seem to indicate that the provided begin and end are in the wrong namespace and therefore do not take part in ADL. Should I report this as a bug? Doesn't seem to be intended.
--
Johannes S. Mueller-Roemer, MSc
Wiss. Mitarbeiter - Interactive Engineering Technologies (IET)
Fraunhofer-Institut für Graphische Datenverarbeitung IGD
Fraunhoferstr. 5 | 64283 Darmstadt | Germany
Tel +49 6151 155-606 | Fax +49 6151 155-139
johannes.mueller-roemer@igd.fraunhofer.de | www.igd.fraunhofer.de
From: Mueller-Roemer, Johannes Sebastian
Sent: Wednesday, August 27, 2014 12:57
To: 'boost-users@lists.boost.org'
Subject: Cannot use Boost.Croutines with range based for
Hi,
I am (again) having issues with the Boost.Coroutines library. Aside from yet another new API, the coroutines no longer work with range based for. Even though the examples include range based for! With the following code (taken directly from the documentation and added the includes and main):
#include
#include <iostream>
int main()
{
boost::coroutines::asymmetric_coroutine<int>::pull_type source(
[&](boost::coroutines::asymmetric_coroutine<int>::push_type& sink){
int first=1, second=1;
sink(first);
sink(second);
for(int i=0;i<8;++i){
int third=first+second;
first=second;
second=third;
sink(third);
}
}
);
for(auto i : source)
std::cout << i << " ";
}
I get this error:
D:\projects\combinators\coro_test.cpp: In function 'int main()':
D:\projects\combinators\coro_test.cpp:20:15: error: 'begin' was not declared in this scope
for(auto i : source)
^
D:\projects\combinators\coro_test.cpp:20:15: note: suggested alternatives:
In file included from D:\projects\combinators\coro_test.cpp:1:0:
D:/libs/mingw-amd64/boost_1_56_0/include/boost-1_56/boost/coroutine/asymmetric_coroutine.hpp:2255:1: note: 'std::begin'
begin( boost::coroutines::push_coroutine< R > & c)
^
In file included from D:/libs/mingw-amd64/boost_1_56_0/include/boost-1_56/boost/range/functions.hpp:18:0,
from D:/libs/mingw-amd64/boost_1_56_0/include/boost-1_56/boost/range.hpp:18,
from D:/libs/mingw-amd64/boost_1_56_0/include/boost-1_56/boost/coroutine/asymmetric_coroutine.hpp:17,
from D:\projects\combinators\coro_test.cpp:1:
D:/libs/mingw-amd64/boost_1_56_0/include/boost-1_56/boost/range/begin.hpp:106:61: note: 'boost::range_adl_barrier::begin'
inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type begin( const T& r )
^
D:/libs/mingw-amd64/boost_1_56_0/include/boost-1_56/boost/range/begin.hpp:106:61: note: 'boost::range_adl_barrier::begin'
D:\projects\combinators\coro_test.cpp:20:15: error: 'end' was not declared in this scope
for(auto i : source)
^
D:\projects\combinators\coro_test.cpp:20:15: note: suggested alternatives:
In file included from D:\projects\combinators\coro_test.cpp:1:0:
D:/libs/mingw-amd64/boost_1_56_0/include/boost-1_56/boost/coroutine/asymmetric_coroutine.hpp:2260:1: note: 'std::end'
end( boost::coroutines::push_coroutine< R > & c)
^
In file included from D:/libs/mingw-amd64/boost_1_56_0/include/boost-1_56/boost/range/functions.hpp:19:0,
from D:/libs/mingw-amd64/boost_1_56_0/include/boost-1_56/boost/range.hpp:18,
from D:/libs/mingw-amd64/boost_1_56_0/include/boost-1_56/boost/coroutine/asymmetric_coroutine.hpp:17,
from D:\projects\combinators\coro_test.cpp:1:
D:/libs/mingw-amd64/boost_1_56_0/include/boost-1_56/boost/range/end.hpp:100:61: note: 'boost::range_adl_barrier::end'
inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type end( const T& r )
^
D:/libs/mingw-amd64/boost_1_56_0/include/boost-1_56/boost/range/end.hpp:100:61: note: 'boost::range_adl_barrier::end'
mingw32-make[2]: *** [CMakeFiles/coro-test.dir/coro_test.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles/coro-test.dir/all] Error 2
mingw32-make: *** [all] Error 2
For completeness sake: I am using MinGW-w64 with GCC 4.9.1 and the -std=c++11 flag
Regards,
Johannes S. Mueller-Roemer
--
Johannes S. Mueller-Roemer, MSc
Wiss. Mitarbeiter - Interactive Engineering Technologies (IET)
Fraunhofer-Institut für Graphische Datenverarbeitung IGD
Fraunhoferstr. 5 | 64283 Darmstadt | Germany
Tel +49 6151 155-606 | Fax +49 6151 155-139
johannes.mueller-roemer@igd.fraunhofer.demailto:johannes.mueller-roemer@igd.fraunhofer.de | www.igd.fraunhofer.dehttp://www.igd.fraunhofer.de