Domanda

Why can constexpr not apply to constructors?

The following code cannot be compiled with VC++ 2013 CTP.

struct A
{
    constexpr A()
        : _n(5)
    {}

    int _n;
};

constexpr A f()
{
    return A();
}

int main()
{
    auto a = f();
}

error C3757: 'A': type not allowed for 'constexpr' function
È stato utile?

Soluzione

VC 2013 does not support all C++11 features yet. Look at MSDN list.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top