xref: /openbsd-src/gnu/llvm/libcxx/include/ext/__hash (revision 4bdff4bed0e3d54e55670334c7d0077db4170f86)
146035553Spatrick// -*- C++ -*-
2*4bdff4beSrobert//===----------------------------------------------------------------------===//
346035553Spatrick//
446035553Spatrick// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
546035553Spatrick// See https://llvm.org/LICENSE.txt for license information.
646035553Spatrick// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
746035553Spatrick//
846035553Spatrick//===----------------------------------------------------------------------===//
946035553Spatrick
1046035553Spatrick#ifndef _LIBCPP_EXT_HASH
1146035553Spatrick#define _LIBCPP_EXT_HASH
1246035553Spatrick
1346035553Spatrick#  pragma GCC system_header
1446035553Spatrick
15*4bdff4beSrobert#include <__config>
1646035553Spatrick#include <cstring>
17*4bdff4beSrobert#include <stddef.h>
18*4bdff4beSrobert#include <string>
1946035553Spatrick
2046035553Spatricknamespace __gnu_cxx {
2146035553Spatrick
2246035553Spatricktemplate <typename _Tp> struct _LIBCPP_TEMPLATE_VIS hash { };
2346035553Spatrick
2446035553Spatricktemplate <> struct _LIBCPP_TEMPLATE_VIS hash<const char*>
25*4bdff4beSrobert : public std::__unary_function<const char*, size_t>
2646035553Spatrick{
2746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
2846035553Spatrick    size_t operator()(const char *__c) const _NOEXCEPT
2946035553Spatrick    {
3046035553Spatrick        return std::__do_string_hash(__c, __c + strlen(__c));
3146035553Spatrick    }
3246035553Spatrick};
3346035553Spatrick
3446035553Spatricktemplate <> struct _LIBCPP_TEMPLATE_VIS hash<char *>
35*4bdff4beSrobert : public std::__unary_function<char*, size_t>
3646035553Spatrick{
3746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
3846035553Spatrick    size_t operator()(char *__c) const _NOEXCEPT
3946035553Spatrick    {
4046035553Spatrick        return std::__do_string_hash<const char *>(__c, __c + strlen(__c));
4146035553Spatrick    }
4246035553Spatrick};
4346035553Spatrick
4446035553Spatricktemplate <> struct _LIBCPP_TEMPLATE_VIS hash<char>
45*4bdff4beSrobert : public std::__unary_function<char, size_t>
4646035553Spatrick{
4746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
4846035553Spatrick    size_t operator()(char __c) const _NOEXCEPT
4946035553Spatrick    {
5046035553Spatrick        return __c;
5146035553Spatrick    }
5246035553Spatrick};
5346035553Spatrick
5446035553Spatricktemplate <> struct _LIBCPP_TEMPLATE_VIS hash<signed char>
55*4bdff4beSrobert : public std::__unary_function<signed char, size_t>
5646035553Spatrick{
5746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
5846035553Spatrick    size_t operator()(signed char __c) const _NOEXCEPT
5946035553Spatrick    {
6046035553Spatrick        return __c;
6146035553Spatrick    }
6246035553Spatrick};
6346035553Spatrick
6446035553Spatricktemplate <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>
65*4bdff4beSrobert : public std::__unary_function<unsigned char, size_t>
6646035553Spatrick{
6746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
6846035553Spatrick    size_t operator()(unsigned char __c) const _NOEXCEPT
6946035553Spatrick    {
7046035553Spatrick        return __c;
7146035553Spatrick    }
7246035553Spatrick};
7346035553Spatrick
7446035553Spatricktemplate <> struct _LIBCPP_TEMPLATE_VIS hash<short>
75*4bdff4beSrobert : public std::__unary_function<short, size_t>
7646035553Spatrick{
7746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
7846035553Spatrick    size_t operator()(short __c) const _NOEXCEPT
7946035553Spatrick    {
8046035553Spatrick        return __c;
8146035553Spatrick    }
8246035553Spatrick};
8346035553Spatrick
8446035553Spatricktemplate <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned short>
85*4bdff4beSrobert : public std::__unary_function<unsigned short, size_t>
8646035553Spatrick{
8746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
8846035553Spatrick    size_t operator()(unsigned short __c) const _NOEXCEPT
8946035553Spatrick    {
9046035553Spatrick        return __c;
9146035553Spatrick    }
9246035553Spatrick};
9346035553Spatrick
9446035553Spatricktemplate <> struct _LIBCPP_TEMPLATE_VIS hash<int>
95*4bdff4beSrobert    : public std::__unary_function<int, size_t>
9646035553Spatrick{
9746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
9846035553Spatrick    size_t operator()(int __c) const _NOEXCEPT
9946035553Spatrick    {
10046035553Spatrick        return __c;
10146035553Spatrick    }
10246035553Spatrick};
10346035553Spatrick
10446035553Spatricktemplate <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned int>
105*4bdff4beSrobert    : public std::__unary_function<unsigned int, size_t>
10646035553Spatrick{
10746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
10846035553Spatrick    size_t operator()(unsigned int __c) const _NOEXCEPT
10946035553Spatrick    {
11046035553Spatrick        return __c;
11146035553Spatrick    }
11246035553Spatrick};
11346035553Spatrick
11446035553Spatricktemplate <> struct _LIBCPP_TEMPLATE_VIS hash<long>
115*4bdff4beSrobert    : public std::__unary_function<long, size_t>
11646035553Spatrick{
11746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
11846035553Spatrick    size_t operator()(long __c) const _NOEXCEPT
11946035553Spatrick    {
12046035553Spatrick        return __c;
12146035553Spatrick    }
12246035553Spatrick};
12346035553Spatrick
12446035553Spatricktemplate <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned long>
125*4bdff4beSrobert    : public std::__unary_function<unsigned long, size_t>
12646035553Spatrick{
12746035553Spatrick    _LIBCPP_INLINE_VISIBILITY
12846035553Spatrick    size_t operator()(unsigned long __c) const _NOEXCEPT
12946035553Spatrick    {
13046035553Spatrick        return __c;
13146035553Spatrick    }
13246035553Spatrick};
133*4bdff4beSrobert} // namespace __gnu_cxx
13446035553Spatrick
13546035553Spatrick#endif // _LIBCPP_EXT_HASH
136