I've gone through the Unreal Engine source code and I found that they use their own container classes, for example an in-house dynamic array. But the C++ STL provides (almost) all the necessary container classes that will be required. So why do they spend time developing the same containers again? Wouldn't it be easier for the developers to use containers such as std::vector
to write their code rather than trying to figure out how to do things using the TArray
class in the engine?
There are several reasons why a project might not use STL containers:
The containers used in the project are tailor-made to have certain performance characteristics that are different from the STL versions.
The STL containers might not even have existed when the custom containers were designed, and it's not worth the effort to make such a large change to a working project.
While most developers are used to STL containers, most contributors to a particular project might actually be more used to the custom versions, and how they should be used, and retraining all of them might not be worth the effort either.
For any particular project, some, or all of the above, and even other reasons might contribute to the decision to use custom containers.
In addition to the reasons mentioned by @cigien - even if the developers of such applications don't need a tailor-made container, it's still the case that several standard-library containers are simply quite slow, e.g.:
- Why is std::unordered_map slow, and can I use it more effectively to alleviate that?
- std::vector typically/always uses heap allocation, not a small-vector optimization (like short-string optimization but for vectors)
© 2022 - 2024 — McMap. All rights reserved.