Guest User

Untitled

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