5
constexpr void X() {
  /* code, that can be executed at compiletime */
}

void X() {
  /* code, that does the same as above, but is optimized for runtime, eg.
  including caching, assembler code, ... to optimize runtime performance */
}

As demostrated above, I want two functions, both basically doing the same thing, one optimized for runtime, one for compile-time. In my example, the runtime version involves caching, which cannot be done in constexpr, but could improve performance at runtime.

Can this be achieved somehow (using C++14)?

If this can only be achieved using compiler-specific solutions, they're ok too, but I would prefer a standard solution (currently, I am unaware of one)

  • This has been being asked for a long time, unfortunately the standard doesn't give any good way to do this (as far as I know). Hopefully http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1045r0.html will get into the standard in the near future. – geza Mar 16 '19 at 11:38

0 Answers0