|
|
|
|
|
by petermcneeley
2684 days ago
|
|
Yes std::vector owns the underlying continuous array of memory and will free it on the destructor call of vector. " img = std::vector<uint32_t>(w*h, color); " What is more interesting if you have been away from c++ is that the assignment is not a copy! The vector in this case is a temporary and it dies on assignment. Thus img takes the guts of this new vector. |
|
Movement semantics didn't exist in the language per se, but they were supported back then by std::swap and std::auto_ptr. Today, it is far easier to represent movement semantics with RValues, std::move, and std::unique_ptr.
But yeah, std::vector's assignment operator was originally at least std::swap based and therefore efficient.