Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <class T>
- class StringCache {
- public:
- static int get(const std::string &value) {
- return Type(_values.insert(std::make_pair(value, _values.size() + 1)).first->second);
- }
- static int find(const std::string &value) {
- auto it =_values.find(value);
- return it != _values.end() ? it->second : 0;
- }
- private:
- static std::map<std::string,int> _values;
- };
- template <class T>
- std::map<std::string,int> StringCache<T,int>::_values;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement