I\'m writing C++ code in an environment in which I don\'t have access to the C++ standard library, specifically not to std::numeric_limits
. Suppose I want to implem
Focusing on unsigned integral types, what do I put there? Specifically, is static_cast(-1) good enough
Yes, it is good enough.
But I prefer a hex value because my background is embedded systems, and I have always had to know the sizeof(T).
Even in desktop systems, we know the sizes of the following T:
uint8_t allones8 = 0xff;
uint16_t allones16 = 0xffff;
uint32_t allones32 = 0xffffffff;
uint64_t allones64 = 0xffffffffffffffff;