|
Boost Users : |
From: Andrea Denzler (andrea_at_[hidden])
Date: 2008-08-18 13:42:20
> So at least on a local scale, index values do correspond to memory
> addresses or memory offsets.
Sure, A part from STL and other containers using they own operator, when you
use direct memory access a index is used to access the flat memory of the
allocated object/array.
> > The "problem" could be solved by using largest _signed_ type both for
> size_type and difference_type.
> [snip]
> > So I'd advocate signed representation for size_type and difference_type.
Sure, also because when you play with pointers you have negative indexes
too. So a signed index is welcome, and it should cover the range of the
maximum memory size of an object (not the entire memory).
But on a 32 bit architecture where theorically I can allocate up to 4
Gigabyte for a single object using a signed integer requires a 32bit + sign
= 33 bits. Ops... what now?
A) using signed 32bit, so the memory address swaps between -2^31 and
+2^31-1. Not exactly elegant.
B) using unsigned 32 bit, a contingous address from 0 to +2^32.
C) using a bigger integral signed type, probably a 64 bit signed.
And 2 GByte is not that uncommon...
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net