c++game-enginestd

Why do big projects like Unreal Engine write their own container classes?


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?


Solution

  • There are several reasons why a project might not use STL containers:

    1. The containers used in the project are tailor-made to have certain performance characteristics that are different from the STL versions.

    2. 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.

    3. 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.