From 8c6e7d8bf78b4950d5d7d38e48dc0ec8ceae0d22 Mon Sep 17 00:00:00 2001 From: q66 Date: Sat, 11 Mar 2017 14:51:34 +0100 Subject: [PATCH] add a generic way to get an yielder for a coroutine/generator --- ostd/coroutine.hh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ostd/coroutine.hh b/ostd/coroutine.hh index e775732..0b48215 100644 --- a/ostd/coroutine.hh +++ b/ostd/coroutine.hh @@ -567,6 +567,20 @@ inline void swap(generator &a, generator &b) { a.swap(b); } +namespace detail { + template + struct yield_type_base { + using type = typename generator::yield_type; + }; + template + struct yield_type_base { + using type = typename coroutine::yield_type; + }; +} + +template +using yield_type = typename detail::yield_type_base::type; + template struct generator_range: input_range> { using range_category = input_range_tag;