我正在尝试来自此 MSDN link 的 Visual Studio 2015 RC 中可恢复函数的代码示例.
#include<iostream>
#include<experimental/generator>
auto hello()
{
for (auto ch : "Hello, world\n")
yield ch;
}
int main()
{
for (auto ch : hello())
std::cout << ch;
}
到目前为止,无论我的编译器设置如何,代码在运行时都会导致访问冲突异常。
这是我的编译器标志:
/Yu"stdafx.h" /GS- /W3 /Zc:wchar_t /ZI /Gm /Od /sdl- /Fd"x64\Debug\vc140.pdb" /Zc:inline /fp:precise /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /Gd /MDd /Fa"x64\Debug\" /EHsc /nologo /Fo"x64\Debug\" /Fp"x64\Debug\Test.pch"
有人知道如何让它工作吗?
最佳答案
我从对原始 MSDN link 的评论中得到回复.问题在于 /ZI
标志(用于编辑和继续的程序数据库)尚不受支持。切换到 /Zi
有效。
关于visual studio 2015 RC 访问冲突中的 C++ 可恢复函数(yield),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29993070/