当多次调用时,"std::future::then"的行为是什么?
What is the behaviour of `std::future::then` when called more than once?
根据并发 TS,下面的代码应该发生什么?
auto f0 = std::async([]{return 0;});
auto f1 = f0.then([](auto& f){ return f.get() + 10; });
auto f2 = f0.then([](auto& f){ if(!f.valid()) return; return f.get() + 10;});
当执行第三行代码时,f0
已经有了延续,所以,根据 TS,f0
应该抛出异常、中止程序、UB 还是具有不同的行为?我不清楚。
根据 cpp 首选项,它是未定义的:
将延续函数附加到
*this
。如果*this
没有关联的共享状态(即valid() == false
(,则行为是未定义的。。
此函数返回后,
valid()
false
。
相关文章:
- C++中 if-then-else 块的首选顺序
- 'char (*RtlpNumberOf(T (&)[N]))[N]':无法从"char *"
- 当多次调用时,"std::future::then"的行为是什么?
- Arduino IDE 错误 - 无法找到数字文字运算符"运算符""f900ff"
- "inline"、"constexpr"或"noexcept"
- "非静态数据成员之前需要构造函数" - 我是否使用"boost::variant"
- 我必须安装"libbitcoin-server"才能包含"bitcoin.hpp"
- 如何在 C++ 中使用 if-then 语句正确计算用户输入
- boost::future .then() 继续返回 boost::future
- “并非所有控制路径都返回一个值./&quot“控制可能达到非空隙功能的末端”.验证时循环时
- 如何输出a'&quot在不使用线端的情况下进行文件
- LLVM IRBuilder If-Then Codegen
- 删除“按任何键” ..&quot.从VS C 控制台应用程序
- 如何检测我何时向可变参数函数传递"std::string"而不是"c_str()"
- 条件运算符vs if then else
- 你如何为游戏游艇编写"if - then"逻辑?
- 使用 if/then 语句解析 C++ 中的 argv[ ] 选项
- '<'''<'''&quot的模板类错误''令牌”
- C++/Cx,可以使用String而不是IAsyncAction调用CreateTask().then
- 使用 boost::future .then() 时出现编译错误