View Single Post
Old Jan 2nd, 2007, 11:23 PM   #9
Game_Ender
Professional Programmer
 
Game_Ender's Avatar
 
Join Date: May 2006
Location: Maryland, USA
Posts: 306
Rep Power: 3 Game_Ender is on a distinguished road
This is completely possible in a type safe way as long as you know the type of the object you want to get out. Just use Boost.Any, sorry if that is not what is desired here, but with it you can make a type safe generic container. The only problem is Boost.Any can't down cast, so you need the exact type not a base class type, which can be limiting. With Boost.Any there is no need to add fields to a special structure every time you want to use a new type.

(Yeah- I do need more nails for my shiny Boost hammer)
Game_Ender is offline   Reply With Quote