automate tuple creation

forkit forkit at gmail.com
Thu Jan 20 23:01:39 UTC 2022


On Thursday, 20 January 2022 at 22:31:17 UTC, Steven 
Schveighoffer wrote:
>
> Because it would allow altering const data.
>

I'm not sure I understand. At what point in this function is 
valuesArray modified, and thus preventing it being passed in with 
const?

// ---

int[][int][] CreateDataSet
ref const int[] idArray, ref int[][] valuesArray, const int 
numRecords)
{
     int[][int][] records;
     records.reserve(numRecords);

     foreach(i, const id; idArray)
         records ~= [ idArray[i] : valuesArray[i] ];

     return records.dup;
}

// ----


More information about the Digitalmars-d-learn mailing list