2 //===----------------------------------------------------------------------===//
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
22 template <typename _Tp> struct _LIBCPP_TEMPLATE_VIS hash { };
24 template <> struct _LIBCPP_TEMPLATE_VIS hash<const char*>
25 : public std::__unary_function<const char*, size_t>
27 _LIBCPP_INLINE_VISIBILITY
28 size_t operator()(const char *__c) const _NOEXCEPT
30 return std::__do_string_hash(__c, __c + strlen(__c));
34 template <> struct _LIBCPP_TEMPLATE_VIS hash<char *>
35 : public std::__unary_function<char*, size_t>
37 _LIBCPP_INLINE_VISIBILITY
38 size_t operator()(char *__c) const _NOEXCEPT
40 return std::__do_string_hash<const char *>(__c, __c + strlen(__c));
44 template <> struct _LIBCPP_TEMPLATE_VIS hash<char>
45 : public std::__unary_function<char, size_t>
47 _LIBCPP_INLINE_VISIBILITY
48 size_t operator()(char __c) const _NOEXCEPT
54 template <> struct _LIBCPP_TEMPLATE_VIS hash<signed char>
55 : public std::__unary_function<signed char, size_t>
57 _LIBCPP_INLINE_VISIBILITY
58 size_t operator()(signed char __c) const _NOEXCEPT
64 template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>
65 : public std::__unary_function<unsigned char, size_t>
67 _LIBCPP_INLINE_VISIBILITY
68 size_t operator()(unsigned char __c) const _NOEXCEPT
74 template <> struct _LIBCPP_TEMPLATE_VIS hash<short>
75 : public std::__unary_function<short, size_t>
77 _LIBCPP_INLINE_VISIBILITY
78 size_t operator()(short __c) const _NOEXCEPT
84 template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned short>
85 : public std::__unary_function<unsigned short, size_t>
87 _LIBCPP_INLINE_VISIBILITY
88 size_t operator()(unsigned short __c) const _NOEXCEPT
94 template <> struct _LIBCPP_TEMPLATE_VIS hash<int>
95 : public std::__unary_function<int, size_t>
97 _LIBCPP_INLINE_VISIBILITY
98 size_t operator()(int __c) const _NOEXCEPT
104 template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned int>
105 : public std::__unary_function<unsigned int, size_t>
107 _LIBCPP_INLINE_VISIBILITY
108 size_t operator()(unsigned int __c) const _NOEXCEPT
114 template <> struct _LIBCPP_TEMPLATE_VIS hash<long>
115 : public std::__unary_function<long, size_t>
117 _LIBCPP_INLINE_VISIBILITY
118 size_t operator()(long __c) const _NOEXCEPT
124 template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned long>
125 : public std::__unary_function<unsigned long, size_t>
127 _LIBCPP_INLINE_VISIBILITY
128 size_t operator()(unsigned long __c) const _NOEXCEPT
133 } // namespace __gnu_cxx
135 #endif // _LIBCPP_EXT_HASH