Specify rhs at initialisation or assignment of typedef' d variable

Cecil Ward via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jul 31 00:16:25 PDT 2017


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.


More information about the Digitalmars-d-learn mailing list