Template Struct HashPtr

Struct Documentation

template<class T>
struct HashPtr

Hashes a pointer to an object using the address the pointer points to.

If two pointers point to the same address, they hash to the same value. Useful to put widely shared_ptrs of entities (eg: TranslationModel, Vocab, Shortlist) etc into containers which require the members to be hashable (std::unordered_set, std::unordered_map).

Public Functions

size_t operator()(const std::shared_ptr<T> &t) const