bug in reduce when passed const arguments

This commit is contained in:
Andrei Alexandrescu 2009-10-03 21:24:13 +00:00
parent b50f21459c
commit 391ce8db1e

View file

@ -256,8 +256,9 @@ private:
}
public:
E reduce(E, R)(E result, R r)
Unqual!E reduce(E, R)(E seed, R r)
{
Unqual!E result = seed;
foreach (e; r)
{
static if (fun.length == 1)
@ -321,6 +322,15 @@ unittest
assert(rep[2 .. $] == "1, 2, 3, 4, 5");
}
unittest
{
const float a = 0.0;
const float[] b = [ 1.2, 3, 3.3 ];
float[] c = [ 1.2, 3, 3.3 ];
auto r = reduce!"a + b"(a, b);
r = reduce!"a + b"(a, c);
}
/**
Fills a range with a value.