And thus spake "Wu Yinghui, Freddie"
1) Store the POD directly in your container. AFAIK, copying 2 integers in and out of the container is not heavy at all in most cases. So that might help remove the trouble of using shared_ptr all together.
Well, my example was boiled-down. In fact, so very much boiled down that it did not allow me to see that my problem was in fact connected to my actual structure, which is a POD container a bit larger than 2 integers. Furthermore it is used a lot at different places, so copying a pointer is definitely cheaper-- even if it is a shared_ptr. The actual problem was PEBKAC: a supposed-to-be-static member (a stringstream), that was there for data conversion purposes and because it made more sense than making it global, was not after all static and got re-created thousands of times. So my POD container was not, after all, POD. Actually, I am a bit embarassed about this... lesson learned: never ever code at 3:00 in the morning, and if you do it anyway, look for problems in your own code rather than blaming some library...
2) If you insist on storing pointer to the POD in the container, why not take a look at Boost.Pointer_Container library? The library provides the whole range of containers for pointer types. Better still, memory management on destruction is automatic in the pointer containers.
Thanks for the suggestion, this sounds very interesting. I will definitely look into it. Regards, Robert