1

While trying to do the compile example from:

https://learn.microsoft.com/en-us/cpp/cpp/lambda-expressions-in-cpp?view=vs-2019#exception-specification

using Visual studio 2012

[]() noexcept { throw 5; }();

I have got the following error:

expected a '{' introducing a lambda body

JeJo
  • 30,635
  • 6
  • 49
  • 88
Kiran Thilak
  • 443
  • 5
  • 15

1 Answers1

1

The noexcept has been introduced in , but the MSVS2015 onwards only(unfortunately) one can use this feature. Meaning, you need to upgrade to MSVS2015 and set the compiler flag C++11 or C++14 to compile this code.

JeJo
  • 30,635
  • 6
  • 49
  • 88