vabold / Kinoko

A reimplementation of Mario Kart Wii's physics engine in C++
MIT License
46 stars 10 forks source link

Explore viability/necessity for creating our own container types #177

Open malleoz opened 23 hours ago

malleoz commented 23 hours ago

This is mainly regarding std::vector. We use vectors throughout Kinoko, even though Nintendo didn't have them. What we end up effectively having is some container always having a fixed upper bound, whereas std::vector is resizable. We could use spans, but then it's annoying to have to manage that every time we run into this scenario.

Explore why we should make our own container type and discuss some of the unique implementation details we could include, such as having ASSERTs in our push_back / emplace_back calls.

vabold commented 23 hours ago

std::span is only usable when the size and capacity of an array are the same. std::vector allows for incongruency between size and capacity, but handles cases in which the size can be greater than the capacity. We would prefer a container that guarantees the size will always be below or at a specified capacity, thus eliminating a lot of overhead.