c++协程3 (boost::coroutine)

#include <tuple>
#include <string>
#include <iostream>
#include <boost/coroutine/all.hpp>


using boost::coroutines::coroutine;

void cooperative(coroutine<std::tuple<int, std::string>>::pull_type &source)
{
	auto args = source.get();
	std::cout << std::get<0>(args) << " " << std::get<1>(args) << '\n';

	source();

	args = source.get();
	std::cout << std::get<0>(args) << " " << std::get<1>(args) << '\n';
}

int main()
{
	coroutine<std::tuple<int, std::string>>::push_type sink{ cooperative };

	//经过tuple传递多个参数
	sink(std::make_tuple(0, "aaa"));

	//经过tuple传递多个参数
	sink(std::make_tuple(1, "bbb"));

	std::cout << "end\n";
}