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.
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