How to use typedef for a generic class in c++

Viewed 2016

I am trying to use unordered_map. But in some of the servers we don't have tr1 library. In those cases I want to use the map. So, I want to write a header file where I will use one of the following lines.

typedef tr1::unordered_map hashmap;
typedef map hashmap;

My Problem is I am using different types of maps here.

map<string, string>
map<string, int>
map <string, map<string,int>> ..etc

If I can use the typedef to alias map or unordered_map as hashmap, then I can use the map as hashmap<string, string> , hashmap<int, int> in the code.

Is there any way to do this or If there is any better way please suggest me.

Thanks Vinod

3 Answers
Related