SHARE
TWEET

Untitled

a guest Mar 19th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     ///
  2.     T[2] opIndex(size_t idx) pure
  3.     {
  4.         assert(idx < length);
  5.  
  6.         Coords coords = coordsInSquare(idx);
  7.  
  8.         import std.traits;
  9.         static assert(isMutable!(typeof(coords))); // ok
  10.  
  11.         if(coords.x <= coords.y) // under diagonal line?
  12.         {
  13.             auto latestIdx = srcLength - 1;
  14.  
  15.             // Mirroring coords
  16.             coords.x = latestIdx - coords.x; // Error: cannot modify const expression coords.x
  17.             coords.y = latestIdx - coords.y - 1;
  18.         }
  19.  
  20.         return [coords.x, coords.y];
  21.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top