February 11, 2007 Is writing typeinfo to a file ok? | ||||
---|---|---|---|---|
| ||||
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? |
Copyright © 1999-2021 by the D Language Foundation