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 15fe6060f1SDimitry Andric#include <__string> 160b57cec5SDimitry Andric#include <cstring> 17*04eeddc0SDimitry Andric#include <string> 180b57cec5SDimitry Andric 190b57cec5SDimitry Andricnamespace __gnu_cxx { 200b57cec5SDimitry Andric 210b57cec5SDimitry Andrictemplate <typename _Tp> struct _LIBCPP_TEMPLATE_VIS hash { }; 220b57cec5SDimitry Andric 230b57cec5SDimitry Andrictemplate <> struct _LIBCPP_TEMPLATE_VIS hash<const char*> 240b57cec5SDimitry Andric : public std::unary_function<const char*, size_t> 250b57cec5SDimitry Andric{ 260b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 270b57cec5SDimitry Andric size_t operator()(const char *__c) const _NOEXCEPT 280b57cec5SDimitry Andric { 290b57cec5SDimitry Andric return std::__do_string_hash(__c, __c + strlen(__c)); 300b57cec5SDimitry Andric } 310b57cec5SDimitry Andric}; 320b57cec5SDimitry Andric 330b57cec5SDimitry Andrictemplate <> struct _LIBCPP_TEMPLATE_VIS hash<char *> 340b57cec5SDimitry Andric : public std::unary_function<char*, size_t> 350b57cec5SDimitry Andric{ 360b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 370b57cec5SDimitry Andric size_t operator()(char *__c) const _NOEXCEPT 380b57cec5SDimitry Andric { 390b57cec5SDimitry Andric return std::__do_string_hash<const char *>(__c, __c + strlen(__c)); 400b57cec5SDimitry Andric } 410b57cec5SDimitry Andric}; 420b57cec5SDimitry Andric 430b57cec5SDimitry Andrictemplate <> struct _LIBCPP_TEMPLATE_VIS hash<char> 440b57cec5SDimitry Andric : public std::unary_function<char, size_t> 450b57cec5SDimitry Andric{ 460b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 470b57cec5SDimitry Andric size_t operator()(char __c) const _NOEXCEPT 480b57cec5SDimitry Andric { 490b57cec5SDimitry Andric return __c; 500b57cec5SDimitry Andric } 510b57cec5SDimitry Andric}; 520b57cec5SDimitry Andric 530b57cec5SDimitry Andrictemplate <> struct _LIBCPP_TEMPLATE_VIS hash<signed char> 540b57cec5SDimitry Andric : public std::unary_function<signed char, size_t> 550b57cec5SDimitry Andric{ 560b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 570b57cec5SDimitry Andric size_t operator()(signed char __c) const _NOEXCEPT 580b57cec5SDimitry Andric { 590b57cec5SDimitry Andric return __c; 600b57cec5SDimitry Andric } 610b57cec5SDimitry Andric}; 620b57cec5SDimitry Andric 630b57cec5SDimitry Andrictemplate <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned char> 640b57cec5SDimitry Andric : public std::unary_function<unsigned char, size_t> 650b57cec5SDimitry Andric{ 660b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 670b57cec5SDimitry Andric size_t operator()(unsigned char __c) const _NOEXCEPT 680b57cec5SDimitry Andric { 690b57cec5SDimitry Andric return __c; 700b57cec5SDimitry Andric } 710b57cec5SDimitry Andric}; 720b57cec5SDimitry Andric 730b57cec5SDimitry Andrictemplate <> struct _LIBCPP_TEMPLATE_VIS hash<short> 740b57cec5SDimitry Andric : public std::unary_function<short, size_t> 750b57cec5SDimitry Andric{ 760b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 770b57cec5SDimitry Andric size_t operator()(short __c) const _NOEXCEPT 780b57cec5SDimitry Andric { 790b57cec5SDimitry Andric return __c; 800b57cec5SDimitry Andric } 810b57cec5SDimitry Andric}; 820b57cec5SDimitry Andric 830b57cec5SDimitry Andrictemplate <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned short> 840b57cec5SDimitry Andric : public std::unary_function<unsigned short, size_t> 850b57cec5SDimitry Andric{ 860b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 870b57cec5SDimitry Andric size_t operator()(unsigned short __c) const _NOEXCEPT 880b57cec5SDimitry Andric { 890b57cec5SDimitry Andric return __c; 900b57cec5SDimitry Andric } 910b57cec5SDimitry Andric}; 920b57cec5SDimitry Andric 930b57cec5SDimitry Andrictemplate <> struct _LIBCPP_TEMPLATE_VIS hash<int> 940b57cec5SDimitry Andric : public std::unary_function<int, size_t> 950b57cec5SDimitry Andric{ 960b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 970b57cec5SDimitry Andric size_t operator()(int __c) const _NOEXCEPT 980b57cec5SDimitry Andric { 990b57cec5SDimitry Andric return __c; 1000b57cec5SDimitry Andric } 1010b57cec5SDimitry Andric}; 1020b57cec5SDimitry Andric 1030b57cec5SDimitry Andrictemplate <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned int> 1040b57cec5SDimitry Andric : public std::unary_function<unsigned int, size_t> 1050b57cec5SDimitry Andric{ 1060b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1070b57cec5SDimitry Andric size_t operator()(unsigned int __c) const _NOEXCEPT 1080b57cec5SDimitry Andric { 1090b57cec5SDimitry Andric return __c; 1100b57cec5SDimitry Andric } 1110b57cec5SDimitry Andric}; 1120b57cec5SDimitry Andric 1130b57cec5SDimitry Andrictemplate <> struct _LIBCPP_TEMPLATE_VIS hash<long> 1140b57cec5SDimitry Andric : public std::unary_function<long, size_t> 1150b57cec5SDimitry Andric{ 1160b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1170b57cec5SDimitry Andric size_t operator()(long __c) const _NOEXCEPT 1180b57cec5SDimitry Andric { 1190b57cec5SDimitry Andric return __c; 1200b57cec5SDimitry Andric } 1210b57cec5SDimitry Andric}; 1220b57cec5SDimitry Andric 1230b57cec5SDimitry Andrictemplate <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned long> 1240b57cec5SDimitry Andric : public std::unary_function<unsigned long, size_t> 1250b57cec5SDimitry Andric{ 1260b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1270b57cec5SDimitry Andric size_t operator()(unsigned long __c) const _NOEXCEPT 1280b57cec5SDimitry Andric { 1290b57cec5SDimitry Andric return __c; 1300b57cec5SDimitry Andric } 1310b57cec5SDimitry Andric}; 1320eae32dcSDimitry Andric} // namespace __gnu_cxx 1330b57cec5SDimitry Andric 1340b57cec5SDimitry Andric#endif // _LIBCPP_EXT_HASH 135