std::execution::just_error
定義於標頭檔案 <execution> |
||
inline constexpr just_error_t just_error{}; struct just_error_t { /*unspecified*/ }; |
(C++26 起) (定製點物件) |
|
呼叫簽名 (Call signature) |
||
execution::sender auto just_error( auto&& error ); |
(C++26 起) | |
一個 sender 工廠,它返回一個 sender,該 sender 透過呼叫 receiver 的 set_error()
立即完成。
令 e 為一個子表示式,它表示一個將被注入並由 receiver 返回的輸入錯誤。表示式 just_error(e) 表示式等價於 /*make-sender*/(just_error, /*product-type*/(e))
自定義點物件
名稱 execution::just_error
表示一個自定義點物件,它是一個 const 函式物件,屬於 字面量 semiregular
類型別。其 cv-unqualified 版本是一種標籤型別,表示為 execution::just_error_t
。
execution::just_error_t
的所有例項均相等。在相同引數上呼叫型別 execution::just_error_t
的不同例項的效果是等價的,無論表示該例項的表示式是左值還是右值,以及是否為 const 限定(但是,volatile 限定的例項不要求可呼叫)。因此,execution::just_error
可以自由複製,並且其副本可以互換使用。
給定一組型別 Args...
,如果 std::declval<Args>()... 滿足上述 execution::just_error
的引數要求,則 execution::just_error_t
滿足
- std::invocable<execution::just_error_t, Args...>,
- std::invocable<const execution::just_error_t, Args...>,
- std::invocable<execution::just_error_t&, Args...>,以及
- std::invocable<const execution::just_error_t&, Args...>.
否則,execution::just_error_t
的任何函式呼叫運算子都不參與過載決議。
[編輯] 注意
如果提供的錯誤是左值引用,則在返回的 sender 內部會進行一次複製,並將該複製的非 const 左值引用傳送到 receiver 的 set_error。如果提供的值是右值引用,它將被移動到返回的 sender 中,並將其右值引用傳送到 receiver 的 set_error
。
[編輯] 示例
本節不完整 原因:無示例 |