On Monday, 31 July 2017 at 07:16:25 UTC, Cecil Ward wrote:
Say I have used Typedef! to create some new type and I declare
a variable, constant or enum of that type. Is there a way that
I can express a literal value on the rhs without having to use
casts, as that seems to defeat the point of the nice type
safety?
I may be asking for the impossible or _illogical_ here. In any
case, I still get to keep the nice feature of not being able to
mix up types with assignment from one variable to another.
Specific example is
mac_addr_48_t my_mac_address = 0x112233445566uL;
Which now produces a compile time error after I changed to use
an alias = Typedef!uint64_t as opposed to just a straight
alias = uint64_t earlier with no strong typing.
If struct + alias this is not strong enough the only solution is
see is a helper template à la "octal" or "hexString", i.e a
static cally checked string.