In a piece of code, there is a type defined as a uint_fast16_t
. Specifically:
typedef uint_fast16_t loc_t;
//And in stdint.h:
typedef unsigned long int uint_fast16_t;
Unfortunately with fast types, the "name" is part of the contract. In that a programmer must be cognisant that the type might be wider than 16 bits, but in usage should treat it as if the valid range is the same as a uint16_t.
I wish to write a static assert that asserts this contract is still valid for loc_t
. In other words "has this type changed in a way that suggest values outside of uint16_t's range are valid?" which translates to "has the assigned name of this type changed?".
In other words, is there some way to write a static assert such as the following?
//not good, since uint_fast_16_t is typedef'd as uint64_t, so the type of loc_t could change to uint_fast64_t and this would pass.
static_assert(std::is_same<loc_t, uint_fast16_t>::value, "");
//What I would actually need
static_assert(std::is_same<nameoftype(loc_t), name(uint_fast16_t)>::value, "");