The simplest way to ask this question is with some code:
struct Point
{
int x;
int y;
int z;
int* as_pointer() { return &x; } // works
int (&as_array_ref())[3] { return &x; } // does not work
};
as_pointer compiles, as_array_ref does not. A cast seems to be in order but I can't figure out the appropriate syntax. Any ideas?
xis, in fact, an array of threeints? There's no guarantee that this will work; compilers can add padding between data members in ways that are different from the way that they lay out arrays.