admin管理员组文章数量:1356067
In GCC 15, std::noop_coroutine
's definition is
{ return std::noop_coroutine_handle(); }
std::noop_coroutine_handle
is defined by:
using noop_coroutine_handle = std::coroutine_handle<std::noop_coroutine_promise>;
To get a no-op coroutine, we write
std::noop_coroutine()
which (I guess) is equivalent to
std::noop_coroutine_handle{}
and
std::coroutine_handle<std::noop_coroutine_promise>{}
So I believe the standard library only needs to provide std::noop_coroutine_promise
(along with certain specializations that use it as a template parameter).
Why did the standard introduce three new symbols? (Feels a bit arbitrary—just my personal opinion.)
In GCC 15, std::noop_coroutine
's definition is
{ return std::noop_coroutine_handle(); }
std::noop_coroutine_handle
is defined by:
using noop_coroutine_handle = std::coroutine_handle<std::noop_coroutine_promise>;
To get a no-op coroutine, we write
std::noop_coroutine()
which (I guess) is equivalent to
std::noop_coroutine_handle{}
and
std::coroutine_handle<std::noop_coroutine_promise>{}
So I believe the standard library only needs to provide std::noop_coroutine_promise
(along with certain specializations that use it as a template parameter).
Why did the standard introduce three new symbols? (Feels a bit arbitrary—just my personal opinion.)
Share Improve this question edited Mar 28 at 8:50 shynur asked Mar 28 at 5:33 shynurshynur 5122 silver badges11 bronze badges 4 |1 Answer
Reset to default 3Why did the standard introduce three new symbols?
Because it can. Defining a particular name in the standard, vs leaving it implementation-defined, only really affects the formatting used to describe it.
The standard still has to describe the behaviour of the promise type.
Implementers would have to use some name to define the promise type for noop_coroutine
, and the handle type could be written out longhand, but most likely would have an alias.
本文标签: cAre stdnoopcoroutine and noopcoroutinehandle redundantStack Overflow
版权声明:本文标题:c++ - Are `std::noop_coroutine` and `noop_coroutine_handle` redundant? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744054731a2583056.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
mt19937_64
even though we can just plug the canonical values intomersenne_twister_engine
- ergonomics – StoryTeller - Unslander Monica Commented Mar 28 at 5:53std::noop_coroutine
might be good enough as well, since we can usestd::noop_coroutine()
to refer tostd::noop_coroutine_handle{}
and so on. – shynur Commented Mar 28 at 6:08std
? It's a namespace. It is reserved for the standard. All the names there are up for grabs. – Caleth Commented Mar 28 at 9:28