www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Array!bool and size_t

reply "Nicolas Sicard" <dransic gmail.com> writes:
The implementation of std.container.Array!bool makes use of ulong 
instead of size_t as far as sizes and indices are concerned. This 
makes Array!bool inconsistent with other array-like types 
(including Array!T if !is(T==bool)) in 32-bit code. What would be 
the disadvantages of using size_t?

Thanks,
Nicolas
May 15 2012
next sibling parent Dmitry Olshansky <dmitry.olsh gmail.com> writes:
On 15.05.2012 13:44, Nicolas Sicard wrote:
 The implementation of std.container.Array!bool makes use of ulong
 instead of size_t as far as sizes and indices are concerned. This makes
 Array!bool inconsistent with other array-like types (including Array!T
 if !is(T==bool)) in 32-bit code. What would be the disadvantages of
 using size_t?

 Thanks,
 Nicolas

doubtful if you can always fetch such big piece of contiguous memory from OS it's still possible. And 32bit bit-indexes just fail to address it. -- Dmitry Olshansky
May 15 2012
prev sibling parent "Nicolas Sicard" <dransic gmail.com> writes:
On Tuesday, 15 May 2012 at 10:04:52 UTC, Dmitry Olshansky wrote:
 On 15.05.2012 13:44, Nicolas Sicard wrote:
 The implementation of std.container.Array!bool makes use of 
 ulong
 instead of size_t as far as sizes and indices are concerned. 
 This makes
 Array!bool inconsistent with other array-like types (including 
 Array!T
 if !is(T==bool)) in 32-bit code. What would be the 
 disadvantages of
 using size_t?

 Thanks,
 Nicolas

While it's doubtful if you can always fetch such big piece of contiguous memory from OS it's still possible. And 32bit bit-indexes just fail to address it.

Yes, I understand this limitation. But from another theoretical point of view, length not returning a size_t is odd for a container (std.bitmanip.BitArray.length did). But I am ok if it is more needful for an array of bool to be able to address the full memory... Thanks, Nicolas
May 15 2012