#include <iostream>
#include <string>
#include <stdexcept>

void foo()
{
  auto func = [] (std::string msg) [[noreturn]] { throw std::runtime_error(msg); };
  return func("Test Message");
}

int main()
{
   try 
   {
      foo();
   }
   catch (...)
   {
      std::cout << "Caught the exception.\n";
   }
}
