Is there any way I can make reference members take no space? For example:
#include <iostream>
#include <glm/glm.hpp>
struct MyClass : public glm::vec3{
float& rx = x;
float& ry = y;
float& rz = z;
};
int main() {
std::cout << sizeof(glm::vec3) << std::endl;
std::cout << sizeof(MyClass) << std::endl;
}
the size of the class glm::vec3
is 12 and the size of the class MyClass
is 40.
Is there any way I can make the references in MyClass
takes no space? Just act as if all codes where ri
is used, it is replaced by i
?
P.S. If you curious why I'm doing this, I'm adding custom attributes on class members for scanning, but I cannot change third-party codes like glm, that's why I need a wrapper, but if the wrapper is not the same size as the origin one, the space wasted is unacceptable.