[Issue 10272] opAssign() not invoked during variable declaration and initialization
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jun 5 17:13:11 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10272
Jonathan M Davis <jmdavisProg at gmx.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution| |INVALID
--- Comment #4 from Jonathan M Davis <jmdavisProg at gmx.com> 2013-06-05 17:13:09 PDT ---
Sorry, but it's still invalid.
auto foo = bar;
will _never_ use opAssign. opAssign is for overloading the assignment operator,
and there is no assignment operator in that statement. It's a variable
declaration, not an assignment. Whether it's an lvalue or rvalue is irrelevant
for that. The difference is that with an rvalue, it's a move operation, whereas
with an lvalue, the postblit operator will be called. So, if you want to
overload the behavior of
auto foo = bar;
then you need to declare a postblit constructor:
http://dlang.org/struct.html#StructPostblit
--
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