On Monday, 17 August 2015 at 13:18:43 UTC, Steven Schveighoffer wrote:
void replaceInPlace(T, Range)(ref T[] array, size_t from, size_t to, Range stuff)
if(isDynamicArray!Range &&
    is(Unqual!(ElementEncodingType!Range) == T) &&
    !is(T == const T) &&
    !is(T == immutable T))
{ /* version 1 that tries to write into the array directly */ }

void replaceInPlace(T, Range)(ref T[] array, size_t from, size_t to,
Range stuff)
else if(is(typeof(replace(array, from, to, stuff))))
{ /* version 2, which simply forwards to replace */ }

looks much better IMO. Can we do something like this? I'm not a compiler guru, so I defer to you experts out there.

-Steve

wouldn't is(typeof(replace(array, from, to, stuff))) better be a static if inside the first version?

Reply via email to