chromium/third_party/libc++/src/include/__functional/hash.h

//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP___FUNCTIONAL_HASH_H
#define _LIBCPP___FUNCTIONAL_HASH_H

#include <__config>
#include <__functional/unary_function.h>
#include <__fwd/functional.h>
#include <__type_traits/conjunction.h>
#include <__type_traits/invoke.h>
#include <__type_traits/is_constructible.h>
#include <__type_traits/is_enum.h>
#include <__type_traits/underlying_type.h>
#include <__utility/pair.h>
#include <__utility/swap.h>
#include <cstddef>
#include <cstdint>
#include <cstring>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#  pragma GCC system_header
#endif

_LIBCPP_BEGIN_NAMESPACE_STD

template <class _Size>
inline _LIBCPP_HIDE_FROM_ABI _Size __loadword(const void* __p) {}

// We use murmur2 when size_t is 32 bits, and cityhash64 when size_t
// is 64 bits.  This is because cityhash64 uses 64bit x 64bit
// multiplication, which can be very slow on 32-bit systems.
template <class _Size, size_t = sizeof(_Size) * __CHAR_BIT__>
struct __murmur2_or_cityhash;

__murmur2_or_cityhash<_Size, 32>;

__murmur2_or_cityhash<_Size, 64>;

template <class _Tp, size_t = sizeof(_Tp) / sizeof(size_t)>
struct __scalar_hash;

__scalar_hash<_Tp, 0>;

__scalar_hash<_Tp, 1>;

__scalar_hash<_Tp, 2>;

__scalar_hash<_Tp, 3>;

__scalar_hash<_Tp, 4>;

struct _PairT {};

_LIBCPP_HIDE_FROM_ABI inline size_t __hash_combine(size_t __lhs, size_t __rhs) _NOEXCEPT {}

hash<_Tp *>;

template <>
struct _LIBCPP_TEMPLATE_VIS hash<bool> : public __unary_function<bool, size_t> {};

template <>
struct _LIBCPP_TEMPLATE_VIS hash<char> : public __unary_function<char, size_t> {};

template <>
struct _LIBCPP_TEMPLATE_VIS hash<signed char> : public __unary_function<signed char, size_t> {};

template <>
struct _LIBCPP_TEMPLATE_VIS hash<unsigned char> : public __unary_function<unsigned char, size_t> {};

#ifndef _LIBCPP_HAS_NO_CHAR8_T
template <>
struct _LIBCPP_TEMPLATE_VIS hash<char8_t> : public __unary_function<char8_t, size_t> {};
#endif // !_LIBCPP_HAS_NO_CHAR8_T

template <>
struct _LIBCPP_TEMPLATE_VIS hash<char16_t> : public __unary_function<char16_t, size_t> {};

template <>
struct _LIBCPP_TEMPLATE_VIS hash<char32_t> : public __unary_function<char32_t, size_t> {};

#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
struct _LIBCPP_TEMPLATE_VIS hash<wchar_t> : public __unary_function<wchar_t, size_t> {};
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS

template <>
struct _LIBCPP_TEMPLATE_VIS hash<short> : public __unary_function<short, size_t> {};

template <>
struct _LIBCPP_TEMPLATE_VIS hash<unsigned short> : public __unary_function<unsigned short, size_t> {};

template <>
struct _LIBCPP_TEMPLATE_VIS hash<int> : public __unary_function<int, size_t> {};

template <>
struct _LIBCPP_TEMPLATE_VIS hash<unsigned int> : public __unary_function<unsigned int, size_t> {};

template <>
struct _LIBCPP_TEMPLATE_VIS hash<long> : public __unary_function<long, size_t> {};

template <>
struct _LIBCPP_TEMPLATE_VIS hash<unsigned long> : public __unary_function<unsigned long, size_t> {};

template <>
struct _LIBCPP_TEMPLATE_VIS hash<long long> : public __scalar_hash<long long> {};

template <>
struct _LIBCPP_TEMPLATE_VIS hash<unsigned long long> : public __scalar_hash<unsigned long long> {};

#ifndef _LIBCPP_HAS_NO_INT128

template <>
struct _LIBCPP_TEMPLATE_VIS hash<__int128_t> : public __scalar_hash<__int128_t> {};

template <>
struct _LIBCPP_TEMPLATE_VIS hash<__uint128_t> : public __scalar_hash<__uint128_t> {};

#endif

template <>
struct _LIBCPP_TEMPLATE_VIS hash<float> : public __scalar_hash<float> {};

template <>
struct _LIBCPP_TEMPLATE_VIS hash<double> : public __scalar_hash<double> {};

template <>
struct _LIBCPP_TEMPLATE_VIS hash<long double> : public __scalar_hash<long double> {};

template <class _Tp, bool = is_enum<_Tp>::value>
struct _LIBCPP_TEMPLATE_VIS __enum_hash : public __unary_function<_Tp, size_t> {};
__enum_hash<_Tp, false>;

template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS hash : public __enum_hash<_Tp> {};

#if _LIBCPP_STD_VER >= 17

template <>
struct _LIBCPP_TEMPLATE_VIS hash<nullptr_t> : public __unary_function<nullptr_t, size_t> {};
#endif

#ifndef _LIBCPP_CXX03_LANG
__check_hash_requirements;

__has_enabled_hash;

#  if _LIBCPP_STD_VER >= 17
__enable_hash_helper_imp;

__enable_hash_helper;
#  else
template <class _Type, class...>
using __enable_hash_helper _LIBCPP_NODEBUG = _Type;
#  endif

#endif // !_LIBCPP_CXX03_LANG

_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP___FUNCTIONAL_HASH_H