Is the number of template parameters for std::vector guaranteed to be 2?

Viewed 105

I currently have a body of code that relies on std::vector<...> having exactly two template arguments. Which as of this writing, all language revisions do. If this number changes, my code will break.

Is it possible that in some future revision, this number will be changed, or does the standard guarantee that this number will always be 2?

1 Answers

I could not find such guarantees, but for what it's worth, I also think it would be exceedingly unlikely, because the standards committee is in general very concerned with anything that might break existing code. The allocator-aware design of std::vector and several other templates has been present since C++98. Additionally, you could say it is complete: it knows the type of its elements, and of the allocator that will handle (de)allocation of memory for those elements. What other template parameters could it need?

Related