How to create compile-time container?
Andrey Zherikov
andrey.zherikov at gmail.com
Mon Aug 31 20:39:10 UTC 2020
On a low level, I want something like this code to work:
string[] arr; // this can be any suitable type
arr ~= "a"; // data is compile-time constant
enum f = arr[0]; // fails with "Error: variable arr cannot
be read at compile time"
enum b = arr[$-1]; // fails with "Error: variable arr cannot
be read at compile time"
More generic description: I'm looking for a way to have a
container (or any other type) that I can manipulate during
compile time. Operations needed are similar to stack
functionality: get first/last element, push_back and pop_back.
How can I do that?
More information about the Digitalmars-d-learn
mailing list