On 8/17/15 1:00 PM, Idan Arye wrote:
It looks a bit ugly, that the `else` is after a function declaration
instead of directly after the if's "then" clause. How about doing it
with the full template style?
template replaceInPlace(T, Range)
if(isDynamicArray!Range &&
is(Unqual!(ElementEncodingType!Range) == T) &&
!is(T == const T) &&
!is(T == immutable T))
{
void replaceInPlace(ref T[] array, size_t from, size_t to,
Range stuff)
{ /* version 1 that tries to write into the array directly */ }
}
else if(is(typeof(replace(array, from, to, stuff))))
{
void replaceInPlace(ref T[] array, size_t from, size_t to,
Range stuff)
{ /* version 2, which simply forwards to replace */ }
}
Yes, I like this much better.
-Steve