dimanche 27 septembre 2015

constexpr class in VC++14 (Visual Studio 2015) cannot be brace initalized

I came across an interesting anomaly today that only happens in VC++14 (constexpr is not supported in predecessors).

Here is a minimal example:

This compiles

struct constClass {
    constexpr constClass() = default;
};

static constexpr constClass cclass = constClass();

int main()
{ }

but this refuses to:

struct constClass {
    constexpr constClass() = default;
};

static constexpr constClass cclass = constClass{};
//                                              * only difference - uses {} instead of ()

int main()
{ }

Is this a bug that I should submit, or is there something that I don't know?

Both these code samples compile in GCC and Clang.

Aucun commentaire:

Enregistrer un commentaire