I would like to know if there is any std library or boost tool to easily merge the contents of multiple sets into a single one.
In my case I have some sets of ints which I would like to merge.
I would like to know if there is any std library or boost tool to easily merge the contents of multiple sets into a single one.
In my case I have some sets of ints which I would like to merge.
You can do something like:
Looks like you are asking for
std::set_union
.Example:
With C++17, you can use
merge
function ofset
directly.This is better, when you want the set2 elements extracted & inserted into set1 as part of merging.
Like below:
look what std::merge can do for you
cplusplus.com/reference/algorithm/merge