Am 16.05.2013 10:14, schrieb TommiT:
On Thursday, 16 May 2013 at 08:02:05 UTC, Jacob Carlborg wrote:
Use a module constructor:
static this () { }
http://dlang.org/module.html#staticorder
On Thursday, 16 May 2013 at 08:01:44 UTC, Timothee Cour wrote:
this works:
import std.stdio;
import std.conv;
const string[100] int__str;
const int[string] str__int;
static this(){
for (int i = 0; i < 100; ++i)
{
auto str = to!string(i);
int__str[i] = str; // ERROR: Can't modify const
str__int[str] = i; // ERROR: Can't modify const
}
}
But I'm talking about function local data. The initialization of
that data might depend on the arguments passed to the function.
so youre example code isn't showing what you try to reach - makes it
hard to understand/help - its even unclear if your string[100],
int[string] is just an example or a real problem, or if your < 100 is
variant or const - come up with an clear example
the normal way of doing stuff like this in C++,Java and D would be
and helper class with const members and const methods for access