View difference between Paste ID: Pn9mTUrg and s3WQPgUc
SHOW: | | - or go back to the newest paste.
1
template <class T>
2-
class StringCache
2+
class StringCache {
3-
{
3+
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;