1// -*- C++ -*- 2//===------------------------- hash_set ------------------------------------===// 3// 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 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef _LIBCPP_EXT_HASH 11#define _LIBCPP_EXT_HASH 12 13#pragma GCC system_header 14 15#include <__string> 16#include <string> 17#include <cstring> 18 19namespace __gnu_cxx { 20 21template <typename _Tp> struct _LIBCPP_TEMPLATE_VIS hash { }; 22 23template <> struct _LIBCPP_TEMPLATE_VIS hash<const char*> 24 : public std::unary_function<const char*, size_t> 25{ 26 _LIBCPP_INLINE_VISIBILITY 27 size_t operator()(const char *__c) const _NOEXCEPT 28 { 29 return std::__do_string_hash(__c, __c + strlen(__c)); 30 } 31}; 32 33template <> struct _LIBCPP_TEMPLATE_VIS hash<char *> 34 : public std::unary_function<char*, size_t> 35{ 36 _LIBCPP_INLINE_VISIBILITY 37 size_t operator()(char *__c) const _NOEXCEPT 38 { 39 return std::__do_string_hash<const char *>(__c, __c + strlen(__c)); 40 } 41}; 42 43template <> struct _LIBCPP_TEMPLATE_VIS hash<char> 44 : public std::unary_function<char, size_t> 45{ 46 _LIBCPP_INLINE_VISIBILITY 47 size_t operator()(char __c) const _NOEXCEPT 48 { 49 return __c; 50 } 51}; 52 53template <> struct _LIBCPP_TEMPLATE_VIS hash<signed char> 54 : public std::unary_function<signed char, size_t> 55{ 56 _LIBCPP_INLINE_VISIBILITY 57 size_t operator()(signed char __c) const _NOEXCEPT 58 { 59 return __c; 60 } 61}; 62 63template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned char> 64 : public std::unary_function<unsigned char, size_t> 65{ 66 _LIBCPP_INLINE_VISIBILITY 67 size_t operator()(unsigned char __c) const _NOEXCEPT 68 { 69 return __c; 70 } 71}; 72 73template <> struct _LIBCPP_TEMPLATE_VIS hash<short> 74 : public std::unary_function<short, size_t> 75{ 76 _LIBCPP_INLINE_VISIBILITY 77 size_t operator()(short __c) const _NOEXCEPT 78 { 79 return __c; 80 } 81}; 82 83template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned short> 84 : public std::unary_function<unsigned short, size_t> 85{ 86 _LIBCPP_INLINE_VISIBILITY 87 size_t operator()(unsigned short __c) const _NOEXCEPT 88 { 89 return __c; 90 } 91}; 92 93template <> struct _LIBCPP_TEMPLATE_VIS hash<int> 94 : public std::unary_function<int, size_t> 95{ 96 _LIBCPP_INLINE_VISIBILITY 97 size_t operator()(int __c) const _NOEXCEPT 98 { 99 return __c; 100 } 101}; 102 103template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned int> 104 : public std::unary_function<unsigned int, size_t> 105{ 106 _LIBCPP_INLINE_VISIBILITY 107 size_t operator()(unsigned int __c) const _NOEXCEPT 108 { 109 return __c; 110 } 111}; 112 113template <> struct _LIBCPP_TEMPLATE_VIS hash<long> 114 : public std::unary_function<long, size_t> 115{ 116 _LIBCPP_INLINE_VISIBILITY 117 size_t operator()(long __c) const _NOEXCEPT 118 { 119 return __c; 120 } 121}; 122 123template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned long> 124 : public std::unary_function<unsigned long, size_t> 125{ 126 _LIBCPP_INLINE_VISIBILITY 127 size_t operator()(unsigned long __c) const _NOEXCEPT 128 { 129 return __c; 130 } 131}; 132} 133 134#endif // _LIBCPP_EXT_HASH 135