save and load a 2d array to a file

Ali Çehreli acehreli at yahoo.com
Tue Apr 19 09:05:55 UTC 2022


On 4/19/22 01:46, bauss wrote:

 > However it should be fairly trivial like:
 >
 > void rawWriteValue(T)(T value)
 > {
 >    rawWrite(*cast((T[1]*)(&value)));
 > }
 >
 > Or is there some downside to this that I'm missing?

Nonet that I can see. I think I used the following version in actual 
code (adding the missing File parameter as well):

void rawWriteValue(T)(File file, T value)
{
   file.rawWrite((&value)[0..1]);
}

Ali



More information about the Digitalmars-d-learn mailing list