Original Post
Hi, I have been trying to create a messaging system. Here is the intro code: typedef std::type_info const *TypeIdPtr; class MsgContainer { public: template MsgContainer(msgDataT &msgData):mType(&typeid(msgDataT)){} TypeIdPtr mType; }; template class Msg: public MsgContainer { public: msgDataT mData; Msg() : MsgContainer(mData) {} }; So as you can see. My Msg can hold anything. For e.g: typedef struct MyMsg { int data1; int data2; } When I send the message, i pass a pointer to the Msg class that holds MyMsg. On the receiving end, I wish to typecast this pointer to the MsgContainer class, and identify the type of the contained Msg. I have just started reading about the std::type_info class but I do not think there is a way to actually get the type. i.e : Msg here. I want to ust the type_info to create an object of Msg, but obviously this cant be done. Is there a way around this. I have no way of knowing the actual type through std::type_info? Please let me know if I am not very clear. Also, I was wondering what are the issues with using RTTI in terms of performance? Thanks, Bhavan