SyntaxFix
Write A Post
Hire A Developer
Questions
If your vectors are sorted*, check out set_union from <algorithm>.
set_union(A.begin(), A.end(), B.begin(), B.end(), AB.begin());
There's a more thorough example in the link
*thanks rlbond