Namespaces
Variants

std::execution:: let_value

From cppreference.net
定义于头文件 <execution>
execution :: sender auto

let_value ( execution :: sender auto input,

std:: invocable < /*values-sent-by*/ ( input ) ... > function ) ;
(C++26 起)

参数

input - 输入发送器,执行后传递函数运行所需的数值
function - 可调用对象,将使用输入发送器的数值进行调用

返回值

返回一个描述输入发送方所描述任务图的发送方,其中增加了一个节点,该节点会调用提供的函数并以输入发送方发送的值作为参数。

let_value then 类似,但区别在于:从 then 返回的发送器会直接发送该函数最终返回的值——而 let_value 要求该函数返回一个发送器,且由 let_value 返回的发送器会转发由回调函数返回的发送器所发送的值。

示例