asFlatStaticArray

Represents value as a flat (single-dimension) static array. Considers T to be an n-dimensional static array type.

See also $(DPREF traits, MultidimStaticArrayElementType), $(DPREF traits, multidimStaticArrayElementCount).

  1. ref asFlatStaticArray(T t)
    ref @trusted pure nothrow @nogc
    asFlatStaticArray
    (
    T
    size_t n = staticArrayDims!T
    )
    (
    ref T t
    )
  2. ref asFlatStaticArray(T t)

Examples

t
{
	int i;
	static assert(is(typeof(asFlatStaticArray(i)) == int[1]));
	asFlatStaticArray(i)[] = 5;
	assert(i == 5);

	int[1][2][3] mdimSArr;
	static assert(is(typeof(asFlatStaticArray(mdimSArr)) == int[6]));
	asFlatStaticArray(mdimSArr) = [1, 2, 3, 4, 5, 6];
	assert(mdimSArr == [[[1], [2]], [[3], [4]], [[5], [6]]]);

	static assert(is(typeof(asFlatStaticArray!2(mdimSArr)) == int[1][6]));
	assert(asFlatStaticArray!2(mdimSArr) == [[1], [2], [3], [4], [5], [6]]

Meta