出于某种原因,我无法将值插入静态地图容器。我正在使用 VS2010,这是我的代码
Header File
class MyClass
{
static std::map<std::string,std::string> config_map;
static void SomeMethod();
};
Cpp File
std::map<std::string,std::string> MyClass::config_map ;
void MyClass::SomeMethod()
{
...
config_map.insert(std::pair<std::string,std::string>("dssd","Sdd")); //ERROR
}
这是我得到的错误
Unhandled exception at 0x0130ca29 in Test.exe: 0xC0000005: Access violation reading location 0x00000004.
我也试过了config_map["str"] = "something"
。似乎我无法在其中插入任何内容。有什么建议么 ?
这个断点位于 xtree
_Pairib _Linsert(_Nodeptr _Node, bool _Leftish)
{ // try to insert node at _Node, on left if _Leftish
const value_type& _Val = this->_Myval(_Node);
_Nodeptr _Trynode = _Root(); //Breakpoint lands here
_Nodeptr _Wherenode = this->_Myhead;
bool _Addleft = true; // add to left of head if tree empty
while (!this->_Isnil(_Trynode))
{ // look for leaf to insert before (_Addleft) or after
_Wherenode = _Trynode;
if (_Leftish)
_Addleft = !_DEBUG_LT_PRED(this->comp,
this->_Key(_Trynode),
this->_Kfn(_Val)); // favor left end
else
_Addleft = _DEBUG_LT_PRED(this->comp,
this->_Kfn(_Val),
this->_Key(_Trynode)); // favor right end
_Trynode = _Addleft ? this->_Left(_Trynode)
: this->_Right(_Trynode);
}