How to do casting map?
template <class S>
struct C {
S* operator()(void* c) { return (S*)c; }
};
Idea is that I can do:
C<QRadioButton> caster;
void* p = ??;
caster(p)->width();
where p is a pointer to a QRadioButton开发者_开发百科, but kept as a void*.
What I'd like to do is keep a map of caster objects, e.g.
map<std::string, ??> Caster;
Caster["radio"] = C<QRadioButton>;
Caster["checkbox"] = C<QCheckBox>;
So that I could do:
Caster["radio"](p)->width();
Any idea how to set this up?
I am not too sure, but it looks like you want to use Boost.Any
精彩评论