J
John Ratliff
Say I had a three-dimensional array containing multiple 2D level data.
It might be defined like this:
unsigned char LEVEL_DATA[][5][5] = {
{
{1, 1, 1, 1, 1},
{1, 0, 0, 0, 1},
{1, 0, 0, 0, 1},
{1, 0, 0, 0, 1},
{1, 1, 1, 1, 1}
}
};
Assume of course there are more dimensions and more than one level.
What is the proper way to cast to a 2D const ptr? This is what I did to
make the compiler shut up, but I don't know if it's correct or not.
const unsigned char * const *data =
reinterpret_cast<const unsigned char * const *>(LEVEL_DATA[0]);
Is this correct? I was reading
http://www.parashift.com/c++-faq-lite/const-correctness.html#faq-18.17
But it doesn't mention pre-defined array data specifically, and the
compiler doesn't implicitly treat them the same (yeah, I know they are
not the same).
Thanks,
--John Ratliff
It might be defined like this:
unsigned char LEVEL_DATA[][5][5] = {
{
{1, 1, 1, 1, 1},
{1, 0, 0, 0, 1},
{1, 0, 0, 0, 1},
{1, 0, 0, 0, 1},
{1, 1, 1, 1, 1}
}
};
Assume of course there are more dimensions and more than one level.
What is the proper way to cast to a 2D const ptr? This is what I did to
make the compiler shut up, but I don't know if it's correct or not.
const unsigned char * const *data =
reinterpret_cast<const unsigned char * const *>(LEVEL_DATA[0]);
Is this correct? I was reading
http://www.parashift.com/c++-faq-lite/const-correctness.html#faq-18.17
But it doesn't mention pre-defined array data specifically, and the
compiler doesn't implicitly treat them the same (yeah, I know they are
not the same).
Thanks,
--John Ratliff