const member function

Baz via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Feb 20 23:01:10 PST 2015


---
class S
{
     private SomeType cache;

     public const(SomeType) SomeProp() @property
     {
        if (cache is null)
          cache = SomeExpensiveOperation();
        return cache;
     }
}
---

the result of the getter will be read-only


More information about the Digitalmars-d-learn mailing list