digitalmars.D.learn - UFCS
- Manfred Nowak (11/11) May 15 2015 The following gives:
- Timon Gehr (2/9) May 15 2015 https://issues.dlang.org/show_bug.cgi?id=8062
- Jonathan M Davis via Digitalmars-d-learn (5/16) May 15 2015 Overloaded operators have to be defined as part of the type that they're
- Manfred Nowak (3/4) May 16 2015 The docs say so. Thx.
- "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm gmx.net> (3/23) May 16 2015 Besides, UFCS doesn't work with local functions either;
The following gives: "Error: 'a += b' is not a scalar, it is a C" although UFCS should engage. -manfred class C{} int main(){ void opOpAssign( string op)( C a, C b){ } C a, b; a+= b; }
May 15 2015
On 05/15/2015 11:31 PM, Manfred Nowak wrote:class C{} int main(){ void opOpAssign( string op)( C a, C b){ } C a, b; a+= b; }https://issues.dlang.org/show_bug.cgi?id=8062
May 15 2015
On Friday, May 15, 2015 21:31:35 Manfred Nowak via Digitalmars-d-learn wrote:The following gives: "Error: 'a += b' is not a scalar, it is a C" although UFCS should engage. -manfred class C{} int main(){ void opOpAssign( string op)( C a, C b){ } C a, b; a+= b; }Overloaded operators have to be defined as part of the type that they're overloading the operator for, and UFCS is only ever used with the . syntax. So, this isn't a bug. - Jonathan M Davis
May 15 2015
Jonathan M Davis wrote:UFCS is only ever used with the . syntaxThe docs say so. Thx. -manfred
May 16 2015
On Saturday, 16 May 2015 at 05:56:26 UTC, Jonathan M Davis wrote:On Friday, May 15, 2015 21:31:35 Manfred Nowak via Digitalmars-d-learn wrote:Besides, UFCS doesn't work with local functions either; `opOpAssign()` would need to be moved out of `main()`.The following gives: "Error: 'a += b' is not a scalar, it is a C" although UFCS should engage. -manfred class C{} int main(){ void opOpAssign( string op)( C a, C b){ } C a, b; a+= b; }Overloaded operators have to be defined as part of the type that they're overloading the operator for, and UFCS is only ever used with the . syntax. So, this isn't a bug.
May 16 2015