Advertisement
Guest User

Untitled

a guest
Sep 14th, 2014
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. template <class T>
  2. class StringCache {
  3. public:
  4.     static int get(const std::string &value) {
  5.         return Type(_values.insert(std::make_pair(value, _values.size() + 1)).first->second);
  6.     }
  7.     static int find(const std::string &value) {
  8.         auto it =_values.find(value);
  9.         return it != _values.end() ? it->second : 0;
  10.     }
  11. private:
  12.     static std::map<std::string,int> _values;
  13. };
  14. template <class T>
  15. std::map<std::string,int> StringCache<T,int>::_values;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement