I am trying to analyze a large C++ program. The program heavily uses STL container data structures like set, map, unordered set, unordered map, vector etc. Sometimes they are nested, e.g. map of sets.

I want to find out, in a particular run of the program, which containers hold the largest number of elements (i.e. largest value of size()). I can do minor edits to the program.

If there was a way to iterate over all the containers, or if there was a way to intercept the (size modifying) APIs of the containers, that might have been helpful. But these are not possible.

How would you approach this? 

Addition: The platform in Linux, compiler is either g++ or clang++.