[My site|SGI STL|Bjarne FAQ|C++ FAQ Lite|MSDN|Jargon]
Ripped off from various people
quote:
If you have nameless-struct problems, just pre-define the struct (I usually typedef them so I don''t need to say "struct s" (just "s") to declare ''em).
floats shouldn''t be suceptible to packing problems, as they are 32 bits in C/C++.
Pragma pack is AFAIK only used if you are using small types like chars that normalls align like ints or shorts (depends on compiler).
vector<float> v;
assert(sizeof(v)==sizeof(float)*3);
struct vec3
{
vec3()
{
arr[0] = &x
arr[1] = &y
arr[2] = &z
}
float x,y,z;
float& operator[](int index) const
{
return *arr[index];
}
private:
const float *arr[3];
};
quote:What does that have to do with the code I provided?
Original post by risingdragon3
Beer Hunter:
vector<float> v;
assert(sizeof(v)==sizeof(float)*3);
HUH!?!
Been there tried that, sir![]()
quote:
What does that have to do with the code I provided?
Perhaps my code destroyed half your brain.
quote:
And as for the rest of you what the HELL were some of those classes/structures/templates actually suppose to do. Because whatever they were suppose to do they clearly didn''t answer the question.
quote:...except that vector is a standard c++ template class, and whenever you say "vector", it is assumed that you are referring to that.
Original post by risingdragon3
Sizeof(vector) should be 3* sizeof(float).
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more