Skip to content

Instantly share code, notes, and snippets.

@marionette-of-u
Created August 4, 2012 16:36
Show Gist options
  • Save marionette-of-u/3258717 to your computer and use it in GitHub Desktop.
Save marionette-of-u/3258717 to your computer and use it in GitHub Desktop.
#include <typeinfo>
#include <map>
struct A{};
struct B{};
struct type_info_cmp{
bool operator ()(const std::type_info *lhs, const std::type_info *rhs) const{
return lhs->before(*rhs) != 0;
}
};
int main(){
A a;
B b;
std::map<const std::type_info*, std::string, type_info_cmp> map;
map[&typeid(a)] = "A";
map[&typeid(b)] = "B";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment