0

There are exist question with similar question. But my question in another aspect.

My question about constexpr in c++ in general. I think that there must be requirement for the compilers, that any expression/statement/etc that could be done in compile time - is must be done in compile time. The compiler better know which things it could make during compilation.

Instead committee pull compiler-specific things to the user space. I think it is mistake.

Is exist some reasons to manage manually the compiler from the user code?

AeroSun
  • 2,401
  • 2
  • 23
  • 46
  • also https://stackoverflow.com/q/39795170/103167 – Ben Voigt Jul 20 '19 at 15:39
  • If you do much template code you'll likely use it every day. I do at least. It's needed for SFINAE and constexpr if (which is sort of like more readable SFINAE) – Cruz Jean Jul 20 '19 at 17:49
  • @Cruz Jean, my point, that [constexpr if] is redundant - if your expression could be done during compilation - it _must_ be done during compilation. Do you know some cases where compiler cant made such optimization? – AeroSun Jul 20 '19 at 18:51
  • @AeroSun The branch not taken in a constexpr if is not compiled. period. thus it is allowed to contain things that would otherwise be compile errors, such as using `T::S` where no such `S` exists within `T`. That couldn't be done with a normal if, since both branches of an if must be valid (regardless of whether one of them can be optimized away). – Cruz Jean Jul 22 '19 at 02:11

0 Answers0