← Back to context

Comment by ralfj

2 days ago

That doesn't let you treat data in-place at two different types, unless one of them happens to be char. So you still need to make a copy in many cases, e.g. to convert between an array of uint32_t and an array of uint16_t.

In some cases you can use unions, but that, too, is very limited, and I am not sure it would let you do this particular case.

Not if you use may alias.

Also yes, that's the point of the C++ object model, only one type may exist in one location at a time.

Since usually different register banks are used for different types, having to copy makes sense.