yieldの引数
以前「難しそう」と書いていましたが不便だったので、yield()の引数にtupleの要素をバラバラに渡せるようにしました。
coroutine_template.hppの差分
これで、
typedef coro::coroutine<std::pair<int,int>(int)> coroutine_type; std::pair<int,int> coro_body(coroutine_type::self& self, int n) { while (true) n = self.yield(std::make_pair(1, 2)); }
が
typedef coro::coroutine<std::pair<int,int>(int)> coroutine_type; std::pair<int,int> coro_body(coroutine_type::self& self, int n) { while (true) n = self.yield(1, 2); // ココ }
と書けるようになりました。
戻り値がstd::pairやboost::tupleの場合にタイプが楽になります。
実装はyield()の引数を戻り値型のコンストラクタに渡しているだけなので、タプルでなくてもなんでも使えます。
ただ、コードの意味が分かりにくくなるのでタプル以外には使わないほうがいいと思います。