vendredi 27 février 2015

Using lambda captured constexpr value as an array dimension

GCC and Clang do compile the following code:



void Test()
{
constexpr int Size = 3;
auto Lambda = [Size]{ int Dim[Size]; };
}


However, VisualStudio 2015 CTP 6 does not. Nevertheless, all 3 compilers are happy with this code:



void Test()
{
static constexpr int Size = 3;
auto Lambda = []{ int Dim[Size]; };
}


Which snippet is actually doing it in the correct way? What does the C++ standard say?


Aucun commentaire:

Enregistrer un commentaire