Skip to content

Commit

Permalink
fix(core): fix std hash for xcode15
Browse files Browse the repository at this point in the history
  • Loading branch information
etkmao authored and hippy-actions[bot] committed Sep 19, 2023
1 parent d7aef60 commit 28a0e36
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions modules/footstone/include/footstone/string_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,15 @@ class string_view final {
} // namespace stringview
} // namespace footstone

#ifdef __APPLE__
#if defined(__clang__) && __clang_major__ >= 15
template<>
struct std::hash<footstone::stringview::string_view::u8string> {
std::size_t operator()(const footstone::stringview::string_view::u8string& value) const noexcept;
};
#endif
#endif

template<>
struct std::hash<footstone::stringview::string_view> {
std::size_t operator()(const footstone::stringview::string_view& value) const noexcept;
Expand Down
9 changes: 9 additions & 0 deletions modules/footstone/src/string_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@

using string_view = footstone::stringview::string_view;

#ifdef __APPLE__
#if defined(__clang__) && __clang_major__ >= 15
std::size_t std::hash<footstone::stringview::string_view::u8string>::operator()(
const footstone::stringview::string_view::u8string& value) const noexcept {
return std::hash<std::string>()(std::string(value.begin(), value.end()));
}
#endif
#endif

#if defined(__GLIBC__) && !defined(__cpp_char8_t)
std::size_t std::hash<string_view::u8string>::operator()(
const string_view::u8string& value) const noexcept {
Expand Down

0 comments on commit 28a0e36

Please sign in to comment.