How to translate this C++ preprocessor declaration in D?

bearophile bearophileHUGS at lycos.com
Sat May 25 07:40:39 PDT 2013


Heinz:

> template makeId(char[4] id)
> {
> 	const makeId = id[0] << 24 | id[1] << 16 | id[2] << 8 | id[3];
> }
>
> const kPIHostBlendModeSignature = makeId!("8BIM");

Generally it's more descriptive to use enum (or even a CT 
function):

template makeId(char[4] id)
{
     enum makeId = (id[0] << 24) | (id[1] << 16) | (id[2] << 8) | 
id[3];
}

enum PIPowerPCCarbonCodeProperty = makeId!"ppcb";

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list