【问题标题】:Why does VC++ 2013 not support non-static data member initializers as promised为什么 VC++ 2013 不支持承诺的非静态数据成员初始化器
【发布时间】:2013-09-17 14:53:06
【问题描述】:

根据C++11 Features (Modern C++),VC++ 2013 现在支持非静态数据成员初始化器。

但是,以下代码被 VC++ 2013 拒绝:

struct A
{
    const int n = 0; // error C2864
};

错误 C2864: 'A::n' : 只有静态 const 整数数据成员才能在类中初始化

根本原因是什么?是编译器的bug吗?

【问题讨论】:

  • 我认为这意味着实际发布。 This 说 RTM。
  • "你试过 LLVM 吗?"
  • @chris:在链接的顶部它写着The following table lists C++11 core language features and their implementation status in..Visual C++ in Visual Studio 2013 Preview,所以它看起来像一个文档错误。

标签: c++ visual-c++ c++11 compiler-errors language-features


【解决方案1】:

根本原因是什么?是编译器的bug吗?

这是一个文档错误,here 和 chris 在评论中的链接都说非静态数据成员初始化器将在 VS2013 RTM 中实现。

当您在 MSDN 上发现虚假信息时不要感到惊讶,有很多旧资料等没有人更新或输入错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-08
    • 2011-08-04
    相关资源
    最近更新 更多