std.array.replace
works on arrays, whereas map
returns a range. To convert the range to an array (which will allocate memory for all elements), use the array
function.
Thus, your example becomes:
return data.map!"a + 1"
.array
.replace(2, 1);