[Issue 7587] New: reduce() of a const array of tuples too
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Feb 25 10:09:29 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7587
Summary: reduce() of a const array of tuples too
Product: D
Version: D2
Platform: x86
OS/Version: Windows
Status: NEW
Keywords: rejects-valid
Severity: enhancement
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2012-02-25 10:09:28 PST ---
import std.algorithm, std.typecons;
int add1(int x, int y) {
return x + y;
}
alias Tuple!int T;
T add2(T x, T y) {
return T(x[0] + y[0]);
}
void main() {
T[] items1 = [T(0), T(1)];
const t0 = T(0);
immutable r1 = reduce!add2(t0, items1); // OK
const(int[]) items2 = [0, 1];
const int zero = 0;
immutable r2 = reduce!add1(zero, items2); // OK
const(T[]) items3 = items1.idup;
immutable r3 = reduce!add2(t0, items3); // Error
}
DMD 2.059head gives:
...\dmd2\src\phobos\std\typecons.d(399): Error: template
std.typecons.Tuple!(int).Tuple.opAssign(R) if (isTuple!(R) &&
allSatisfy!(isIdentityAssignable,Types)) does not match any function template
declaration
...\dmd2\src\phobos\std\typecons.d(399): Error: template
std.typecons.Tuple!(int).Tuple.opAssign(R) if (isTuple!(R) &&
allSatisfy!(isIdentityAssignable,Types)) cannot deduce template function from
argument types !()(const(int))
...\dmd2\src\phobos\std\algorithm.d(702): Error: template instance
std.typecons.Tuple!(Tuple!(int)).Tuple.__ctor!(const(Tuple!(int))) error
instantiating
test.d(17): instantiated from here:
reduce!(const(Tuple!(int)),const(Tuple!(int)[]))
test.d(17): Error: template instance
std.algorithm.reduce!(add2).reduce!(const(Tuple!(int)),const(Tuple!(int)[]))
error instantiating
I think just as reduce works on an const(int[]) it should also work on an
const(Tuple!(int)[]).
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list