This code compiles fine in gcc, but fail in Visual C++.
MCVE = https://wandbox.org/permlink/SqNI85EospSrwm5T
int main() {
auto func_do1Pass2=[&]() {
return 8;
};
constexpr int g=func_do1Pass2();
auto sLambda=[&]() {
constexpr int g2=func_do1Pass2(); //<== error at Visual C++
};
}
Error C2131 expression did not evaluate to a constant
-
Who is wrong? Why? Please give reference.
-
Here is my more real example. What is a workaround for the below code in Visual C++ case?
Code:
void testtt() {
auto func_do1Pass2=[&]<int s>() {
return 8;
};
[&]<int s2>() {
///vvv can edit only here
constexpr int g2=func_do1Pass2.operator()<s2>();
///^^^ can edit only here
}.operator()<2>();
}