所有 C++ 编译器都支持 async/await 关键字吗?
Do all C++ compilers support the async/await keywords?
我想在 C++(UE4 框架)中使用 async/await
语法,但由于跨平台代码,我不确定这是否可能...或者可能?如果可以,我该如何使用?
还有 await
和 __await
(resumable
、yield
和 __yield_value
)关键字在 Visual Studio 中突出显示。有什么区别?可能不是所有的编译器都支持这个关键字或者单独支持?
gcc
、clang
都接受了吗?或者不接受,我可以单独为每个平台使用宏。
async
和await
是微软提出的语言扩展,经过多次修改,但目前是N4134。这尚未被纳入标准。
该提议遭到许多人的反对,例如 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0158r0.html due to not being completely baked and having not been explored fully in a TS and there's competing proposals like N3985 提议可以在现有语言标准中实现的协程。
据我所知,唯一真正支持 async/await 的编译器是 MS Visual Studio。
作为更新,clang 5.0 支持当前的协同例程提案草案 https://isocpp.org/files/papers/N4663.pdf,该提案现已被接受为 TS,并着眼于 C++20 标准。
我想在 C++(UE4 框架)中使用 async/await
语法,但由于跨平台代码,我不确定这是否可能...或者可能?如果可以,我该如何使用?
还有 await
和 __await
(resumable
、yield
和 __yield_value
)关键字在 Visual Studio 中突出显示。有什么区别?可能不是所有的编译器都支持这个关键字或者单独支持?
gcc
、clang
都接受了吗?或者不接受,我可以单独为每个平台使用宏。
async
和await
是微软提出的语言扩展,经过多次修改,但目前是N4134。这尚未被纳入标准。
该提议遭到许多人的反对,例如 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0158r0.html due to not being completely baked and having not been explored fully in a TS and there's competing proposals like N3985 提议可以在现有语言标准中实现的协程。
据我所知,唯一真正支持 async/await 的编译器是 MS Visual Studio。
作为更新,clang 5.0 支持当前的协同例程提案草案 https://isocpp.org/files/papers/N4663.pdf,该提案现已被接受为 TS,并着眼于 C++20 标准。