I am trying to copy a std::vector
into std::priority_queue
while the following two approaches are working.
vector<int> parts = { 8, 4, 6, 12, 57, 28}; //source
priority_queue<int, vector<int>, greater<int>> minHeap; //target
approach 1:
all_of(parts.begin(), parts.end(), [&minHeap](int& part){minHeap.push(part); return true;});
approach 2:
for(int& part: parts) minHeap.push(part);
However, I'd like to know if the same can be done by std::copy
?