const member function
rumbu via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Feb 20 22:38:16 PST 2015
Often I'm using the following code pattern:
class S
{
private SomeType cache;
public SomeType SomeProp() @property
{
if (cache is null)
cache = SomeExpensiveOperation();
return cache;
}
}
Is there any way to mark SomeProp() as const? Because I want to
call somewhere const(S).SomeProp, which for the outside world is
must be "const", returning just a value, even that internaly it
modifies the internal S structure.
More information about the Digitalmars-d-learn
mailing list