Subject: Re: [std-proposals] Delay the judgement for coroutine function after the instantiation of template entity.
From: Arthur O'Dwyer (arthur.j.odwyer_at_[hidden])
Date: 2021-01-20 10:12:11
On Wed, Jan 20, 2021 at 9:21 AM Omry Noam via Std-Proposals <
> What if we specialized a function template templated on bool, to have one
> version that's a coroutine, and one version that's a normal function?
> Maybe something like: https://godbolt.org/z/7TEnb6
> (Code adapted from cppreference as an example)
I believe that's well-formed, but I'm pretty sure OP's main goal is to *avoid
writing the code twice*.
I do agree that it would be useful if Chuanqi provided a more fleshed-out
and realistic example. When the body of the function is only one line, it's
easy to say "just write it twice." If the function were more complicated,
it would be more obvious why "write everything twice" wouldn't be an
But I personally can't come up with such an example off the top of my head;
I'm not good enough at coroutine stuff.
STD-PROPOSALS list run by firstname.lastname@example.org
Standard Proposals Archives on Google Groups