0

And to infer T from x instead? Obviously I can declare a function to do this:

template <typename T>
size_t get_std_hash(const T& x) {
    return std::hash<T>{}(x);
}

The question is in case I've overlooked something, and this function or some variation of it is already in the standard.

Alexey Romanov
  • 167,066
  • 35
  • 309
  • 487
  • 2
    Are you asking if the standard already provides a function that does the same thing as your `get_std_hash`? AFAIK no. – Lukas-T Oct 22 '21 at 14:33
  • 2
    as an expression? `std::hash{}(x)`? – Caleth Oct 22 '21 at 14:37
  • @Caleth I thought of that, but `x` can be a non-trivial expression, and I want to avoid repeating it for the same reason I don't want to specify `T` in the first place. – Alexey Romanov Oct 22 '21 at 14:43

0 Answers0