This is one of reasons why “C# fanboys” want C++ to die lol
To make your life easier you can iterate an index backwards while changing the array.
Instead of doing “for &item…” you can do
for (int32 i = inventory.Num()-1; i > INDEX_NONE; --i)
inventory*… // do things