set<int> A, B;
for (int i = 0; i < 100; i++) A.insert(i);
for (int i = 50; i < 150; i++) B.insert(i);
How to add elements of set B to the set A?
In another words, how to implement A = Union(A, B)?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
By default sets are unique values only and sorted so inserting the iterator range should work: