【发布时间】:2015-07-11 15:37:45
【问题描述】:
我正在尝试来自 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"
有人知道如何让它工作吗?
【问题讨论】:
-
那个链接说的是
requires an opt-in switch (/await) to use it.这个特性你有没有试过把它添加到编译器标志中? -
是的,我已经有了
/await开关。它只是在对话框的不同部分,所以它没有与其他开关一起复制。
标签: c++ yield visual-studio-2015