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 zealotchen0 committed Aug 7, 2023
1 parent c8c16c2 commit 6607478
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/third_party/base/include/base/unicode_string_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ class unicode_string_view final {
} // namespace base
} // namespace tdf

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

template <>
struct std::hash<tdf::base::unicode_string_view> {
std::size_t operator()(const tdf::base::unicode_string_view& value) const noexcept;
Expand Down
9 changes: 9 additions & 0 deletions core/third_party/base/src/base/unicode_string_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@

using unicode_string_view = tdf::base::unicode_string_view;

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

std::size_t std::hash<unicode_string_view>::operator()(
const unicode_string_view& value) const noexcept {
switch (value.encoding_) {
Expand Down

0 comments on commit 6607478

Please sign in to comment.