How do you make a copy TO and object when you're INSIDE of it?

Enjoys Math via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jul 23 18:30:55 PDT 2015


Here's my code:

module grammar;

class Grammar(T : ulong) {
     this(const T[] str) {
         auto grammar = str in grammarCache;

         if (grammar) {
             this = grammar.dup;
         } else {
             this = approximateSmallestGrammar(str);
             grammarCache[str] = this.dup;
         }
     }

     static Grammar approximateSmallestGrammar(const T[] str) {
         return new Grammar();
     }

     @property Grammar dup() {

     }

private:
     this() {}
     static Grammar[T[]] grammarCache;
};


Compiler says 'this' is not an lvalue.  How would I accomplish 
what I want?



More information about the Digitalmars-d-learn mailing list