www.digitalmars.com         C & C++   DMDScript  

c++.stl - How to merge two std::vectors

Good afternoon,

I have just written a function, which uses the "set_union()" 
function for merging two sorted std::vectors.
The issue is that this is very slow, and I think I understand 
why: the function "set_union()" takes two input vectors and 
generates an output vector, which means that every element in the 
resulting vector needs to be allocated in memory.

What I'm actually looking for, is a function which merges the 
values of one std::vector into another one. Here the number of 
allocations should be far less and I expect the performance of 
this function being far better.

Does anybody know if such a function exists and how to use it? 
(I'm having quite some trouble getting STL functions to work)

Thanks in advance
Dominique
Oct 04 2016