From b526d8761895643cb42e62997240344420d65e0f Mon Sep 17 00:00:00 2001 From: Yuriy Chernyshov Date: Tue, 8 Dec 2020 13:39:56 -0500 Subject: [PATCH] [libc++] Add std::hash specialization if char8_t is enabled Differential Revision: https://reviews.llvm.org/D92325 --- libcxx/include/functional | 1 + libcxx/include/utility | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/libcxx/include/functional b/libcxx/include/functional index 22c73c5790b..ffcff35f6e4 100644 --- a/libcxx/include/functional +++ b/libcxx/include/functional @@ -470,6 +470,7 @@ template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; +template <> struct hash; // since C++20 template <> struct hash; template <> struct hash; template <> struct hash; diff --git a/libcxx/include/utility b/libcxx/include/utility index 2af552b4b34..6f27af70646 100644 --- a/libcxx/include/utility +++ b/libcxx/include/utility @@ -1364,6 +1364,16 @@ struct _LIBCPP_TEMPLATE_VIS hash size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast(__v);} }; +#ifndef _LIBCPP_NO_HAS_CHAR8_T +template <> +struct _LIBCPP_TEMPLATE_VIS hash + : public unary_function +{ + _LIBCPP_INLINE_VISIBILITY + size_t operator()(char8_t __v) const _NOEXCEPT {return static_cast(__v);} +}; +#endif // !_LIBCPP_NO_HAS_CHAR8_T + #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS template <> -- 2.11.0