any news on const/invariant?

Bill Baxter dnewsgroup at billbaxter.com
Mon Nov 26 17:48:42 PST 2007


0ffh wrote:
> Derek Parnell wrote:
>> I am under the impression that this is a fairly common way of doing 
>> things.
>>
>>    byte[] bitmap;
>>
>>    bitmap = LoadBitMapFromFile("worldroadmap.bmp");
>>    GammaAdjust(bitmap, 0.20);
> 
> void GammaAdjust(ref byte[] bitmap,float gamma) ?

byte[] bitmap;
bitmap = LoadBitMapFromFile("worldroadmap.bmp");
byte[] same_bitmap = bitmap;
GammaAdjust(bitmap, 0.20);
assert(bitmap.ptr is same_bitmap.ptr, "Error GammaAdjust not supposed to 
change the bitmap pointer");


Sometimes it's convenient to have more than one reference to the same 
buffer around.

--bb



More information about the Digitalmars-d mailing list