Before C++17
vector.insert(vector.end(), set.begin(), set.end());
After C++17
vector.reserve(set.size());
for (auto it = set.begin(); it != set.end(); ) {
vector.push_back(std::move(set.extract(it++).value()));
}
#include <iostream>
#include <vector>
#include <unordered_set>
int main()
{
std::vector<int> input({ 1, 2, 2, 1, 3, 1, 4 });
std::unordered_set<int> set(input.begin(), input.end());
for (const int &i: set) {
std::cout << i << " ";
}
return 0;
}