Do all C++ compilers support the async/await keywords?

女生的网名这么多〃 提交于 2019-12-21 03:47:09

问题


I want to use async/await syntax in C++ (UE4 framework), but due to cross-platform code I not sure that is possible... Or possible? If yes, how can I use it?

And also there are await and __await (resumable, yield and __yield_value also) keywords that highlighted in Visual Studio. What's difference? Maybe not all compilers supports this keywords or supports separately?

gcc, clang are accepts it? Or not accepts and I can just use macros for each platform individually.


回答1:


async and await are language extensions proposed by Microsoft with several revisions, but current is N4134. This has not yet accepted into the standard.

The proposal is opposed by many like 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 which proposes coroutines that can be implemented within the existing language standard.

To my knowledge, the only compiler that actually supports async/await is MS Visual Studio.

As an update, clang 5.0 has support for the current draft co-routines proposal https://isocpp.org/files/papers/N4663.pdf which has now been accepted as a TS and is progressing with an eye toward the C++20 standard.



来源:https://stackoverflow.com/questions/39106863/do-all-c-compilers-support-the-async-await-keywords

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!