Here is a code snippet which i want to get a list of unique_ptr from a function. Although i have added Copy/move Constructor to this struct,the vs compiler still has reported a c2280 error(attempting to reference a deleted function) .Does anybody know what's going on>?
#include<iostream>
#include<memory>
#include <list>
using namespace std;
struct info {
info() {
cout << "c" << endl;
}
~info() {}
info(const info&w) {
cout << "cc" << endl;
}
info(const info&&w) {
cout << "ccc" << endl;
}
info& operator==(const info&) {
cout << "=" << endl;
}
info& operator==(const info&&) {
cout << "==" << endl;
}
};
typedef unique_ptr<info> infop;
list<infop> test() {
list<infop> infopList;
info t,t1;
infop w = make_unique<info>(t);
infop w1 = make_unique<info>(t1);
infopList.push_back(w);
infopList.push_back(w1);
return infopList;
}
void main() {
list<infop> pl = test();
}