Skip to content

Instantly share code, notes, and snippets.

@tshev
Last active August 29, 2015 14:03
Show Gist options
  • Save tshev/33e13897d5d844ade967 to your computer and use it in GitHub Desktop.
Save tshev/33e13897d5d844ade967 to your computer and use it in GitHub Desktop.
std::move does not move
#include <iostream>
#include <vector>
#include <string>
int main() {
std::string str1 = "AA";
std::vector< std::string > v;
v.push_back(str1);
std::cout << str1 << "\n"; // AA
v.push_back(std::move(str1));
std::cout << str1 << "\n"; // AA
std::cout << v[0] << "\t"; // AA
std::string str2 = "BB";
std::cout << str2 << std::endl; // BB
v[0] = std::move(str2);
std::cout << str2 << "\n"; // AA
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment