Consider that the data.first is a pointer to the base class and I want to call the serialize of the derived class which is not virtual
which still looks like a bad idea to me. But it might be what you want.
Really I'm not aware of a storage mechanism for a heterogeneous container without using virtual functions in time of accessing data which means less performace for us. In this sudo code the accessing mechanism is not menssioned but it is fast and typesafe (it can be seen here http://kratos.cimne.upc.es/trac/browser/kratos/kratos/containers/data_value_...)
Of course any suggestion will be very welcome!!
First of all - focusing on this aspect of performance at this stage in development is a bad idea. Try the following: a) Make your container interface. b) Implement it using the the easiest method c) Make a test program for it d) Profile it e) Enhance the implementation to improve performance bottlenecks. That is the fastest way to make the fastest code. To do this (e), you need to know more about how the serialization library works internally. Most of this is available in the documentation - but it would also require investment of effort in studying some of the dozens of examples and tests included with the library. The serialization library only uses virtual types for a couple of special types inside the library implemenation. Even re-constitution of virtual types created by the user don't use any calls to virtual functions. This should be apparent from study of the document tests and examples. Also, for a heterogenous container, you might look at several approaches. One is a container of boost.variant or boost.any. The former doesn't use virtual functions at all. Study of all of this seems like a lot of work - and it is. But ultimately it will be faster and give a better result than trying to speculate on an optimal solution and then trying to make the serialization library fit it. The easiest and best way to make a 12 inch telescope lens is to make a 2 inch one first. Robert Ramey