Simple user registry code in C++
std::unordered_map&lt;std::string, int&gt; is an overkill. Since you only need to track of a presence - which is naturally boolean - std::set&lt;std::string&gt; is enough. As a perk benefit, notice that std::set::insert indicates whether the insertion was successful or not (this is an anomaly), and std::set::erase return a number of elements erased (0 means the key was not there, another anomaly):

    std::set&lt;std::string&gt; registry;
    bool UserEntered(const std::string&amp; user) {
        return !registry.insert().second;
    }
    bool userExited(const std::string&amp; user) {
        return registry.erase(user) == 0;
    }


Now both methods return the anomaly:

    bool anomaly;
    if (action == "entered") {
        anomaly = userEntered(user);
    } else if(action == "exited") {
        anomaly = userExited(user);
    } else {
        // handle error here
        return;
    }
    LogAction(....);