The std::unordered_set does not support a lambda implementation of find(). This means the template type must be created to get a key comparison. In the key cache case the type is a shared_ptr which is a relatively expensive object. It is much preferred to compare the field count and the hash without the expense of creating a smart pointer instance.