On Monday, 17 July 2017 at 20:01:41 UTC, H. S. Teoh wrote:
OK, here's an actual, compilable, runnable version:
import std.algorithm : sum;
import std.meta : allSatisfy, staticMap;
import std.range : only;
import std.traits : CommonType, isStaticArray;
alias Elem(A : E[n], E, size_t n) = E;
enum Length(A) = A.length;
enum sumLengths(A...) = sum(only(0, staticMap!(Length, A)));
CommonType!(staticMap!(Elem, A))[sumLengths!A] append(A...)(A
arrays)
if (allSatisfy!(isStaticArray, A))
{
typeof(return) result = void;
foreach (i, a; arrays) {
enum offset = sumLengths!(A[0 .. i]);
result[offset .. offset + a.length] = a[];
This slice assignment doesn't support conversion between
different element-types, for instance from `int[]` to `double[]`.
But I'm not convinced that we should allow `CommonType` when
operator ~ doesn't.