3 ms·
I may not know modern C++ well enough, but I would think that, if you go through a translation unit, discarding everything ”not constexpr”, the result should co
by Someone 7y ago
I may not know modern C++ well enough, but I would think that, if you go through a translation unit, discarding everything ”not constexpr”, the result should compile to an object file without any code.
Repeat compilation (conceptually, the implementation might be more efficient), replacing anything ”constexpr” by what you got earlier, and you’re done.
Or am I overlooking something?
- bigcheesegs 7y agoconstexpr functions aren't restricted to compile time, they can also be used at runtime. Thus constexpr functions can show up in the final executable. Constexpr functions can also control what gets compiled in the first place. For example you can use the result of a constexpr evaluation to instantiate a template.