#include <iostream>
#include <vector>
#include <initializer_list>
template<typename T>
std::vector<T> merge(std::initializer_list <std::vector<T>*> vecs)
{
size_t size = 0;
for(auto v : vecs) { size += v->size(); }
std::vector<T> ret;
ret.reserve(size);
for(auto v : vecs) { ret.insert(ret.end(), v->begin(), v->end()); }
return ret;
}
int main()
{
std::vector<std::string> a = {"a", "b"};
std::vector<std::string> b = {"c", "d"};
std::vector<std::string> c = {"e", "f"};
std::vector<std::string> d = {"g", "h"};
std::vector<std::string> newVector = merge({&a, &b, &c, &d});
for(auto &s : newVector)
std::cout << s << " ";
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8aW5pdGlhbGl6ZXJfbGlzdD4KCnRlbXBsYXRlPHR5cGVuYW1lIFQ+CnN0ZDo6dmVjdG9yPFQ+IG1lcmdlKHN0ZDo6aW5pdGlhbGl6ZXJfbGlzdCA8c3RkOjp2ZWN0b3I8VD4qPiB2ZWNzKQp7CglzaXplX3Qgc2l6ZSA9IDA7Cglmb3IoYXV0byB2IDogdmVjcykgeyBzaXplICs9IHYtPnNpemUoKTsgfQoJc3RkOjp2ZWN0b3I8VD4gcmV0OwoJcmV0LnJlc2VydmUoc2l6ZSk7Cglmb3IoYXV0byB2IDogdmVjcykgeyByZXQuaW5zZXJ0KHJldC5lbmQoKSwgdi0+YmVnaW4oKSwgdi0+ZW5kKCkpOyB9CglyZXR1cm4gcmV0Owp9CgppbnQgbWFpbigpCnsKCXN0ZDo6dmVjdG9yPHN0ZDo6c3RyaW5nPiBhID0geyJhIiwgImIifTsKCXN0ZDo6dmVjdG9yPHN0ZDo6c3RyaW5nPiBiID0geyJjIiwgImQifTsKCXN0ZDo6dmVjdG9yPHN0ZDo6c3RyaW5nPiBjID0geyJlIiwgImYifTsKCXN0ZDo6dmVjdG9yPHN0ZDo6c3RyaW5nPiBkID0geyJnIiwgImgifTsKCglzdGQ6OnZlY3RvcjxzdGQ6OnN0cmluZz4gbmV3VmVjdG9yID0gbWVyZ2UoeyZhLCAmYiwgJmMsICZkfSk7CgoJZm9yKGF1dG8gJnMgOiBuZXdWZWN0b3IpCgkJc3RkOjpjb3V0IDw8IHMgPDwgIiAiOwoKCXJldHVybiAwOwp9