Better_Software_Header_MobileBetter_Software_Header_Web

Find what you need - explore our website and developer resources

Qt and Trivial Relocation (Part 2)

Relocation and Erasure

QVector<QString> v{ "A", "B", "C", "D" };

v.erase(v.begin() + 1);  // remove B, second element

Move-assign C over B, move-assign D over (moved-from) C, and so on.

After the move assignments, there is a tail of moved-from element(s) that needs to be destroyed.

Almost done: destroy the last element, and reduce size by 1.

... it's a rotate!

We still have a tail of elements to destroy.

Destroying the last element.

About KDAB


4 Comments

15 - May - 2024

Robert

16 - May - 2024

Giuseppe D'Angelo

16 - May - 2024

Robert

16 - May - 2024

Giuseppe D'Angelo

GiuseppeD'Angelo

Giuseppe D’Angelo

Senior Software Engineer

Learn Modern C++

Learn more