How to create compile-time container?
Adam D. Ruppe
destructionator at gmail.com
Mon Aug 31 20:44:16 UTC 2020
On Monday, 31 August 2020 at 20:39:10 UTC, Andrey Zherikov wrote:
> How can I do that?
You can use a normal string[] BUT it is only allowed to be
modified inside its own function.
Then you assign that function to an enum or whatever.
string[] ctGenerate() {
string[] list;
list ~= "stuff";
return list;
}
enum list = ctGenerate();
That's all allowed. But CTFE is now allowed to read or modify
anything outside its own function; you can't have two separate
function calls build up a shared list (unless you can somehow
call them both together like `enum list = ctGenerate() ~
other_thing();`
More information about the Digitalmars-d-learn
mailing list