Witam !
Chciałbym się zapytać dlaczego po wykonaniu vec_str.push_back(move(str));
string "str" jest pusty a obiekt typu Test* "t" po vec.push_back(move(t));
nie ? Myślałem że funkcja std::move przenosi zmienną i jej poprzednie miejsce w pamięci jest puste.
#include <iostream>
#include <string>
#include <vector>
using namespace std;
struct Test
{
int& value;
Test(int& val): value{val}{}
};
int main()
{
int value = 100;
Test* t = new Test(value);
vector<Test*> vec;
vec.push_back(t);
cout << t->value << endl;
vec.push_back(move(t));
cout << t->value << endl;
string str = "Hello";
vector<string> vec_str;
vec_str.push_back(move(str));
cout << str << endl;
}