Use the following approach
inode_ptr i = NULL;
auto it = directories.find("string");
if ( it != directories.end() ) i = it->second;
Maybe it is even better to write
inode_ptr i = {};
instead of
inode_ptr i = NULL;
solved how to retrieve value from map c++ [closed]