, ++ . ++ ++ . ( , , , , , : " " ".
constexpr
, , , .
There are zero basic C ++ compilers that are called new types at runtime. So, we have the ability to force something to run at compile time; atC ++ 14 we have template constants:
template<uint32_t v>
std::integral_constant< uint32_t, v > kint32{};
With this we can do:
uniformByNameCRC32(kint32<ctcrc32("uPointLight.position")>);
should execute ctcrc32
at compile time. Not doing this will require a lot of compiler work.
AT C ++ 17 you can even do:
template<auto x>
std::integral_constant< std::decay_t<decltype(x)>, x > k{};
and it works for any type.
std::integral_constant
in turn, implicitly converts back to a value of the same type.
source
share