Why "Access Violent" throw when insert pair object into std::map
i met this problem:
//=====head file====
#include <map>
....
Class CDataCell{...};
Class CADTNode
{...
private:
std::map<int, CDataCell> m_mapCellCollection;
public:
bool InsertCell(int nSign, CDataCell& objNewCell);
....};
//=====source file=====
....
bool CADTNode::Insert(int nSign, CDataCell& objNewCell)
{
std::pair<std::map<int, CDataCell>::iterator, bool> ret =
m_mapCellCollection.insert(std::map<int,
CDataCell>::value_type(nSign, objNewCell); //throw an error said
"0x000005, Access violent"
....
}
//=====End====
Debug with F11 found where throw this exception:
//====..\VC98\Include\stlport\stl\_tree.h======
....
template <class _Key, class _Value, class _KeyOfValue,
class _Compare, class _Alloc> __iterator__
_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> ::insert_equal(const
_Value& __v)
{
_Link_type __y = this->_M_header._M_data;
//==============================
_Link_type __x = _M_root(); //THROW THE EXCEPTION
//==============================
while (__x != 0) {
__y = __x;
__x = _M_key_compare(_KeyOfValue()(__v), _S_key(__x)) ?
_S_left(__x) : _S_right(__x);
}
return _M_insert(__x, __y, __v);
}
my os is Win2003Enterprise
my develop environment is VC++6.0 SP6 + stlport(version unknown -_-!)
i have little known about stlport and pls help me.
thanks a lot!