[Issue 4103] opAssign signature rules not enforced on templated opAssign
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Feb 9 06:35:20 PST 2015
https://issues.dlang.org/show_bug.cgi?id=4103
Kenji Hara <k.hara.pg at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |spec
Status|NEW |RESOLVED
Version|unspecified |D2
Resolution|--- |FIXED
--- Comment #2 from Kenji Hara <k.hara.pg at gmail.com> ---
D2 spec is updated for struct.
http://dlang.org/operatoroverloading#assignment
> For struct types, operator overloading for the identity assignment is allowed.
...
> However for class types, identity assignment is not allowed.
And for class types, identity opAssign definition is properly checked, even if
it's template.
class C
{
C opAssign(T)(T t) // line 3
{
writeln(T.stringof);
return this;
}
}
void main() {}
Output:
test.d(3): Error: class test.C identity assignment operator overload is illegal
--
More information about the Digitalmars-d-bugs
mailing list