Skip to content

Instantly share code, notes, and snippets.

@argv0
Created October 18, 2013 09:23
Show Gist options
  • Save argv0/7038937 to your computer and use it in GitHub Desktop.
Save argv0/7038937 to your computer and use it in GitHub Desktop.
#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;
@jrwren
Copy link

jrwren commented Oct 18, 2013

++ -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()

&)’
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:99:5: note: template constexpr const _Tp* std::end(
std::initializer_list<_Tp>)
end(initializer_list<_Tp> __ils) noexcept
^
/usr/include/c++/4.8/initializer_list:99: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:97:5: note: template<class _Tp, long unsigned int _Nm> _Tp*
std::end(_Tp (&)[_Nm])
end(_Tp (&__arr)[_Nm])
^
/usr/include/c++/4.8/bits/range_access.h:97: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:78:5: note: template decltype (__cont.end
()) std::end(const _Container&)
end(const _Container& __cont) -> decltype(_cont.end())
^
/usr/include/c++/4.8/bits/range_access.h:78:5: note: template argument deduction/substitution fail
ed:
/usr/include/c++/4.8/bits/range_access.h: In substitution of ‘template decltype (

_cont.end()) std::end(const _Container&) [with _Container = boost::coroutines::coroutine<int()>]’:
coroutine.cpp:19:20: required from here
/usr/include/c++/4.8/bits/range_access.h:78:5: error: ‘const class boost::coroutines::coroutine<int(
)>’ has no member named ‘end’
/usr/include/c++/4.8/bits/range_access.h:68:5: note: template decltype (__cont.end
()) std::end(_Container&)
end(_Container& __cont) -> decltype(_cont.end())
^
/usr/include/c++/4.8/bits/range_access.h:68:5: note: template argument deduction/substitution fail
ed:
/usr/include/c++/4.8/bits/range_access.h: In substitution of ‘template decltype (

_cont.end()) std::end(_Container&) [with _Container = boost::coroutines::coroutine<int()>]’:
coroutine.cpp:19:20: required from here
/usr/include/c++/4.8/bits/range_access.h:68:5: error: ‘class boost::coroutines::coroutine<int()>’ ha
s no member named ‘end’
make: *** [coroutine] Error 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment