gpt4 book ai didi

c++ - constexpr 未在 VC2013 中编译

转载 作者:IT老高 更新时间:2023-10-28 14:00:25 26 4
gpt4 key购买 nike

此 constexpr 代码未在 Visual Studio 2013 版本 12.0.21005.1 REL 中编译

是否有更新的 Visual Studio 编译器可以与 constexpr 一起使用?

#include <iostream>

constexpr int factorial(int n)
{
return n <= 1 ? 1 : (n * factorial(n - 1));
}

int main(void)
{
const int fact_three = factorial(3);
std::cout << fact_three << std::endl;
return 0;
}

编译输出:

    1>------ Build started: Project: Project1, Configuration: Debug Win32 ------    1>  Source.cpp    1>....\source.cpp(3): error C2144: syntax error : 'int' should be preceded by ';'    1>....\source.cpp(3): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Herb Sutter 在他的博客上提到了 constexpr,但不清楚它在哪个版本中起作用/将起作用? http://herbsutter.com/2013/09/09/visual-studio-2013-rc-is-now-available/#comment-13521

最佳答案

Microsoft 发布了一个 C++11 兼容性表,其中 constexprclearly marked as not being available in Visual Studio 2013 .

The November 2013 CTP不过有。

来源:谷歌visual studio constexpr

关于c++ - constexpr 未在 VC2013 中编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20264644/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com