3.索引与string进行映射实现高效查找

 1 #include <iostream>
 2 #include <typeindex>//类型索引
 3 #include <unordered_map>//红黑树
 4 #include <string>
 5 using namespace std;
 6 
 7 class myclass
 8 {
 9 
10 };
11 
12 void main()
13 {
14     //索引与string进行映射
15     unordered_map<type_index, string> mytype;//类型与字符串映射
16     mytype[typeid(int)] = "整数类型";
17     mytype[typeid(double)] = "整数类型";
18     mytype[typeid(myclass)] = "我的类";
19 
20     cout << mytype[typeid(int)] << endl;
21     cout << mytype[typeid(double)] << endl;
22     cout << mytype[typeid(myclass)] << endl;
23     cin.get();
24 }
原文地址:https://www.cnblogs.com/xiaochi/p/8576830.html