I am trying to use multimap for the first time but my app will not compile. TIA Paul..
// file dept.h
typedef std::multimap <CString, std::map< CString, CString> > _DeparmentRecord; // also tryied replacing CString with LPCWSTR
_DeparmentRecord DeparmentRecord;
// file dept.cpp
DWORD CIni::AddNameValue(LPCWSTR Section, LPCWSTR Name, LPCWSTR Value)
{
DeparmentRecord.insert(std::make_pair ( Section, std::make_pair(Name, Value)) ); <-- error here
}
c:\program files\microsoft visual studio 9.0\vc\include\utility(57) : error C2664: ‘std::map<_Kty,_Ty>::map(const std::less<_Ty> &)’ : cannot convert parameter 1 from ‘const std::pair<_Ty1,_Ty2>’ to ‘const std::less<_Ty> &’
1> with
1> [
1> _Kty=CString,
1> _Ty=CString
1> ]
1> and
1> [
1> _Ty1=LPCWSTR,
1> _Ty2=LPCWSTR
1> ]
1> and
1> [
1> _Ty=CString
1> ]
1> Reason: cannot convert from ‘const std::pair<_Ty1,_Ty2>’ to ‘const std::less<_Ty>’
1> with
1> [
1> _Ty1=LPCWSTR,
1> _Ty2=LPCWSTR
1> ]
1> and
1> [
1> _Ty=CString
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1> c:\dev\projects\migrator\jobbuilder\jobbuilder\ini.cpp(55) : see reference to function template instantiation ‘std::pair<_Ty1,_Ty2>::pair>(const std::pair> &)’ being compiled
1> with
1> [
1> _Ty1=const CString,
1> _Ty2=std::map
1> ]
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Change the function as follows.