dimanche 29 janvier 2017

How can I hash a std::regex?

I need to hash a class which has a std::regex as a member which is initialized from a string in the class' constructor.

To get a good hash for the class, I could either store the hash of the pattern string in the constructor or -- the preferred way -- compute a hash of the regex itself. Is this possible (preferrably without boost)?

More precisely: I would like to calculate

std::hash<std::regex>{}(m_regex);

where m_regex is of type std::regex, but the template specialization for std::regex does not exist.

Thanks very much for your help.

Aucun commentaire:

Enregistrer un commentaire