You do not need pointers for this. Just use a std::vector
std::set<int> my_set;
... insert things in the set ...
std::vector<std::set<int> > list_of_sets;
list_of_sets.push_back(my_set);
This will cause the set to be copied but unless you have billions of integers, or this is being done millions of times, it won’t matter much.
Alternatively, you can insert the set into the vector and then use that element in the vector for your insertions directly, in which case you won’t incur the copy cost. But I’m not sure how the rest of your code is laid out.
Perhaps what you want instead is a Superset. In which case you should do this:
std::set<int> superset;
for each smaller set:
superset.insert(each_set.begin(), each_set.end());
3
solved Get a superlist of different lists in C++ [closed]