I am following http://www.cplusplus.com/reference/map/map/map/.
I am trying to build an invert index structure, which is a map that has a 64 bits integer as a key and each key will hold a pointer to a sub-map. A sub-map will contain int int pair. So I got myself writing some samples:
map<unsigned long long int, map<int, int>*> invertID;
int main(int argc, char *argv[]){
map<int,int>* m = new map<int,int>();
m[10] = 1;
invertID[1] = m;
return 0;
}
But here is the trouble, normally, for a non-pointer type map like
std::map<char,int> first;
as described in http://www.cplusplus.com/reference/map/map/map/, I see that we can do
first['a']= 10;
But if we have a pointer type for map, how can we do that? My code above will generate an error complaining
error C2679: binary '=' : no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversion)
You can de-reference the pointer:
or
On the other hand, do you really need all these pointers? Would your program suffer greatly from using this form?