Created
October 18, 2013 09:23
-
-
Save argv0/7038937 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdlib> | |
#include <iostream> | |
#include <boost/coroutine/all.hpp> | |
using namespace boost::coroutines; | |
using namespace std; | |
int main() | |
{ | |
coroutine< int() > c( | |
[&]( coroutine< void( int) > & c) { | |
int first = 1, second = 1; | |
for ( int i = 0; i < 10; ++i) | |
{ | |
int third = first + second; | |
first = second; | |
second = third; | |
c( third); | |
} | |
}); | |
for ( auto i : c) cout << i << " "; | |
return 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
++ -std=c++11 -Weffc++ -Wstrict-null-sentinel coroutine.cpp -o coroutine
coroutine.cpp: In function ‘int main()’:
coroutine.cpp:19:20: error: no matching function for call to ‘begin(boost::coroutines::coroutine<int
()>&)’
for ( auto i : c) cout << i << " ";
^
coroutine.cpp:19:20: note: candidates are:
In file included from /usr/include/c++/4.8/bits/basic_string.h:42:0,
from /usr/include/c++/4.8/string:52,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from coroutine.cpp:2:
/usr/include/c++/4.8/initializer_list:89:5: note: template constexpr const _Tp* std::begi
n(std::initializer_list<_Tp>)
begin(initializer_list<_Tp> __ils) noexcept
^
/usr/include/c++/4.8/initializer_list:89:5: note: template argument deduction/substitution failed:
coroutine.cpp:19:20: note: ‘boost::coroutines::coroutine<int()>’ is not derived from ‘std::initial
izer_list<_Tp>’
for ( auto i : c) cout << i << " ";
^
In file included from /usr/include/c++/4.8/string:51:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from coroutine.cpp:2:
/usr/include/c++/4.8/bits/range_access.h:87:5: note: template<class _Tp, long unsigned int _Nm> _Tp*
std::begin(_Tp (&)[_Nm])
begin(_Tp (&__arr)[_Nm])
^
/usr/include/c++/4.8/bits/range_access.h:87:5: note: template argument deduction/substitution fail
ed:
coroutine.cpp:19:20: note: mismatched types ‘_Tp [_Nm]’ and ‘boost::coroutines::coroutine<int()>’
for ( auto i : c) cout << i << " ";
^
In file included from /usr/include/c++/4.8/string:51:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from coroutine.cpp:2:
/usr/include/c++/4.8/bits/range_access.h:58:5: note: template decltype (__cont.beg
in()) std::begin(const _Container&)
begin(const _Container& __cont) -> decltype(_cont.begin())
^
/usr/include/c++/4.8/bits/range_access.h:58:5: note: template argument deduction/substitution fail
ed:
/usr/include/c++/4.8/bits/range_access.h: In substitution of ‘template decltype (
_cont.begin()) std::begin(const _Container&) [with _Container = boost::coroutines::coroutine<int()>]
’:
coroutine.cpp:19:20: required from here
/usr/include/c++/4.8/bits/range_access.h:58:5: error: ‘const class boost::coroutines::coroutine<int(
)>’ has no member named ‘begin’
/usr/include/c++/4.8/bits/range_access.h:48:5: note: template decltype (__cont.beg
in()) std::begin(_Container&)
begin(_Container& __cont) -> decltype(_cont.begin())
^
/usr/include/c++/4.8/bits/range_access.h:48:5: note: template argument deduction/substitution fail
ed:
/usr/include/c++/4.8/bits/range_access.h: In substitution of ‘template decltype (
_cont.begin()) std::begin(_Container&) [with _Container = boost::coroutines::coroutine<int()>]’:
coroutine.cpp:19:20: required from here
/usr/include/c++/4.8/bits/range_access.h:48:5: error: ‘class boost::coroutines::coroutine<int()>’ ha
s no member named ‘begin’
coroutine.cpp:19:20: error: no matching function for call to ‘end(boost::coroutines::coroutine<int()