Steven Schveighoffer wrote:
> struct AlgebraicFunction {
> double getMaximum() {
> if (!cache_valid) {
> this.cachedMaximum = this.veryExpensiveCalculation();
> cache_valid = true;
> }
> return this.cachedMaximum; // hey, I thought you only use struct
> pointers like (*x).member?
I kind of forgot that 'this' is a pointer inside structs.
> }
>
> private Optional!double cached_maximum;
> private bool cache_valid = false;
> }
If cached_maximum and cache_valid are the only members of
AlgebraicFunction, you might be able to get away with that. If you have
several different cached values, not so much.
--
Rainer Deyke - [email protected]