What does this compile-time error mean?
Alexandr Druzhinin
drug2004 at bk.ru
Sun Feb 24 04:10:06 PST 2013
24.02.2013 15:59, Jonathan M Davis пишет:
>
> Because main_cont is module-level variable, it must be initialized with a
> value at compile time. Classes can be used at compile time (at least some of
> the time), but they cannot stick around between compile time and runtime,
> meaning that you could potentially use them in a CTFE function, but you can't
> initialize a module-level or static variable (or enum) with them, and you're
> attempting to initialize maint_cont with a RedBlackTree, which is a class. It
> won't work.
>
> Now, on top of that, given those particular errors, it looks like there may be
> other issues beyond that which prevent RedBlackTree and/or std.array.array
> from being used at compile time at all, but even if it were perfectly useable
> at compile time, it still couldn't persist after the code is compiled and
> therefore could not be assigned to maint_cont.
>
> If you want to have main_cont be a RedBlackTree, you need to iniatialize it at
> runtime. To do that, you could do that something like
>
> RedBlackTree!int main_cont;
>
> static this()
> {
> main_cont = redBlackTree(iota(0, 100, 10).array());
> }
>
> - Jonathan M Davis
>
I see. Thank you!
More information about the Digitalmars-d-learn
mailing list