Given the following code
#include <type_traits>
int main ()
{
std::integral_constant<int, 42> ic;
[&]{ constexpr int i = ic; (void)i; }();
}
(the (void)i;
is just to avoid a "unused variable" warning) clang++ compile without problem where g++ gives the following error
prog.cc: In lambda function:
prog.cc:7:27: error: '__closure' is not a constant expression
7 | [&]{ constexpr int i = ic; (void)i; }();
| ^~
Capturing by value
[=]{ constexpr int i = ic; (void)i; }();
both compilers compile without problem.
The question, as usual, is: who's right? g++ or clang++?
Aucun commentaire:
Enregistrer un commentaire