Answers for "move elements from vector to unordered_set"

C++
0

move elements from vector to unordered_set

#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;
}
Posted by: Guest on August-29-2021

Code answers related to "move elements from vector to unordered_set"

Browse Popular Code Answers by Language