www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - isRandomAccessRange!(const(size_t[])) is false ... ?

reply Joseph Rushton Wakeling <joseph.wakeling webdrake.net> writes:
import std.range;

void main()
{
     assert(isRandomAccessRange!(const(size_t[])));
}

.... results in an assertion error.  This is a bug, no ... ?
Sep 12 2013
parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 09/12/2013 02:53 PM, Joseph Rushton Wakeling wrote:
 import std.range;

 void main()
 {
      assert(isRandomAccessRange!(const(size_t[])));
 }

 .... results in an assertion error.  This is a bug, no ... ?
That one is fine. You probably want a slice of const(size_t): import std.range; void main() { assert(!isRandomAccessRange!(const(size_t[]))); assert( isRandomAccessRange!(const(size_t)[])); // <-- } Ali
Sep 12 2013
parent "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Thu, Sep 12, 2013 at 03:12:48PM -0700, Ali Çehreli wrote:
 On 09/12/2013 02:53 PM, Joseph Rushton Wakeling wrote:
import std.range;

void main()
{
     assert(isRandomAccessRange!(const(size_t[])));
}

.... results in an assertion error.  This is a bug, no ... ?
That one is fine. You probably want a slice of const(size_t): import std.range; void main() { assert(!isRandomAccessRange!(const(size_t[]))); assert( isRandomAccessRange!(const(size_t)[])); // <-- }
[...] Explanation: const(size_t)[] means the elements of the array can't be modified, but the array itself can (necessary to implement popFront, popBack, etc.). const(size_t[]) means the array itself can't be modified, so popFront, popBack are invalid. So it cannot be a range. T -- Food and laptops don't mix.
Sep 12 2013