constexpr不编译在VC2013 [英] constexpr not compiling in VC2013

查看:1051
本文介绍了constexpr不编译在VC2013的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个constexpr代码没有编译在Visual Studio 2013版本12.0.21005.1 REL

This constexpr code does not compiled in Visual Studio 2013 version 12.0.21005.1 REL

有没有更新的Visual Studio编译器与constexpr?

Is there a newer Visual Studio compiler that works with 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;
}



从编译输出:

output from compilation:

    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

Herb Sutter mentions constexpr on his blog but is unclear in what version it works / will work? http://herbsutter.com/2013/09/09/visual-studio-2013-rc-is-now-available/#comment-13521

推荐答案

Microsoft发布了一个C ++ 11兼容性表,其中 constexpr 清楚标记为在Visual Studio 2013中不可用

Microsoft publishes a C++11 compatibility table, under which constexpr is clearly marked as not being available in Visual Studio 2013.

2013年11月CTP 有它。

: Google visual studio constexpr

Source: Google visual studio constexpr

这篇关于constexpr不编译在VC2013的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆