static const (D 1.x)
    Bill Baxter 
    dnewsgroup at billbaxter.com
       
    Tue Sep 18 23:03:37 PDT 2007
    
    
  
I've got a situation like this:
struct A
{
   opEquals
   int idx = -1;
}
class Foo(Type)
{
    ...
    static const A  StaticA;
}
But it doesn't work when I try to do something like this in a function:
    A myA;
    if (myA == Foo!(Type).StaticA) { // <-- error here
    }
The error I get is:
    Error: can only initialize static const StaticA inside static 
constructor
Is this a bug?
I notice that it compiles if I make StaticA just "static" instead of 
"static const".
At the very least the compiler error text seems wrong since I'm not 
trying to initialize anything.
--bb
    
    
More information about the Digitalmars-d-learn
mailing list