Specify rhs at initialisation or assignment of typedef' d variable
Stefan Koch via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jul 31 04:33:15 PDT 2017
On Monday, 31 July 2017 at 08:53:10 UTC, Cecil Ward wrote:
> [ ... ]
> I suspect that I am asking for something that literally makes
> no sense at all. I wanted to try and avoid opening the door to
> allowing the following kind of typing error now, eg
> enum ip_address = 0x11223344;
> [ ... ]
Please have a look at the bigEndian function and BigEndian struct
in SQLite-D
https://github.com/UplinkCoder/sqlite-d/blob/master/source/utils.d
The point here is writing your own struct and using alias-this
yourself.
Then you only need a function to produce constants of the right
type.
Such a function should be trivially CTFEable
More information about the Digitalmars-d-learn
mailing list