Is it possible to store unique_ptr in QList QPairs?

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");

// First make a pair
auto pair = qMakePair(std::move(a), std::move(b));      // Fails
// Error C2280 - attempting to reference a deleted function

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)); // Succes
list.append(std::move(pair)); // Fails
// Error C2280 - attempting to reference a deleted function

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)); // Succes
list.push_back(std::move(pair)); // Succes

It works. Is my conclusion true that these Qt containers do not support move semantics, and should I use STL instead?

+4
source share

All Articles