P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4::Util::Hasher< Key, Enable > Struct Template Reference

Detailed Description

template<class Key, class Enable = void>
struct P4::Util::Hasher< Key, Enable >

The implementation below decouples generic hash interface provider from a particular implementation for a given class T. One should partially-specialize Util::Hasher<T> to provide a hash value for T. Util::Hash is intended to be used instead of std::hash<T> in various associative containers. For example std::unordered_set<K, Util::Hash> would work as soon as there is an implementation of Util::Hasher<K>. The code below provides some default specializations for certain built-in types and theirs combinations (pairs and tuples). Additionally, hashes could be combined either directly (Hash::operator() is variadic) or via dedicated hash_combine / hash_combine_generic functions.