`The following function compiles using Xcode 6.1:
void attach(const std::string& command, std::function<void()> callback)
{
std::vector<std::function<void()>> v;
v.push_back(callback);
m_observers.insert(std::make_pair(command, v)); // causes the crash
}
but when it is called as follows:
attach("xxx", std::bind(&X::callback, this));
it crashes in a function called __tree_balance_after_insert in __tree in the std library.
m_observers is declared as:
std::map<std::string, std::vector<std::function<void()>>> m_observers;
X::callback is declared as void X::callback().
Can someone explain what is going wrong?
Aucun commentaire:
Enregistrer un commentaire