Is writing typeinfo to a file ok?
Charles D Hixson
charleshixsn at earthlink.net
Sat Feb 10 13:34:59 PST 2007
How should one write a typeinfo to a file?
What occurs to me is:
import std.stream;
class F : BufferedFile
{
void read (out TypeInfo t)
{ int siz;
Stream.read (siz);
if (readBlock(cast(void*)t, siz) != siz) throw new
Exception ("Wrong size block read");
}
void write (TypeInfo t)
{ Stream.write (t.sizeof);
if (writeBlock (cast(void*)t, t.sizeof) != t.sizeof)
{ throw new Exception ("Wrong size block written"); }
}
}
void main()
{ F f;
}
And it compiles all right. But would there be a problem if I
wrote during one invocation of a program, and later read to
reconstruct the state?
More information about the Digitalmars-d-learn
mailing list