mercredi 29 mai 2019

Which C++ standard library functions allocate memory?

It's obvious that the collection classes with their class Allocator = std::allocator<T> parameter explicitly use heap allocations, but which other library functions (or indeed language features) can be expected to allocate memory in a practical implementation.

I know from this post that throw may be expected to (I don't have the spec to hand for the exact terminology) allocate memory for the stack trace, but where else may it occur?


Background: MISRA C++ 18-4-1 says "Dynamic heap allocation shall not be used", yet other rules cover the use of throw (15-0-1/2/3), and yet others (eg 3-4-1) have sample code using std::cout which I would expect to allocate memory.

Aucun commentaire:

Enregistrer un commentaire