F
felixnielsen
What i have is not even a real problem, but i hope someone can help
anyway, but first a piece of code_
@code start
const unsigned short Size = 2; // 2^N
std::bitset<Size*Size*Size> YZ;
std::bitset<Size*Size*Size> XZ;
std::bitset<Size*Size*Size> XY;
std::bitset<Size*Size*Size> V;
union {
struct {
unsigned z:8;
unsigned y:8;
unsigned x:8;
};
unsigned id:24;
} coords;
@code end
Some explanation migth be in place.
The var "Size" will allways be the value 2^N {1,2,4,8,16,32,64, ect.} i
have yet to find a way to it is, because when i use the obious solution
(pow()) the compiler wont accept the bitsets being initialised by the
us of "Size", wery weird.
The bitsets are just bitset, no need to explain what they are for.
the union is kinda obious, its as way to bot have the x,y,z coords by
them self and have a bombined identifier to access the right bit of the
bitsets.
Now the tricky part:
I order for this to work, the vars in the union have to alocate a
specific amount of memory.
I guess its easyly explained with some code:
@code start
union {
struct {
unsigned z:log2(Size);
unsigned y:log2(Size);
unsigned x:log2(Size);
};
unsigned id:log2(Size)*3;
} coords;
@code end
This ofcourse doesnt work, but you should understand my problem by now.
Regards
Zacariaz
anyway, but first a piece of code_
@code start
const unsigned short Size = 2; // 2^N
std::bitset<Size*Size*Size> YZ;
std::bitset<Size*Size*Size> XZ;
std::bitset<Size*Size*Size> XY;
std::bitset<Size*Size*Size> V;
union {
struct {
unsigned z:8;
unsigned y:8;
unsigned x:8;
};
unsigned id:24;
} coords;
@code end
Some explanation migth be in place.
The var "Size" will allways be the value 2^N {1,2,4,8,16,32,64, ect.} i
have yet to find a way to it is, because when i use the obious solution
(pow()) the compiler wont accept the bitsets being initialised by the
us of "Size", wery weird.
The bitsets are just bitset, no need to explain what they are for.
the union is kinda obious, its as way to bot have the x,y,z coords by
them self and have a bombined identifier to access the right bit of the
bitsets.
Now the tricky part:
I order for this to work, the vars in the union have to alocate a
specific amount of memory.
I guess its easyly explained with some code:
@code start
union {
struct {
unsigned z:log2(Size);
unsigned y:log2(Size);
unsigned x:log2(Size);
};
unsigned id:log2(Size)*3;
} coords;
@code end
This ofcourse doesnt work, but you should understand my problem by now.
Regards
Zacariaz