无法使用GCC 4.9编译constexpr成员函数

时间:2017-09-16 20:34:28

标签: c++ gcc

以下简单代码无法使用GCC 4.9和MSVC 2015进行编译:

struct A
{
    static constexpr size_t GetTextureCount()
    {
        return 5;
    }

    static constexpr size_t a = GetTextureCount();
};

GCC 4.9错误:'静态constexpr size_t ISparkleRenderer :: GetTextureCount()'以常量表达式调用

MSVC 2015错误C2131:表达式未评估为常量

为什么这段代码不能编译?可能我需要更高版本的编译器?

0 个答案:

没有答案