I have a function which is like
for (auto&& i : v) {
...
this->fifoQueue.push_back(move(i.p));
...
}
where fifoQueue is of type vector<unique_ptr<T> >, v is of type vector<struct s>, and struct s is
struct s {
...
std::unique_ptr<T> p;
...
};
The statement this->fifoQueue.push_back(move(i.p)); has caused a compiler error "... error: declared here unique_ptr(const unique_ptr&) = delete; ...". What's wrong with this statement?
I have another working statement basically the same as it, except that statement is like this->fifoQueue.push_back(move(p)). So i.p is the evil? Or auto&&?
Update:
As Petr inferred, v is indeed a const reference, which caused the error.