user1873947
user1873947

Reputation: 1811

Assign vector to multiset

Is there any good way for assigning std::vector to std::multiset? Other than iteration of course. I see that in C++11 there is something like initializer list, maybe it can be used somehow?

Upvotes: 0

Views: 4486

Answers (2)

us2012
us2012

Reputation: 16253

vector<int> v;
//fill your vector
multiset<int> m (v.begin(), v.end());

Upvotes: 14

Ivaylo Strandjev
Ivaylo Strandjev

Reputation: 70929

Use this:

std::vector<SOME_TYPE> a;
....
std::multiset<SOME_TYPE> ms(a.begin(), a.end());

Upvotes: 4

Related Questions