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
。
[编辑] 示例
本节不完整 原因:无示例 |