Created
August 4, 2012 16:36
-
-
Save marionette-of-u/3258717 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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