`std::vector` is often said to be the default container, because it provides good baseline performance for common operations. Recently, I experimented with a simple API change that can improve the performance of a common usage pattern by 10+ %.
emplace controls the construction of the object added to the collection. It’s also important but not related to the problem exposed by OP which is “how to remove the capacity check when we know statically that there is enough space”.
Ok, but why did you not use emplace?
emplace
controls the construction of the object added to the collection. It’s also important but not related to the problem exposed by OP which is “how to remove the capacity check when we know statically that there is enough space”.