
12 Feb
2006
12 Feb
'06
2:14 a.m.
David Abrahams wrote:
"Peter Dimov" <pdimov@mmltd.net> writes:
The status quo is that the size of the container is consistently written or read as an unsigned int, is it not?
I think so, though I could be mistaken.
Consider the simplistic example:
void f( unsigned int ); // #1 void f( unsigned long ); // #2
void g( std::vector<int> & v ) { unsigned int n1 = v.size(); f( n1 ); // #1
size_t n2 = v.size(); f( n2 ); // ??? }
Sure. So how does this relate to serialization?
Consider an archive where unsigned int and unsigned long have a different internal representation. When a value of a size_t type is written on platform A, where size_t == unsigned int, platform B, where size_t == unsigned long, won't be able to read the file.