gpt4 book ai didi

c++ - C++中的 "suspension context of a function"是什么

转载 作者:行者123 更新时间:2023-11-30 05:21:44 26 4
gpt4 key购买 nike

Gor Nishanov、Jens Maurer、Richard Smith 和 Daveed Vandevoorde 的“协程措辞”(文档 C++ P0057R5),参见 P0057r5 , 讲了很多“函数的暂停上下文”,直指“5.3.8”

这是在哪里定义的?

我问是因为,对于一个过程,有时某些代码是或应该被要求在或不在某些地方。就像 Notify(我认为是)一样,在 Java 中应该被要求作为最后一条语句(Per Brinch Hansen(1999 年撰写的“Java 的不安全并行性”)。请问一个函数的suspend context是不是在这样的地方?

最佳答案

正是在论文中定义它的地方:

An await-expression shall appear only in a potentially-evaluated expression within the compound-statement of a function-body outside of a handler (15). In a declaration-statement or in the simple-declaration (if any) of a for-init-statement, an await-expression shall appear only in an initializer of that declaration-statement or simple-declaration. An await-expression shall not appear in a default argument (8.3.6). A context within a function where an await-expression can appear is called a suspension context of the function.

关于c++ - C++中的 "suspension context of a function"是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39966852/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com