I have a class NoCopy
that is movable, but not copiable.
I need to make a vector of 3 queues of NoCopy
. I can create an empty one, but there is no way to add any element.
I can make a std::vector<NoCopy>
or std::queue<NoCopy>
and populate them. But not for std::vector<std::queue<NoCopy>>
.
MWE:
#include <iostream>
#include <vector>
#include <queue>
class NoCopy{
public:
NoCopy() = default;
NoCopy& operator = (const NoCopy&) = delete;
NoCopy(const NoCopy&) = delete;
NoCopy(NoCopy&&) = default;
NoCopy& operator = (NoCopy&&) = default;
};
using QNC = std::queue<NoCopy>;
int main(void) {
QNC q;
q.push(std::move(NoCopy()));
std::vector<NoCopy> ncvec;
ncvec.emplace_back();
std::cout << "Queue size " << q.size() << ", vector size: " << ncvec.size() << std::endl;
std::vector<QNC> qvec;
//????
return 0;
}
Any ideas?