I have a unique_ptr in a priority_queue and I want to remove it from that collection and put it on a deque while maintaining the ownership semantics of unique_ptr. But I can't find a way to pull it off the priority_queue without a compile error: "attempting to reference a deleted function". What's the right way to accomplish this?
struct MyStruct {
int val = 2;
MyStruct(const int val) : val(val) {}
};
void testDeque() {
std::priority_queue<std::unique_ptr<MyStruct>> q1;
q1.emplace(std::make_unique<MyStruct>(10));
std::deque<std::unique_ptr<MyStruct>> q2;
q2.push_back(q1.top()); // <- compiler error "attempting to reference a deleted function"
q2.push_back(std::move(q1.top())); // <- compiler error "attempting to reference a deleted function"
q1.pop();
}