10b57cec5SDimitry Andric// -*- C++ -*- 2349cc55cSDimitry Andric//===----------------------------------------------------------------------===// 30b57cec5SDimitry Andric// 40b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 50b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 60b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 70b57cec5SDimitry Andric// 80b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 90b57cec5SDimitry Andric 100b57cec5SDimitry Andric#ifndef _LIBCPP_EXT_HASH 110b57cec5SDimitry Andric#define _LIBCPP_EXT_HASH 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric#pragma GCC system_header 140b57cec5SDimitry Andric 1581ad6265SDimitry Andric#include <__config> 160b57cec5SDimitry Andric#include <cstring> 17bdd1243dSDimitry Andric#include <stddef.h> 1804eeddc0SDimitry Andric#include <string> 190b57cec5SDimitry Andric 200b57cec5SDimitry Andricnamespace __gnu_cxx { 210b57cec5SDimitry Andric 22*cb14a3feSDimitry Andrictemplate <typename _Tp> 23*cb14a3feSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash {}; 240b57cec5SDimitry Andric 25*cb14a3feSDimitry Andrictemplate <> 26*cb14a3feSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<const char*> : public std::__unary_function<const char*, size_t> { 27*cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_t operator()(const char* __c) const _NOEXCEPT { 280b57cec5SDimitry Andric return std::__do_string_hash(__c, __c + strlen(__c)); 290b57cec5SDimitry Andric } 300b57cec5SDimitry Andric}; 310b57cec5SDimitry Andric 32*cb14a3feSDimitry Andrictemplate <> 33*cb14a3feSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<char*> : public std::__unary_function<char*, size_t> { 34*cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_t operator()(char* __c) const _NOEXCEPT { 350b57cec5SDimitry Andric return std::__do_string_hash<const char*>(__c, __c + strlen(__c)); 360b57cec5SDimitry Andric } 370b57cec5SDimitry Andric}; 380b57cec5SDimitry Andric 39*cb14a3feSDimitry Andrictemplate <> 40*cb14a3feSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<char> : public std::__unary_function<char, size_t> { 41*cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_t operator()(char __c) const _NOEXCEPT { return __c; } 420b57cec5SDimitry Andric}; 430b57cec5SDimitry Andric 44*cb14a3feSDimitry Andrictemplate <> 45*cb14a3feSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<signed char> : public std::__unary_function<signed char, size_t> { 46*cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_t operator()(signed char __c) const _NOEXCEPT { return __c; } 470b57cec5SDimitry Andric}; 480b57cec5SDimitry Andric 49*cb14a3feSDimitry Andrictemplate <> 50*cb14a3feSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<unsigned char> : public std::__unary_function<unsigned char, size_t> { 51*cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned char __c) const _NOEXCEPT { return __c; } 520b57cec5SDimitry Andric}; 530b57cec5SDimitry Andric 54*cb14a3feSDimitry Andrictemplate <> 55*cb14a3feSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<short> : public std::__unary_function<short, size_t> { 56*cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_t operator()(short __c) const _NOEXCEPT { return __c; } 570b57cec5SDimitry Andric}; 580b57cec5SDimitry Andric 59*cb14a3feSDimitry Andrictemplate <> 60*cb14a3feSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<unsigned short> : public std::__unary_function<unsigned short, size_t> { 61*cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned short __c) const _NOEXCEPT { return __c; } 620b57cec5SDimitry Andric}; 630b57cec5SDimitry Andric 64*cb14a3feSDimitry Andrictemplate <> 65*cb14a3feSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<int> : public std::__unary_function<int, size_t> { 66*cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_t operator()(int __c) const _NOEXCEPT { return __c; } 670b57cec5SDimitry Andric}; 680b57cec5SDimitry Andric 69*cb14a3feSDimitry Andrictemplate <> 70*cb14a3feSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<unsigned int> : public std::__unary_function<unsigned int, size_t> { 71*cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned int __c) const _NOEXCEPT { return __c; } 720b57cec5SDimitry Andric}; 730b57cec5SDimitry Andric 74*cb14a3feSDimitry Andrictemplate <> 75*cb14a3feSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<long> : public std::__unary_function<long, size_t> { 76*cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_t operator()(long __c) const _NOEXCEPT { return __c; } 770b57cec5SDimitry Andric}; 780b57cec5SDimitry Andric 79*cb14a3feSDimitry Andrictemplate <> 80*cb14a3feSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<unsigned long> : public std::__unary_function<unsigned long, size_t> { 81*cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned long __c) const _NOEXCEPT { return __c; } 820b57cec5SDimitry Andric}; 830eae32dcSDimitry Andric} // namespace __gnu_cxx 840b57cec5SDimitry Andric 850b57cec5SDimitry Andric#endif // _LIBCPP_EXT_HASH 86