I'm sure this is possible, because I'm pretty sure I did it. I think this is terrible, but I will gladly accept the answers "This is a terrible idea because ____".
Say that we have a basic structure.
structure head (float x, y, z)};
Now, I want to apply the alias to these variables.
vertex pos; Summit collage; Summit arr; Pos.x = 0.0f; Pos.y = 0.5f; Pos.z = 1.0f; Col.r = 0.0f; Col.g = 0.5f; Col.b = 1.0f; Arr [0] = 0.0 f; Arrivals [1] = 0.5 F; Arrivals [2] = 1.0 f;
Ideally the third syntax will be indistinguishable from an array. That is, if I sent the arr
in the form of a reference parameter in the hope of a foreground, in which it will store the data (like many OpenGL glGet
functions) , It will work fine.
What do you think? Possible? Possible but stupid?
What will I do that make the accessers:
Structure Vertex { Float & amp; R () {return value [0]; } Float & amp; G () {return value [1]; } Float & amp; B () {return value [2]; } Float & amp; X () {return value [0]; } Float & amp; Y () {return value [1]; } Float & amp; Z () {Return Value [2]; } Float operator [] (unsigned i) const {at-> values [i]; } Float & amp; Operator [] (unsigned i) {returned> values> [i]; } Operator float * () CONST {back to this- & gt; Values_; } Private: float [3] values_; }
Comments
Post a Comment