std.algorithm.reduce & std.metastrings.Format

Sam Hu samhudotsamhu at gmail.com
Sat Jun 27 01:55:51 PDT 2009


Below 2 code snippets are both from phobos2.030 source.Compile with 'bud.exe -O -release -cleanup '.

1.std.metastrings:

string s=Format!("Arg %s=%s","foo",27);
writefln(s);// "Arg foo = 27"

can't compile,error msg:
testFormat.d(30): Error: cannot implicitly convert expression ("Arg %s=%sfoo27") of type const(char[]) to immutable(char)[]

2.std.algorithm.reduce 
I posted before but no input so I move here:

double[] a = [ 3.0, 4, 7, 11, 3, 2, 5 ];

// Compute minimum and maximum in one pass
auto r = reduce!(min, max)(a);
// The type of r is Tuple!(double, double)
assert(r.field[0] == 2);  // minimum
assert(r.field[1] == 11); // maximum

// Compute sum and sum of squares in one pass
r = reduce!("a + b", "a + b * b")(0.0, 0.0, a);
assert(r.field[0]==35);
assert(r.field[1]=233);

Can't compile.Error msg:
testFormat.d(22): Error: template std.algorithm.Reduce!("a + b","a + b * b").reduce(E,Range) does not match any function template declaration
testFormat.d(22): Error: template std.algorithm.Reduce!("a + b","a + b * b").reduce(E,Range) cannot deduce template function from argument types !()(double,double,double[])

So I am wondering are these 2 bugs?

Thanks for your help in advance.

Regards,
Sam


More information about the Digitalmars-d-learn mailing list