效果:
进一步的优化:若需要用到的字符串枚举值很多,可以将strint_serv外包一层哈希查找/索引查找,以提高查找效率。
#include<assert.h>
#include<stdarg.h>
#include<string>
#include<map>
using std::map;
using std::string;
typedef map<string, int>strint;
class strint_serv//这个类绑定在函数中作为static使用。
{
private:
strint si;
int head;
public:
strint_serv(const char* keys,...) :si(),head(0)