jbaldwin/libcoro

coro::task<T> expects T to be default-constructible even if the default constructor is never used

LordTermor opened this issue · 2 comments

I don't know if it's intended and couldn't find any discussion regarding this.

struct A {
    A(int bar) {} //no default constructor
};

coro::task<A> foo() {
    co_return A(2);
} // doesn't compile

Seems the promise type needs default-constructed m_return_value.

held_type m_return_value;

Hey @LordTermor, thanks for reporting this problem, this is indeed a bug. I've pushed a PR which addresses the issue and adds a test to verify that the code you submitted compiles. Can you please take a look and try it out? Thanks.

Hey. Thank you! Works flawlessly on my side.