isRandomAccessRange!(const(size_t[])) is false ... ?

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Thu Sep 12 15:46:20 PDT 2013


On 13/09/13 00:15, Jonathan M Davis wrote:
> Nope. It's correct. Because it's const, you can't call popFront on it or any
> of the other mutating range operations. So, it's not a valid range.

D'oh! :-P

I gave the assert as an example, but this one snuck up on me rather unexpectedly 
-- I'd got a class method that was something like this:

     auto foo(in size_t n) @safe const nothrow pure
     {
         return buf[n];      // where buf is a size_t[][]
     }

... and it turned out that foo was trying to return a const(size_t[]) rather 
than a size_t[].


More information about the Digitalmars-d-learn mailing list