range.size() should be long, right?

Jonathan M Davis jmdavisProg at gmx.com
Mon Jun 25 11:25:28 PDT 2012


On Monday, June 25, 2012 19:49:54 Mehrdad wrote:
> Shouldn't the length of a range should be a long?
> 
> Otherwise there's no way we could possibly replace streams with
> ranges.
> 32-bit systems have LOTS of common streams that are over 2^32
> bytes (e.g. DVD images, partition images, large movies, etc.).
> 
> And not just that -- if we use size_t instead of long, bit arrays
> will only have a maximum length of 512 MiB -- waay lower than
> what 32-bit systems can handle.

It depends on the range type. It's usually size_t, but sometimes it's 
explicitly something else. It just has to be implicitly convertible to ulong:

template hasLength(R)
{
 enum bool hasLength = !isNarrowString!R && is(typeof(
 (inout int _dummy=0)
 {
 R r = void;
 static assert(is(typeof(r.length) : ulong));
 }));
}

- Jonathan M Davis


More information about the Digitalmars-d mailing list