So basically a few hours ago, I was working on my project and something that I didn't touch at all broke for no apparent reason. This code:
CFilesystem::working_directory_t &CFilesystem::GetThreadDirectories( )
{
const auto dwThread = GetCurrentThreadId( );
const auto pSearch = _ThreadDirectories.find( dwThread );
volatile auto b = pSearch == _ThreadDirectories.end( );
if ( pSearch == _ThreadDirectories.end( ) )
{
_ThreadDirectories.insert( std::pair< DWORD, working_directory_t >( dwThread, working_directory_t( ) ) );
return GetThreadDirectories( );
}
return pSearch->second;
}
struct working_directory_t
{
std::string strWorkingDirectory;
std::stack< std::string > _DirectoryStack;
working_directory_t( ) = default;
void StoreCurrentWorkingDirectory( );
void RestoreWorkingDirectory( );
};
std::map< DWORD, working_directory_t > _ThreadDirectories { };
doesn't want to work anymore. When this is run, the variables look like this:
For whatever reason, the variable, b, evaluates to false, even though pSearch clearly equals end, as shown in the image. If I drag the yellow arrow into the if statement to execute the code that inserts into _ThreadDirectories, I get an exception thrown as follows:
I've tried rebuilding, restarting Visual Studio 2019 and my PC. I've tried inlining the CFileSystem declaration rather than externing it to see if that would make a difference, but it didn't. I have no idea what's happened and I'd appreciate any help. Thanks in advance.