I'm using enum to compute the value at runtime like this:

struct A
{
        enum foo = A("foo", 10);
        enum baa = A("baa", 20);

        string name;
        int value;
        alias value this;
}

In order to avoid foo having its value (even if literal) copied every time A instancied and duplicates, shall I use static here?

I'm assuing that it works like this:

int f() {
   int a = 30;
   int b = 50;
}

and static would make it like this:

int f() {
  static int a = 20;
  static int b = 30;
}

int are examples, of course. I have A and array of A in my code.
  • Do I need to use static here? Machine Code via Digitalmars-d-learn

Reply via email to