无法创建静态constexpr

时间:2016-07-18 23:03:35

标签: c++ c++11 constexpr

我有以下代码:

struct Literal
{
    int val;
    constexpr Literal(int const& val) : val(val) {}
    constexpr Literal(Literal const& rhs) : val(rhs.val) {}
};


struct Parent
{
    struct StaticObject
    {
        Literal const zero;

        constexpr StaticObject() :zero(0) {}
    };
    static constexpr StaticObject outer{};
};

行' static constexpr StaticObject outer {};'给了我错误:

  

'表达式未评估为常量'

接下来是

  

注意:失败是由调用未定义的函数或未声明的函数引起的' constexpr'

     

注意:请参阅' Parent :: StaticObject :: StaticObject'

的用法

据我所知,这里使用的所有函数都是定义和声明的constexpr。我错过了什么,或者这是编译器错误?

0 个答案:

没有答案