Is there a good way to modify a class in C++ so that its integers are 64-bit on a 64-bit system and 32-bit for 32-bit systems? Is there a way to check for that?
The class is something like:
class B{
public:
int64_t size();
private:
int64_t m_size();
}
If you really want exactly what you said (32-bit on 32-bit and 64-bit on 64-bit) you’ll need to use macros.
But what you probably want instead is to just use
size_t.EDIT:
size_tis guaranteed to be large enough to size any object and index any array. And as such, it is usually 32-bits on 32-bit and 64-bits on 64-bit. So it probably does exactly what you want.