3 ms·
I wonder if this is more for the sake of C++ than C, where primitive values are more likely to be 'boxed' into a struct/class along with some methods. For insta
by andrewf 16y ago
I wonder if this is more for the sake of C++ than C, where primitive values are more likely to be 'boxed' into a struct/class along with some methods. For instance, with a typical non-debug standard library, vector<int>::iterator has one member - an int*. It'd be a shame if that couldn't go in a register.
- pmjordan 16y agoI'm fairly sure that as soon as it's no longer POD (plain old data), it can no longer be passed in a register, though, as it MUST have a permanent memory address. A struct or class loses its POD-ness by having constructors, a destructor, being a derived class, having virtual functions, public/protected/private sections or a bunch of other very strict conditions. Simple iterators may well be POD in many STL implementations, though.