[Issue 2701] Can't declare struct, assign lvalue via opAssign in same statement
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Aug 15 21:11:37 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2701
David Simcha <dsimcha at yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
--- Comment #2 from David Simcha <dsimcha at yahoo.com> 2010-08-15 21:11:33 PDT ---
I'm closing this, since this appears to be what C'tors are for. The following
example demonstrates. Perhaps this should be better documented, though.
struct Bar {
uint num;
this(uint otherNum) {
opAssign(otherNum);
}
Bar opAssign(uint otherNum) {
num = otherNum;
return this;
}
}
void main() {
int foo = 1;
Bar bar = foo; // Error: e2ir: cannot cast from uint to Bar.
Bar bar2;
bar2 = foo; // Works.
}
--
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