constexpr auto v = static_cast<std::uint64_t>(1) << 32;
is not ideal, because of the tedious syntax and the cast which is semantically indirect. From this thread, I learned constexpr auto v = UINT64_C(1) << 32;
However, the precise semantics of the macro is
expands to an integer constant expression having the value specified by its argument and the type
uint_least64_t
.
Therefore, it's not exactly uint64_t
. I'm wondering what is the best/proper way to define uint64_t
constants.
Note that unsigned long long
doesn’t necessarily map to uint64_t
.
Update
I'm reluctant to use functional/C-style cast, because some (e.g., Google C++ Coding Style) say it's from C, and modern C++ should avoid using them. Looks like I should have my own opinion on this, instead of blindly following others.