codekingpro/portable-devtools
114k
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-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCUDACXX_EXT_HASH11#define _LIBCUDACXX_EXT_HASH12 13#pragma GCC system_header14 15#include <string>16#include <cstring>17 18namespace __gnu_cxx {19 20template <typename _Tp> struct _LIBCUDACXX_TEMPLATE_VIS hash { };21 22template <> struct _LIBCUDACXX_TEMPLATE_VIS hash<const char*>23 : public std::__unary_function<const char*, size_t>24{25 _LIBCUDACXX_INLINE_VISIBILITY26 size_t operator()(const char *__c) const noexcept27 {28 return std::__do_string_hash(__c, __c + strlen(__c));29 }30};31 32template <> struct _LIBCUDACXX_TEMPLATE_VIS hash<char *>33 : public std::__unary_function<char*, size_t>34{35 _LIBCUDACXX_INLINE_VISIBILITY36 size_t operator()(char *__c) const noexcept37 {38 return std::__do_string_hash<const char *>(__c, __c + strlen(__c));39 }40};41 42template <> struct _LIBCUDACXX_TEMPLATE_VIS hash<char>43 : public std::__unary_function<char, size_t>44{45 _LIBCUDACXX_INLINE_VISIBILITY46 size_t operator()(char __c) const noexcept47 {48 return __c;49 }50};51 52template <> struct _LIBCUDACXX_TEMPLATE_VIS hash<signed char>53 : public std::__unary_function<signed char, size_t>54{55 _LIBCUDACXX_INLINE_VISIBILITY56 size_t operator()(signed char __c) const noexcept57 {58 return __c;59 }60};61 62template <> struct _LIBCUDACXX_TEMPLATE_VIS hash<unsigned char>63 : public std::__unary_function<unsigned char, size_t>64{65 _LIBCUDACXX_INLINE_VISIBILITY66 size_t operator()(unsigned char __c) const noexcept67 {68 return __c;69 }70};71 72template <> struct _LIBCUDACXX_TEMPLATE_VIS hash<short>73 : public std::__unary_function<short, size_t>74{75 _LIBCUDACXX_INLINE_VISIBILITY76 size_t operator()(short __c) const noexcept77 {78 return __c;79 }80};81 82template <> struct _LIBCUDACXX_TEMPLATE_VIS hash<unsigned short>83 : public std::__unary_function<unsigned short, size_t>84{85 _LIBCUDACXX_INLINE_VISIBILITY86 size_t operator()(unsigned short __c) const noexcept87 {88 return __c;89 }90};91 92template <> struct _LIBCUDACXX_TEMPLATE_VIS hash<int>93 : public std::__unary_function<int, size_t>94{95 _LIBCUDACXX_INLINE_VISIBILITY96 size_t operator()(int __c) const noexcept97 {98 return __c;99 }100};101 102template <> struct _LIBCUDACXX_TEMPLATE_VIS hash<unsigned int>103 : public std::__unary_function<unsigned int, size_t>104{105 _LIBCUDACXX_INLINE_VISIBILITY106 size_t operator()(unsigned int __c) const noexcept107 {108 return __c;109 }110};111 112template <> struct _LIBCUDACXX_TEMPLATE_VIS hash<long>113 : public std::__unary_function<long, size_t>114{115 _LIBCUDACXX_INLINE_VISIBILITY116 size_t operator()(long __c) const noexcept117 {118 return __c;119 }120};121 122template <> struct _LIBCUDACXX_TEMPLATE_VIS hash<unsigned long>123 : public std::__unary_function<unsigned long, size_t>124{125 _LIBCUDACXX_INLINE_VISIBILITY126 size_t operator()(unsigned long __c) const noexcept127 {128 return __c;129 }130};131}132 133#endif // _LIBCUDACXX_EXT_HASH134 