Can anyone think of a reason why map::find() isn't finding a name that definitely is in the map?
Code:
typedef std::map<std::wstring, bool> UserAdminChangeMap;
std::wstring strUserName( UserName->Buffer, UserName->Length ); // strUserName == L"Test1"
UserAdminChangeMap::iterator it = g_UserAdminChangeMap.find( strUserName ); // map has 1 key == L"Test1"
if ( it != g_UserAdminChangeMap.end() )
{
if ( it->second == true )
{
swprintf( GenericMessage, _T("*** User '%s' with admin flag found in map!"), strUserName.c_str() );
}
else
{
swprintf( GenericMessage, _T("*** User '%s' WITHOUT admin flag found in map!"), strUserName.c_str() );
}
g_UserAdminChangeMap.erase( it );
}
else
{
it = g_UserAdminChangeMap.begin();
swprintf( GenericMessage, _T("*** User (%04x %04x %04x %04x %04x %04x) NOT found in map!\nmap size = %u\nmap.first = (%04x %04x %04x %04x %04x %04x)"),
strUserName.c_str()[0], strUserName.c_str()[1], strUserName.c_str()[2], strUserName.c_str()[3], strUserName.c_str()[4], strUserName.c_str()[5],
g_UserAdminChangeMap.size(),
it->first.c_str()[0], it->first.c_str()[1], it->first.c_str()[2], it->first.c_str()[3], it->first.c_str()[4], it->first.c_str()[5] );
}
It prints this into GenericMessage:
Code:
*** User (0054 0065 0073 0074 0031 0000) NOT found in map!
map size = 1
map.first = (0054 0065 0073 0074 0031 0000)