`DUNE_THROW` fails when used within `constexpr` function

Used within constexpr function, DUNE_THROW does not compile.

// throw with std exception
constexpr bool testThrow(bool a)
{
  if (a)
  {
    return true;
  }
  else
  {
    DUNE_THROW(Dune::NotImplemented, "testThrow");
  }
}

I assume this due to the definition of DUNE_THROW which explicitly creates an exception object which fails because no constexpr constructor is found.

  1. Can we fix this?
  2. Do we need to overhaul Dune's exception infrastructure? One example could be https://stackoverflow.com/questions/348833/how-to-know-the-exact-line-of-code-where-where-an-exception-has-been-caused/348862#348862
  3. Is there any C++ standard way in sight? C++20 or similar?

By the way, this is no academic example, but real-world from DuMuX' material laws and geometry helpers.

Edited by Christoph Grüninger