[Bug c++/95540] [coroutine] coroutine_traits<> lookup for lambdas
iains at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Jun 5 19:19:23 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95540
--- Comment #6 from Iain Sandoe <iains at gcc dot gnu.org> ---
(In reply to Michael Bruck from comment #5)
> > Since the coroutine traits are global, and the closure type is unique,
> > that provides a way to disambiguate instantiations of the traits for
> > lambdas with otherwise identical signatures.
>
> But the closure type is generated in the same lambda expression where the
> coroutine generator looks up the coroutine_traits<>. How do I specialize on
> that?
I wasn't meaning to suggest you can specialise per lambda (but I was saying
that the traits instantiated will be unique per lambda) - perhaps the latter is
an implementation detail.
Providing the class/callable object type to the traits look does allow
specialisations like ...
template<typename R, typename CallOp, typename ...T>
struct std::coroutine_traits<R, CallOp, T...> {
struct promise_type {
promise_type (CallOp op, T ...args) {}
Fake get_return_object() { return {}; }
std::suspend_always initial_suspend() { return {}; }
....
to be possible.
( I might be getting out of my depth with the long history of the design
evolution here - but this is my understanding of the rationale for the status
quo ).
More information about the Gcc-bugs
mailing list