2 //===------------------------- hash_set ------------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP_EXT_HASH
11 #define _LIBCPP_EXT_HASH
13 #pragma GCC system_header
20 template <typename _Tp> struct _LIBCPP_TEMPLATE_VIS hash { };
22 template <> struct _LIBCPP_TEMPLATE_VIS hash<const char*>
23 : public std::unary_function<const char*, size_t>
25 _LIBCPP_INLINE_VISIBILITY
26 size_t operator()(const char *__c) const _NOEXCEPT
28 return std::__do_string_hash(__c, __c + strlen(__c));
32 template <> struct _LIBCPP_TEMPLATE_VIS hash<char *>
33 : public std::unary_function<char*, size_t>
35 _LIBCPP_INLINE_VISIBILITY
36 size_t operator()(char *__c) const _NOEXCEPT
38 return std::__do_string_hash<const char *>(__c, __c + strlen(__c));
42 template <> struct _LIBCPP_TEMPLATE_VIS hash<char>
43 : public std::unary_function<char, size_t>
45 _LIBCPP_INLINE_VISIBILITY
46 size_t operator()(char __c) const _NOEXCEPT
52 template <> struct _LIBCPP_TEMPLATE_VIS hash<signed char>
53 : public std::unary_function<signed char, size_t>
55 _LIBCPP_INLINE_VISIBILITY
56 size_t operator()(signed char __c) const _NOEXCEPT
62 template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>
63 : public std::unary_function<unsigned char, size_t>
65 _LIBCPP_INLINE_VISIBILITY
66 size_t operator()(unsigned char __c) const _NOEXCEPT
72 template <> struct _LIBCPP_TEMPLATE_VIS hash<short>
73 : public std::unary_function<short, size_t>
75 _LIBCPP_INLINE_VISIBILITY
76 size_t operator()(short __c) const _NOEXCEPT
82 template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned short>
83 : public std::unary_function<unsigned short, size_t>
85 _LIBCPP_INLINE_VISIBILITY
86 size_t operator()(unsigned short __c) const _NOEXCEPT
92 template <> struct _LIBCPP_TEMPLATE_VIS hash<int>
93 : public std::unary_function<int, size_t>
95 _LIBCPP_INLINE_VISIBILITY
96 size_t operator()(int __c) const _NOEXCEPT
102 template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned int>
103 : public std::unary_function<unsigned int, size_t>
105 _LIBCPP_INLINE_VISIBILITY
106 size_t operator()(unsigned int __c) const _NOEXCEPT
112 template <> struct _LIBCPP_TEMPLATE_VIS hash<long>
113 : public std::unary_function<long, size_t>
115 _LIBCPP_INLINE_VISIBILITY
116 size_t operator()(long __c) const _NOEXCEPT
122 template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned long>
123 : public std::unary_function<unsigned long, size_t>
125 _LIBCPP_INLINE_VISIBILITY
126 size_t operator()(unsigned long __c) const _NOEXCEPT
133 #endif // _LIBCPP_EXT_HASH