Original Post
🔒 Locked
[solved] Moving elements within an std::vector
Advertisement
Quote:
Original post by Kustaz
Is there a built in method for relocating an element from one position within a vector to another? I googled for a solution but didn't find anything which was very helpful.
Vectors don't have any built in operations for this (AFAIK), I'd use something like:
std::swap( my_vector[3] , my_vector[15] );
Or, with iterators:
std::swap( *iterator1 , *iterator2 );
Etc.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement