Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hash of *std::*string_view must equal hash of corresponding std::string object #58

Open
martinmoene opened this issue Jan 12, 2018 · 0 comments

Comments

@martinmoene
Copy link

std::hash<std::string_view> on cppreference

Section 24.4.5 in C++ 17 working draft N4659: Hash support:

Note: The hash value of a string view object is equal to the hash value of the corresponding string object.

Currently the following tests fail and although it's not std::string_view, you might consider this for core::string_view.

  SECTION("hash-std::string") {
      CHECK( std::hash<core::string_view>()("hello") == std::hash<std::string>()("hello") );
      CHECK( std::hash<core::string_view>()("world") == std::hash<std::string>()("world") );
  }
prompt> test-string-view.exe --reporter compact
string-view.cpp:383: failed: std::hash<core::string_view>()("hello") == std::hash<std::string>()("hello") for: 2191231550387646743 == 2762169579135187400
string-view.cpp:384: failed: std::hash<core::string_view>()("world") == std::hash<std::string>()("world") for: 5568329560871645431 == 8751027807033337960
Failed 1 test case, failed 2 assertions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant