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

fix(core): fix std hash for xcode15 #3442

Merged
merged 1 commit into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -136,6 +136,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 @@ -4,6 +4,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
Loading