template<typename coroutine>
struct test
{
using pull_type = typename coroutine::pull_type;
using push_type = typename coroutine::push_type;
pull_type * child = nullptr;
void start_child_coroutine()
{
child = new pull_type
(
[](push_type & yield)
{
std::cout << "2";
yield();
std::cout << "2";
}
);
}
pull_type start_parent_coroutine()
{
return pull_type
(
[this](push_type & yield)
{
std::cout << "1";
start_child_coroutine();
yield(); // comment this to see crash on assert in Boost.Coroutine2
std::cout << "1";
}
);
}
test()
{
auto parent = start_parent_coroutine();
(*child)();
std::cout << std::endl;
}
};
int main()
{
std::cout << "When using Boost.Coroutine result is ";
test<boost::coroutines::coroutine<void>> t1;
std::cout << "When using Boost.Coroutine2 result is ";
test<boost::coroutines2::coroutine<void>> t2;
}