Logical const
Peter Alexander
peter.alexander.au at gmail.com
Mon Nov 29 13:33:21 PST 2010
On 29/11/10 3:19 PM, so wrote:
> Second why do mark something const if it is not, this is a wrong
> approach even in C++ which provides explicit "mutable".
It is logical const. It is the correct approach in C++.
> How are you going to do caching anyways, if static array is not the case?
>
> struct matrix {
> f32[4][4] m;
> f32 det_cache; // ?
> f32 mag_cache; // ?
> f32 whatever_cache; // ?
> };
>
I described the mechanisms of this in the original post. You have a
'is_dirty' member function, which is marked as true if you modify the
matrix. The getDeterminant function only calculates the determinant if
is_dirty is true, otherwise it returns the cached version.
More information about the Digitalmars-d
mailing list