1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
// unordered_multiset::operator=
#include <iostream>
#include <string>
#include <unordered_set>
template<class T>
T cmerge (T a, T b) {
T t(a); t.insert(b.begin(),b.end()); return t;
}
int main ()
{
std::unordered_multiset<std::string> first, second, third;
first = {"red","green","blue"}; // init list
second = {"red","yellow","blue"}; // init list
third = cmerge (first, second); // move
first = third; // copy
std::cout << "first contains:";
for (const std::string& x: first) std::cout << " " << x;
std::cout << std::endl;
return 0;
}
| |