I want to use reference in std::map
typedef const std::function<void(const cocos2d::Ref*)>& callBack;
std::map<const std::string&, callBack> m_mapListener
and my error message is:
error C2535: 'const std::function<void (const cocos2d::Ref *)> &std::map<const std::string &,callBack,
std::less<_Kty>,std::allocator<std::pair<_Kty,_Ty>>>::operator [](const std::basic_string
<char,std::char_traits<char>,std::allocator<char>> &)' :
member function already defined or declared
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\map
How could I fix it?
std::function. Next time perform some experimentation, such as taking away thestd::functionand seeing whether your problem remains (which it does). Also, present proper testcases in your questions: here your error message complains aboutoperator[], but you don't ever show us actually usingoperator[]. It's pure chance that we can fix the problem for you regardless.