0

Why there is no constructor to initialize container size in multiset in C++?

for example for vector we can initialize container size as

vector<int> a(n);

Jay
  • 59
  • 1
  • 8

1 Answers1

0

Creating a multiset with N identical elements was not viewed as a common use case.

For a vector, creating a vector with a pile of identical elements is a common use case, such as a vector of integral types initialized to zero or minus 1.

Yakk - Adam Nevraumont
  • 262,606
  • 27
  • 330
  • 524
  • I am not asking about identical elements in multiset. I am asking about reserving some space for multiset as we do with vector. Why it is not there in c++? – Jay Nov 05 '16 at 13:28
  • @jay the constructor you mention for vector does not reserve, it creates elements. So if that is what you wanted to ask, you did not ask it! Feel free to ask another question on why with vector you can reserve but node based containers you cannot. – Yakk - Adam Nevraumont Nov 05 '16 at 13:36
  • thank you. now i understood why there is no reserve for multiset :) – Jay Nov 07 '16 at 11:32