15 ms·
If one wishes to be pedantic, constexpr is a C++-like language for generating C++ values at compile time and templates are a quite different language for doing
by anonymoushn 4y ago
If one wishes to be pedantic, constexpr is a C++-like language for generating C++ values at compile time and templates are a quite different language for doing the same thing (and some other things). The pitch of the comptime feature is that you can do all of the things you would do with templates and constexpr (and more things due to some limitations being relaxed and type introspection existing) in the language that is similar to the language you use for runtime code. You don't have to do anything in a weird metalanguage.
- gpderetta 4y agoC++ has been trying to get compile time introspection and synthesis into the language for a while. There is a proposal going slowly through standardization, but it is not yet know when it will be ready (I believe it missed 2 or more release trains already). Circle, mentioned elsewhere, is a C++ dialect with fully working compile time metaprogramming.
- rurban 4y agoC++ has only half of a fully working compile time metaprogramming. constexpr are limited, consteval, would be the full part, but is usually an error. And the error handling is even only 10% working. clang is fine, gcc is broken for years.