Skip to content

Commit 94bb5d6

Browse files
togeashvardanian
andauthored
Docs: C++ hashing example (#171)
--------- Co-authored-by: Ash Vardanian <[email protected]>
1 parent a34d836 commit 94bb5d6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,10 +665,10 @@ sz::string haystack = "some string";
665665
sz::string_view needle = sz::string_view(haystack).substr(0, 4);
666666
667667
auto substring_position = haystack.find(needle); // Or `rfind`
668-
auto hash = std::hash<sz::string_view>(haystack); // Compatible with STL's `std::hash`
668+
auto hash = std::hash<sz::string_view>{}(haystack); // Compatible with STL's `std::hash`
669669
670670
haystack.end() - haystack.begin() == haystack.size(); // Or `rbegin`, `rend`
671-
haystack.find_first_of(" \w\t") == 4; // Or `find_last_of`, `find_first_not_of`, `find_last_not_of`
671+
haystack.find_first_of(" \v\t") == 4; // Or `find_last_of`, `find_first_not_of`, `find_last_not_of`
672672
haystack.starts_with(needle) == true; // Or `ends_with`
673673
haystack.remove_prefix(needle.size()); // Why is this operation in-place?!
674674
haystack.contains(needle) == true; // STL has this only from C++ 23 onwards

0 commit comments

Comments
 (0)