2つのリストと名前があります。検索する名前が最初のリストにない場合は、2番目のリストにわずかに異なる形式で表示されます。 2つの形式間の変換関数が与えられています。表示された新しいペアをstd :: map <CString、CString>に挿入します。
std::map<CString, CString>* convertedNames;
BOOL CSome::SeekNameWithConversion(std::set<CString> names, CString nameToFind)
{
for (auto it = names.begin(); it != names.end(); ++it)
{
if (nameToFind.Compare(*it) == 0) return true;
auto convertedIt = convertedNames->find(*it);
if (convertedIt != convertedNames->end() &&
nameToFind.Compare(convertedIt->second) == 0)
return true;
CString justConvertedName = ConvertToTheOtherFormat(nameToFind);
convertedNames->insert(*it, justConvertedName); // Error here
return nameToFind.Compare(justConvertedName) == 0;
}
}
エラーは次のとおりです。
error C2675: unary '++':
'ATL::CStringT<char,StrTraitMFC_DLL<char,ATL::ChTraitsCRT<_CharType>>>' does
not define this operator or a conversion to a type acceptable to the
predefined operator
私はオペレータ++
がここに関与している理由を知りたいのですが、その後どのように私はこのエラーを処理する必要があります。
'std :: set names' - 値ではなく、const参照で渡す必要があります。 –
PaulMcKenzie
@PaulMcKenzie確かに、ありがとう。 – tomab