Hi,
I'm trying to set up some code which uses a map to store data but I've been completely confounded by a segfault.
Here's the outline:
In code.cc, I #include code.hh. code.hh declares, as private,
std::map<G4int,G4VEMDataSet*,std::less<G4int> > dataMap;
where G4int and G4VEmDataSet are both working datatypes, properly included and everything.
In code.cc, I then have a function
1 2 3 4 5 6 7
|
void code::Clear()
{
if(!dataMap.empty())
{
...
}
}
|
I've used couts to verify that the segfault occurs at if(!dataMap.empty()) but this makes no sense to me because I would expect a compiler error if the map didn't exist or something, and if it exists, how can calling a built-in function give a segfault?
Also, I have #include <map> at the top of both my header and code files, and using namespace std at the top of both as well.
I hope I included everything relevant to the problem (this is all the places where the map is dealt with) but at least theoretically should this work?
Thanks very much