C++中的HashCodeBuilder

wup*_*her 3 c++ java hashcode

如果我想在Java中为给定对象生成哈希,我知道的最简单方法是使用Apache Commons HashCodeBuilder:

public class Person {
   String name;
   int age;
   boolean smoker;
   ...

   public int hashCode() {
     // you pick a hard-coded, randomly chosen, non-zero, odd number
     // ideally different for each class
     return new HashCodeBuilder(17, 37).
       append(name).
       append(age).
       append(smoker).
       toHashCode();
   }
 }
Run Code Online (Sandbox Code Playgroud)

C++中有类似的东西吗?