Author: Yuriy Chernyshov Date: 2020-12-08T13:46:18-05:00 New Revision: b526d8761895643cb42e62997240344420d65e0f
URL: https://github.com/llvm/llvm-project/commit/b526d8761895643cb42e62997240344420d65e0f DIFF: https://github.com/llvm/llvm-project/commit/b526d8761895643cb42e62997240344420d65e0f.diff LOG: [libc++] Add std::hash<char8_t> specialization if char8_t is enabled Differential Revision: https://reviews.llvm.org/D92325 Added: Modified: libcxx/include/functional libcxx/include/utility Removed: ################################################################################ diff --git a/libcxx/include/functional b/libcxx/include/functional index 22c73c5790bd..ffcff35f6e4d 100644 --- a/libcxx/include/functional +++ b/libcxx/include/functional @@ -470,6 +470,7 @@ template <> struct hash<bool>; template <> struct hash<char>; template <> struct hash<signed char>; template <> struct hash<unsigned char>; +template <> struct hash<char8_t>; // since C++20 template <> struct hash<char16_t>; template <> struct hash<char32_t>; template <> struct hash<wchar_t>; diff --git a/libcxx/include/utility b/libcxx/include/utility index 2af552b4b347..6f27af70646b 100644 --- a/libcxx/include/utility +++ b/libcxx/include/utility @@ -1364,6 +1364,16 @@ struct _LIBCPP_TEMPLATE_VIS hash<unsigned char> size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast<size_t>(__v);} }; +#ifndef _LIBCPP_NO_HAS_CHAR8_T +template <> +struct _LIBCPP_TEMPLATE_VIS hash<char8_t> + : public unary_function<char8_t, size_t> +{ + _LIBCPP_INLINE_VISIBILITY + size_t operator()(char8_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} +}; +#endif // !_LIBCPP_NO_HAS_CHAR8_T + #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS template <> _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits