visual studio 2015 RC 访问冲突中的 C++ 可恢复函数(yield)

标签 c++ yield visual-studio-2015

我正在尝试来自此 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/

相关文章:

python - NoneType-Python 中的 Yield 错误

c++ - SetWindowSubclass 内的 msftedit.dll RichEdit 控件出现错误 "Access violation reading location 0x00000008"

c++ - 为什么析构函数默认不是虚拟的[C++]

c++ - 你不应该从 std::vector 继承

python - 如何让 yield 在 Debug模式下工作?

vb.net - Option Strict On 和 DBNull.Value

angularjs - 在 Visual Studio 2015 中将 TypeScript 编译成 Javascript

c++ - 编译错误 : undeclared identifier

c++ - 使用#include 将从终端读取的文件包含到函数中

Ruby:从内部 block 产生不起作用