C++ (Qt)template <class T> void add(const QString & key, const T & data) { map[key] = QVariant::fromValue(data);}
class IObserver{ typedef QPair<void*, QVariant::Type> MapData; QMap<QString, MapData> map;public: template <class T> void add(QString key, T *data) {map[key] = MapData(data, QVariant::fromValue(*data).type());} virtual void set(QString key, QVariant data);};