The two cannot be fairly compared since a "
std::vector" of references is not allowed. Internally, there's a pointer to a region of memory. If the specified type is of type reference, the internal declaration of the pointer would be a
pointer to a reference to a "T", which isn't allowed. In addition, the type a "
std::vector" holds must be copy-assignable. Declaration aside, this declaration:
DeepBlack wrote: |
---|
"typedef std::vector<const xyz&> xyzTypeVector_t; " |
...is purely implementation-defined because an implementation may or may not reserve storage for a reference. Let's a assume no storage is set aside for a reference. Pushing and popping references wouldn't make any sense; how would you push/pop something that doesn't technically exists in memory? You can't.
Now let's assume there was space reserved for a reference. Pushing and popping would be OK, but the declaration is not OK, because an array of references is not allowed, and the internal pointer is still a
pointer to a reference to a "T".
Now let's assume the declaration is valid. If a temporary actual "
xyz" parameter was pushed, the actual parameter would be bound to the reference within the "
std::vector". If the type was not of type reference to a "
T", the actual parameter would be copied
only if the "
union" has a copy-constructor.
Wazzak