There is a link to the vector
vector<CCMD> &commands = *new vector<CCMD>(); How to move an element in the original vector through it?
swap somehow works incomprehensibly with links, it swaps elements in the link, but not in the original .. I myself did not understand anything.
swap(commands[i], commands[i + 1]); UPD
Code:
commands = bots[0]->command.commandListChat; ... cout << "copy - " << commands[i].instance->triggerS << endl; cout << "orig - " << bots[0]->command.commandListChat[i].instance->triggerS << endl; swap(commands[i], commands[i + 1]); cout << "copy - " << commands[i].instance->triggerS << endl; cout << "orig - " << bots[0]->command.commandListChat[i].instance->triggerS << endl; Conclusion:
copy - 2 orig - 2 copy - 1 orig - 2 UPD2
I understood. The link cannot be changed. Very interesting. I will go to redo everything.
vector<CCMD> &commands = *new vector<CCMD>();- and then how to release the memory?delete &commands;? Not the best method - for a number of reasons ... - Harry