top | item 18335780

(no title)

paulhilbert | 7 years ago

So this is basically misusing the compiler as an impractial script interpreter?

discuss

order

gpm|7 years ago

I'm not sure if it counts as misuse, compile time evaluation is intended to be used to do computation at compile time. But "an impractical script interpreter" is certainly one way to view it.

gnulinux|7 years ago

It used to be a misuse (when metaprogramming was templates and then after the very first constexpr functions were introduced) since back then metaprogramming was intended to decide simple facts about the program and make inlining easier. But in this standard they actually made it so that pretty much all C++ stdlib can be constexpr and it is encouraged to "constexpr everything". So while this is not an abuse of C++ compiler, it's likely not a fantastic idea since C++ compilers tend to be slow.

Koshkin|7 years ago

> misusing

AKA hacking.