Stack Distributor for C ++ 03 Standard Containers

For software, I should avoid using memory on the heap and rely only on memory allocated by the stack. Then it stops me from using any standard C ++ containers, such as a vector, map, string (well, basic_string), which I would really like to use to facilitate the development and processing of data.

I found (many) implementations of stack allocators, such as this one that itself refers to two others, or this one from chrome.

Many of them are not fully compatible with the standard or rely on C ++ 11 (and I'm stuck with C ++ 03 at the moment, unfortunately). Do you have any feedback on the existing stack allocator for C ++ 03 or should I adapt one of the above?

Thanks!

+5
source share
1 answer

Howard Hinnant short_alloc.h ( see also here ) is a good start (you will need to add the C ++ 03 template, see here ).

Of course, it will go to heap anyway, if it runs out of memory, the alternative is to throw std::bad_alloc .

+3
source

Source: https://habr.com/ru/post/1234707/


All Articles