I\'m using a std::shared_ptr
in my application to make a smart pointer which can point to many different types of data structures like structs, vect
If you store void*
, then at every use point you need to know the exact type you put in, as a cast-to-void*
-and-back is only valid if you go to/from the exact same type (not derived-to-void-to-base, for example).
Given that every use point will require knowing the type of the stored pointer, why round trip to void at all?
Have one map per type you store. This has modest overhead over one map per application (O(number of types) memory at run time, similar compile time).
With C++ template
s there will be little code duplication.