map not initialised properly, Pnode is null

  • Thread starter Thread starter Dave Curtis
  • Start date Start date
D

Dave Curtis

Guest
I have this code:

std::map<string,fType> FileMap::fTypeMap;

void FileMap::setTypes()
{

// project file
fTypeMap["FIDX"] = FIDX;

// etc

}

(fType is an enum)

This line crashes at runtime with an exception. If I step through the insert call I encounter the following:

mapped_type& operator[](key_type&& _Keyval)
{ // find element matching _Keyval or insert with default mapped
iterator _Where = this->lower_bound(_Keyval);

iterator lower_bound(const key_type& _Keyval)
{ // find leftmost node not less than _Keyval in mutable tree
return (iterator(_Lbound(_Keyval), this));
}

_Nodeptr _Lbound(const key_type& _Keyval)
{ // find leftmost node not less than _Keyval
_Nodeptr _Pnode = _Root();
_Nodeptr _Wherenode = this->_Myhead; // end() if search fails


_Nodeptr& _Root() const
{ // return root of nonmutable tree
return (this->_Parent(this->_Myhead));
}

This returns 0.

I don't understand this. The tree for the map seems not to have been set up. I don't see any tests to see whether the tree needs to be initialised.

This seems like a simple insertion. Why doesn't it work? Is it anything to do with the fact that the declaration is static and some constructor has not been called?

I'm baffled.

Continue reading...
 
Back
Top