Drake uses the hash_append pattern as described by N3980.
For a full treatment of the hash_append pattern, refer to: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3980.html
Drake types may implement a hash_append
function. The function appends every hash-relevant member field into the hasher:
Checklist for reviewing a hash_append
implementation:
@ref hash_append
in its Doxygen comment.noexcept
.Types that implement this pattern may be used in unordered collections:
Some Drake types may also choose to specialize std::hash<MyValue>
to use DefaultHash
, so that the second template argument to std::unordered_set
can be omitted. For example, Drake's symbolic::Expression
header says:
so that users are able to simply write: