CTFE implementation
Jarrett Billingsley
kb3ctd2 at yahoo.com
Fri Feb 8 11:28:11 PST 2008
"Frank Benoit" <keinfarbton at googlemail.com> wrote in message
news:foi6sn$1kb4$1 at digitalmars.com...
> Does someone have a solution for this?
private template IIDFromString(char[] str)
{
static assert(str.length is 38);
static assert(str[0] is '{');
static assert(str[9] is '-');
static assert(str[14] is '-');
static assert(str[19] is '-');
static assert(str[24] is '-');
static assert(str[37] is '}');
const GUID IIDFromString =
{
Data1: HexToInt(str[1 .. 9]),
Data2: HexToInt(str[10 .. 14]),
Data3: HexToInt(str[15 .. 19]),
Data4:
[
HexToInt(str[20 .. 22]),
HexToInt(str[22 .. 24]),
HexToInt(str[25 .. 27]),
HexToInt(str[27 .. 29]),
HexToInt(str[29 .. 31]),
HexToInt(str[31 .. 33]),
HexToInt(str[33 .. 35]),
HexToInt(str[35 .. 37])
]
};
}
const IIDJavaBeansBridge =
IIDFromString!("{8AD9C840-044E-11D1-B3E9-00805F499D93}");
CTFE is terribly buggy, I tend to stay away from it as much as I can.
More information about the Digitalmars-d-learn
mailing list