Hello, I am writing an Apache module in C++. I need to store the common data that all childs need to read as a portion of shared memory. Structure is kind of map of vectors, so I want to use STL map and vectors for it. I have written a shared allocator and a shared manager for the purpose, they work fine for vectors but not for maps, below is the example:
typedef vector<CustomersData, SharedAllocator<CustomersData> > CustomerVector;
CustomerVector spData; //this one works fine
typedef SharedAllocator< pair< const int, CustomerVector > > PairAllocator;
typedef map<int, CustomerVector, less<int>, PairAllocator > SharedMap;
SharedMap spIndex; //this one doesn't work<
I get compile time errors when I try to use the second object (spIndex), which are someting like:
../SpatialIndex.h:97: error: '((SpatialIndex*)this)->SpatialIndex::spIndex' does not have class type
It looks like the compiler cannot determine a type for SharedMap template type, which is strange in my opinion, it seems to me that all the template parameters have been specified.
Can you help?
Thanks Benvenuto
Hello, thanks for your comments.
SpatialIndex is the class that contains the container, it basically made by the container (SharedMap spIndex; which is a member of SpatialIndex), and two methods, update and getData.
Whithin the update method the following line of code gives the compiler error above:
int spKey = this->calculateSpKey( customer.getLat(), customer.getLong() );
this->spIndex[spKey].push_back(customer);
Varying the sintax of the last line varies the error the compiler gives, but basically it says that it cannot understand which type variable spIndex is, or that it cannot find the appropriate overload constructor for this class.