Files
cppdraft_translate/cppdraft/coroutine/noop.md
2025-10-25 03:02:53 +03:00

6.2 KiB
Raw Blame History

[coroutine.noop]

17 Language support library [support]

17.13 Coroutines [support.coroutine]

17.13.5 No-op coroutines [coroutine.noop]

17.13.5.1 Class noop_coroutine_promise [coroutine.promise.noop]

🔗

struct noop_coroutine_promise {};

1

#

The class noop_coroutine_promise defines the promise type for the coroutine referred to by noop_coroutine_handle ([coroutine.syn]).

17.13.5.2 Class coroutine_handle<noop_coroutine_promise> [coroutine.handle.noop]

17.13.5.2.1 General [coroutine.handle.noop.general]

🔗

namespace std {template<>struct coroutine_handle<noop_coroutine_promise>{// [coroutine.handle.noop.conv], conversionconstexpr operator coroutine_handle<>() const noexcept; // [coroutine.handle.noop.observers], observersconstexpr explicit operator bool() const noexcept; constexpr bool done() const noexcept; // [coroutine.handle.noop.resumption], resumptionconstexpr void operator()() const noexcept; constexpr void resume() const noexcept; constexpr void destroy() const noexcept; // [coroutine.handle.noop.promise], promise access noop_coroutine_promise& promise() const noexcept; // [coroutine.handle.noop.address], addressconstexpr void* address() const noexcept; private: coroutine_handle(unspecified); void* ptr; // exposition only};}

17.13.5.2.2 Conversion [coroutine.handle.noop.conv]

🔗

constexpr operator coroutine_handle<>() const noexcept;

1

#

Effects: Equivalent to: return coroutine_handle<>::from_address(address());

17.13.5.2.3 Observers [coroutine.handle.noop.observers]

🔗

constexpr explicit operator bool() const noexcept;

1

#

Returns: true.

🔗

constexpr bool done() const noexcept;

2

#

Returns: false.

17.13.5.2.4 Resumption [coroutine.handle.noop.resumption]

🔗

constexpr void operator()() const noexcept; constexpr void resume() const noexcept; constexpr void destroy() const noexcept;

1

#

Effects: None.

2

#

Remarks: If noop_coroutine_handle is converted to coroutine_handle<>, calls to operator(), resume and destroy on that handle will also have no observable effects.

17.13.5.2.5 Promise access [coroutine.handle.noop.promise]

🔗

noop_coroutine_promise& promise() const noexcept;

1

#

Returns: A reference to the promise object associated with this coroutine handle.

17.13.5.2.6 Address [coroutine.handle.noop.address]

🔗

constexpr void* address() const noexcept;

1

#

Returns: ptr.

2

#

Remarks: A noop_coroutine_handle's ptr is always a non-null pointer value.

17.13.5.3 Function noop_coroutine [coroutine.noop.coroutine]

🔗

noop_coroutine_handle noop_coroutine() noexcept;

1

#

Returns: A handle to a coroutine that has no observable effects when resumed or destroyed.

2

#

Remarks: A handle returned from noop_coroutine may or may not compare equal to a handle returned from another invocation of noop_coroutine.