digitalmars.D.bugs - Mixins and operator overloading
- "Regan Heath" <regan netwin.co.nz> Mar 16 2005
import std.stdio;
class A
{
A opCatAssign(int[] arr)
{
foreach(int v; arr)
writefln(v);
return this;
}
}
class B
{
template opCatAssign(Type)
{
B opCatAssign(Type arr)
{
foreach(typeof(arr[0]) v; arr)
writefln(v);
return this;
}
}
mixin opCatAssign!(int[]);
}
void main()
{
static int[] arr = [0,1,2];
A a = new A();
B b = new B();
a ~= arr;
b ~= arr; //Error: Can only concatenate arrays
}
Regan
Mar 16 2005
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Regan Heath schrieb am Thu, 17 Mar 2005 20:07:08 +1300:import std.stdio; class A { A opCatAssign(int[] arr) { foreach(int v; arr) writefln(v); return this; } } class B { template opCatAssign(Type) { B opCatAssign(Type arr) { foreach(typeof(arr[0]) v; arr) writefln(v); return this; } } mixin opCatAssign!(int[]); } void main() { static int[] arr = [0,1,2]; A a = new A(); B b = new B(); a ~= arr; b ~= arr; //Error: Can only concatenate arrays } Regan
Added to DStress as http://dstress.kuehne.cn/run/opCatAssign_06.d http://dstress.kuehne.cn/run/opCatAssign_07.d http://dstress.kuehne.cn/run/opCatAssign_08.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCQHdK3w+/yD4P9tIRAnm7AJwNGdsRxiHuuCyn48tGC2Wsji4ZxQCePopw EwW72e8kRRTbPEtl52evVPk= =9E2d -----END PGP SIGNATURE-----
Mar 22 2005








Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn>