digitalmars.D.bugs - static opIndex not working with templated class
- Ivan Senji (18/18) Oct 24 2005 Given this code:
- Thomas Kuehne (12/30) Oct 28 2005 -----BEGIN PGP SIGNED MESSAGE-----
Given this code:
class array(T)
{
   static T[] opIndex(T[] a ...)
   {
     return a.dup;
   }
}
This doesn't work:
float[] a = array!(float)[1,2,3];
DMD(0.135) Compiler complains:
animacija.d(48): only one index allowed to index void
animacija.d(48): class array must be an array or pointer type, not void
animacija.d(48): cannot implicitly convert expression (class array[1]) 
of type int to float[]
But this works:
alias array!(float) type;
float[] a = type[1,2,3];
 Oct 24 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Ivan Senji schrieb am 2005-10-24:
 Given this code:
 class array(T)
 {
    static T[] opIndex(T[] a ...)
    {
      return a.dup;
    }
 }
 This doesn't work:
 float[] a = array!(float)[1,2,3];
 DMD(0.135) Compiler complains:
 animacija.d(48): only one index allowed to index void
 animacija.d(48): class array must be an array or pointer type, not void
 animacija.d(48): cannot implicitly convert expression (class array[1]) 
 of type int to float[]
 But this works:
 alias array!(float) type;
 float[] a = type[1,2,3];
Added to DStress as
http://dstress.kuehne.cn/run/t/template_class_11_A.d
http://dstress.kuehne.cn/run/t/template_class_11_B.d
Thomas
-----BEGIN PGP SIGNATURE-----
iD8DBQFDYi3n3w+/yD4P9tIRAtkeAJ9SQi7cpQLT4xFL96EeiI3t4D+ZhgCfXDml
6tdP+9z+ij9vJafDq8+UV8I=
=Rscr
-----END PGP SIGNATURE-----
 Oct 28 2005








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