http://d.puremagic.com/issues/show_bug.cgi?id=7513
Summary: [TDPL] opAssign examples don't work as described Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: mrmoc...@gmx.de --- Comment #0 from Trass3r <mrmoc...@gmx.de> 2012-02-16 02:34:20 CET --- import std.algorithm; struct Widget { private int[] array; this(uint length) { array = new int[length]; } this (this) { array = array.dup; } ref Widget opAssign(ref Widget rhs) { array = rhs.array.dup; return this; } ref Widget opAssign(Widget rhs) { swap(array, rhs.array); return this; } } void main() { Widget w; w = Widget(50); // line 30 } Two issues here: 1. Comment out the 2nd opAssign and the compiler should give an error, but it doesn't. (TDPL: // Cannot bind an rvalue of type Widget to ref Widget!) 2. TDPL's solution is 2 opAssigns, but this results in: $ dmd -release -O -run test2.d test2.d(30): Error: overloads ref Widget(ref Widget rhs) and ref Widget(Widget rhs) both match argument list for opAssign test2.d(30): Error: function test2.Widget.opAssign called with argument types: ((Widget)) matches both: test2.Widget.opAssign(ref Widget rhs) and: test2.Widget.opAssign(Widget rhs) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------