TL;DR
- no exceptions
- no recursion
- no malloc()/free() in the inner-loop
replies(9):
- no exceptions
- no recursion
- no malloc()/free() in the inner-loop
My guess is that you're assuming all user defined types, and maybe even all non-trivial built-in types too, are boxed, meaning they're allocated on the heap when we create them.
That's not the case in C++ (the language in question here) and it's rarely the case in other modern languages because it has terrible performance qualities.
C++ is designed to make this pretty easy.