October 2004
Intermediate to advanced
240 pages
6h 22m
English
Don’t try to X-ray objects (see Item 96): Don’t make assumptions about how objects are exactly represented in memory. Instead, let types decide how their objects are written to and read from memory.
The C++ Standard makes few guarantees about how types are represented in memory:
• Base two is guaranteed for integral numbers.
• Two’s complement is guaranteed for negative integral numbers.
• Plain Old Data (POD) types have C-compatible layout: Member variables are stored in their order of declaration.
• int holds at least 16 bits.
In particular, the following may be common but are not guaranteed on all current architectures, and in particular are liable to be broken on newer architectures: ...
Read now
Unlock full access