To avoid a lot of unnecessary copying, I'm trying to save unique_ptr in a list of pairs. I use a simple class test that accepts QString;
I am using VS2013 with Qt5.4
using std::unique_ptr;
QList<QPair<unique_ptr<Test>, unique_ptr<Test>>> list;
auto a = std::make_unique<Test>("a");
auto b = std::make_unique<Test>("b");
auto pair = qMakePair(std::move(a), std::move(b));
Due to failure, I tried:
QList<std::pair<unique_ptr<Test>, unique_ptr<Test>>> list;
auto pair = std::make_pair(std::move(a), std::move(b));
list.append(std::move(pair));
Due to the failure, I completely changed to STL containers:
std::list<std::pair<unique_ptr<Test>, unique_ptr<Test>>> list;
auto pair = make_pair(std::move(a), std::move(b));
list.push_back(std::move(pair));
It works. Is my conclusion true that these Qt containers do not support move semantics, and should I use STL instead?
source
share