Commit ac93f68e authored by Carsten Schlote's avatar Carsten Schlote
Browse files

Merge branch 'master' of gitlab.vahanus.com:dlang/examples/crosscc-arm-cortex-a7

parents a8149aa0 6cda2b28
Pipeline #212 failed with stage
in 23 seconds
......@@ -22,7 +22,8 @@ uint32_t sumRange( int start, int max )
return summe;
}
uint32_t sumBooTree(int N, T)(T[N] arr)
/** Perfectly ineficient sum template */
uint32_t sumBooTree(int N = T.length, T)(T[N] arr)
{
static assert(arr.length >= 1, "We need at least one argument.");
static if (arr.length == 1)
......@@ -35,11 +36,14 @@ uint32_t sumBooTree(int N, T)(T[N] arr)
}
}
immutable ubyte[10] foo = [ 1,2,3,4,5,6,7,8,9,10 ];
ubyte[1024] foo;
static this() {
foreach( i, ref v ; foo ) v = cast(ubyte)(i + 1);
}
uint32_t sumTest(out uint32_t expect )
{
uint32_t rc = sumBooTree!10( foo );
uint32_t rc = sumBooTree( foo );
expect = (foo.length * (foo.length+1)) / 2;
return rc;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment