Sup! I started getting back to C++ after 1,5 year break... How to pass multiple vectors to a function, but of indefinitive amount in c++?
It won't work:
template <typename T>
std::vector<T> Distinct(const std::vector<T>&... arrays)
{
std::unordered_map<T, int> map;
for (auto arr : arrays)
{
for (auto item : arr)
{
auto count = map[item];
map.insert_or_assign(item, ++count);
}
}
std::vector<T> result;
for (auto item : map)
{
if (item.second > 1)
result.push(item.first);
}
return result;
}