BitArray in custom class & initialize it in ctor with arguments
MarisaLovesUsAll
marusya at 2ch.hk
Sat Mar 22 02:24:07 PDT 2014
Hi! I need to use array of bits in my custom class. I tried to
add std.bitmanip.BitArray as field, but got a strange error. What
am I doing wrong?
import std.bitmanip;
class Scene
{
BitArray collisionMap;
this(int w, int h)
{
collisionMap.init([0,0,0]);
}
}
C:\D\dmd2\windows\bin\..\..\src\phobos\std\bitmanip.d
line 606
Error: btr cannot be interpreted at compile time, because it has
no available source code
If I use collisionMap.length(w*h), I get:
C:\D\dmd2\windows\bin\..\..\src\phobos\std\bitmanip.d
line 554
Error: non-constant expression [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
And if I use BitArray in default ctor ( this() ), or in other
function in class, or in main function, all is OK. But I need
only ctor with arguments that initialize the BitArray with '0'
and sets 'w*h' length.
DMD version 2.065.0
Sorry for bad English.
More information about the Digitalmars-d-learn
mailing list