enum string[string] CtfeFoo = ["foo" : "bar"];
static immutable string[string] Foo;
static this()
{
Foo = CtfeFoo;
}
string ctfeableFunction()
{
if (__ctfe)
return CtfeFoo["foo"];
else
return Foo["foo"];
}
void main()
{
enum a = ctfeableFunction();
auto b = ctfeableFunction();
}
d编译时与运行时关联数组
猜你喜欢
转载自blog.csdn.net/fqbqrr/article/details/104036170
今日推荐
周排行