1

I have a large codebase I want it to log when the STL performs an allocation. So far you might think "custom allocator" and done.

What I don't want is to have to go through every container used on this thing and add some customer allocator to the template params. Is there some way I can just inherit from std::alloc, decorate the relevant function with a log statement (ideally wrapped in a macro for FILE and LINE) and then get the STL to use that as its default. Or do you have to be horribly intrusive to the entire codebase here?

reference this kind of thing for STL allocations: https://stackoverflow.com/a/583079/3995687

Community
  • 1
  • 1
Hal
  • 1,061
  • 7
  • 20

0 Answers0