I am writing a COM wrapper for a COM object that sends different types of values from a client and want to map these types in a Map to their actual C++ type, such as VT_BSTR to a wstring, etc.
I was thinking of defining an enumuration of all COM Variant types and then using a map to have that Enum as the key and the actual type containing the retrieved value, however I'm running into the issue that I cannot seem to find a global type to put in my map that I can cast to a string or double or whatever is handed to me to place in the map.
Perhaps my thinking of how to do this is entirely wrong, please advice?
I was thinking of a void pointer, however it seems the compiler doesn't like my casts:
(example)
enum Type
{
VT_INTEGER=0,
VT_DBL=1
};
map<Type, void*> typemap;
typedef pair<Type, void*> m_typepair;
typemap.insert( m_typepair(VT_INTEGER, 0));
typemap.insert( m_typepair(VT_DBL, (double)2.5)); // it does not like this cast
map<Type, void*>::iterator m_typeiter;
Iterating this map would probably need a switch statement inside to find the right type, I'm not sure if there is a better way?