4-character literal
torhu
fake at address.dude
Thu Jan 25 23:29:05 PST 2007
Rick Mann wrote:
> Rick Mann Wrote:
>
>> enum : uint
>> {
>> kSomeConstantValue = 'abcd'
>> }
>
>
> I realized I was misunderstanding something else I saw, and that "abcd"d doesn't do what I thought (make a 4-byte character).
>
> So: how to I do the equivalent of 'abcd'?
>
> Thanks!
Try this.
template MAKE_ID(char[] s)
{
static assert(s.length == 4);
const uint ID = (s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3];
}
enum : uint
{
kSomeConstantValue = MAKE_ID!("abcd")
}
More information about the Digitalmars-d
mailing list