std::string_view compile time hashing
问题 It seems the std::hash functions for the C++17 string_view are not constexpr's. It seems to me that a string view bound to a const char[] could be hashed at compile time (which would be very sweet), or is there anything which prevents this? 回答1: Since C++14 (see 17.6.3.4 Hash requirements, table 26), we have: The value returned shall depend only on the argument k for the duration of the program. [Note: Thus all evaluations of the expression h(k) with the same value for k yield the same result