1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef _LIBCPP___FUNCTIONAL_HASH_H 10 #define _LIBCPP___FUNCTIONAL_HASH_H 11 12 #include <__config> 13 #include <__functional/unary_function.h> 14 #include <__tuple> 15 #include <__utility/forward.h> 16 #include <__utility/move.h> 17 #include <__utility/pair.h> 18 #include <__utility/swap.h> 19 #include <cstddef> 20 #include <cstdint> 21 #include <cstring> 22 #include <limits> 23 #include <type_traits> 24 25 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 26 # pragma GCC system_header 27 #endif 28 29 _LIBCPP_BEGIN_NAMESPACE_STD 30 31 template <class _Size> 32 inline _LIBCPP_INLINE_VISIBILITY 33 _Size 34 __loadword(const void* __p) 35 { 36 _Size __r; 37 _VSTD::memcpy(&__r, __p, sizeof(__r)); 38 return __r; 39 } 40 41 // We use murmur2 when size_t is 32 bits, and cityhash64 when size_t 42 // is 64 bits. This is because cityhash64 uses 64bit x 64bit 43 // multiplication, which can be very slow on 32-bit systems. 44 template <class _Size, size_t = sizeof(_Size)*__CHAR_BIT__> 45 struct __murmur2_or_cityhash; 46 47 template <class _Size> 48 struct __murmur2_or_cityhash<_Size, 32> 49 { 50 inline _Size operator()(const void* __key, _Size __len) 51 _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK; 52 }; 53 54 // murmur2 55 template <class _Size> 56 _Size 57 __murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len) 58 { 59 const _Size __m = 0x5bd1e995; 60 const _Size __r = 24; 61 _Size __h = __len; 62 const unsigned char* __data = static_cast<const unsigned char*>(__key); 63 for (; __len >= 4; __data += 4, __len -= 4) 64 { 65 _Size __k = __loadword<_Size>(__data); 66 __k *= __m; 67 __k ^= __k >> __r; 68 __k *= __m; 69 __h *= __m; 70 __h ^= __k; 71 } 72 switch (__len) 73 { 74 case 3: 75 __h ^= static_cast<_Size>(__data[2] << 16); 76 _LIBCPP_FALLTHROUGH(); 77 case 2: 78 __h ^= static_cast<_Size>(__data[1] << 8); 79 _LIBCPP_FALLTHROUGH(); 80 case 1: 81 __h ^= __data[0]; 82 __h *= __m; 83 } 84 __h ^= __h >> 13; 85 __h *= __m; 86 __h ^= __h >> 15; 87 return __h; 88 } 89 90 template <class _Size> 91 struct __murmur2_or_cityhash<_Size, 64> 92 { 93 inline _Size operator()(const void* __key, _Size __len) _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK; 94 95 private: 96 // Some primes between 2^63 and 2^64. 97 static const _Size __k0 = 0xc3a5c85c97cb3127ULL; 98 static const _Size __k1 = 0xb492b66fbe98f273ULL; 99 static const _Size __k2 = 0x9ae16a3b2f90404fULL; 100 static const _Size __k3 = 0xc949d7c7509e6557ULL; 101 102 static _Size __rotate(_Size __val, int __shift) { 103 return __shift == 0 ? __val : ((__val >> __shift) | (__val << (64 - __shift))); 104 } 105 106 static _Size __rotate_by_at_least_1(_Size __val, int __shift) { 107 return (__val >> __shift) | (__val << (64 - __shift)); 108 } 109 110 static _Size __shift_mix(_Size __val) { 111 return __val ^ (__val >> 47); 112 } 113 114 static _Size __hash_len_16(_Size __u, _Size __v) 115 _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 116 { 117 const _Size __mul = 0x9ddfea08eb382d69ULL; 118 _Size __a = (__u ^ __v) * __mul; 119 __a ^= (__a >> 47); 120 _Size __b = (__v ^ __a) * __mul; 121 __b ^= (__b >> 47); 122 __b *= __mul; 123 return __b; 124 } 125 126 static _Size __hash_len_0_to_16(const char* __s, _Size __len) 127 _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 128 { 129 if (__len > 8) { 130 const _Size __a = __loadword<_Size>(__s); 131 const _Size __b = __loadword<_Size>(__s + __len - 8); 132 return __hash_len_16(__a, __rotate_by_at_least_1(__b + __len, __len)) ^ __b; 133 } 134 if (__len >= 4) { 135 const uint32_t __a = __loadword<uint32_t>(__s); 136 const uint32_t __b = __loadword<uint32_t>(__s + __len - 4); 137 return __hash_len_16(__len + (__a << 3), __b); 138 } 139 if (__len > 0) { 140 const unsigned char __a = static_cast<unsigned char>(__s[0]); 141 const unsigned char __b = static_cast<unsigned char>(__s[__len >> 1]); 142 const unsigned char __c = static_cast<unsigned char>(__s[__len - 1]); 143 const uint32_t __y = static_cast<uint32_t>(__a) + 144 (static_cast<uint32_t>(__b) << 8); 145 const uint32_t __z = __len + (static_cast<uint32_t>(__c) << 2); 146 return __shift_mix(__y * __k2 ^ __z * __k3) * __k2; 147 } 148 return __k2; 149 } 150 151 static _Size __hash_len_17_to_32(const char *__s, _Size __len) 152 _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 153 { 154 const _Size __a = __loadword<_Size>(__s) * __k1; 155 const _Size __b = __loadword<_Size>(__s + 8); 156 const _Size __c = __loadword<_Size>(__s + __len - 8) * __k2; 157 const _Size __d = __loadword<_Size>(__s + __len - 16) * __k0; 158 return __hash_len_16(__rotate(__a - __b, 43) + __rotate(__c, 30) + __d, 159 __a + __rotate(__b ^ __k3, 20) - __c + __len); 160 } 161 162 // Return a 16-byte hash for 48 bytes. Quick and dirty. 163 // Callers do best to use "random-looking" values for a and b. 164 static pair<_Size, _Size> __weak_hash_len_32_with_seeds( 165 _Size __w, _Size __x, _Size __y, _Size __z, _Size __a, _Size __b) 166 _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 167 { 168 __a += __w; 169 __b = __rotate(__b + __a + __z, 21); 170 const _Size __c = __a; 171 __a += __x; 172 __a += __y; 173 __b += __rotate(__a, 44); 174 return pair<_Size, _Size>(__a + __z, __b + __c); 175 } 176 177 // Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty. 178 static pair<_Size, _Size> __weak_hash_len_32_with_seeds( 179 const char* __s, _Size __a, _Size __b) 180 _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 181 { 182 return __weak_hash_len_32_with_seeds(__loadword<_Size>(__s), 183 __loadword<_Size>(__s + 8), 184 __loadword<_Size>(__s + 16), 185 __loadword<_Size>(__s + 24), 186 __a, 187 __b); 188 } 189 190 // Return an 8-byte hash for 33 to 64 bytes. 191 static _Size __hash_len_33_to_64(const char *__s, size_t __len) 192 _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 193 { 194 _Size __z = __loadword<_Size>(__s + 24); 195 _Size __a = __loadword<_Size>(__s) + 196 (__len + __loadword<_Size>(__s + __len - 16)) * __k0; 197 _Size __b = __rotate(__a + __z, 52); 198 _Size __c = __rotate(__a, 37); 199 __a += __loadword<_Size>(__s + 8); 200 __c += __rotate(__a, 7); 201 __a += __loadword<_Size>(__s + 16); 202 _Size __vf = __a + __z; 203 _Size __vs = __b + __rotate(__a, 31) + __c; 204 __a = __loadword<_Size>(__s + 16) + __loadword<_Size>(__s + __len - 32); 205 __z += __loadword<_Size>(__s + __len - 8); 206 __b = __rotate(__a + __z, 52); 207 __c = __rotate(__a, 37); 208 __a += __loadword<_Size>(__s + __len - 24); 209 __c += __rotate(__a, 7); 210 __a += __loadword<_Size>(__s + __len - 16); 211 _Size __wf = __a + __z; 212 _Size __ws = __b + __rotate(__a, 31) + __c; 213 _Size __r = __shift_mix((__vf + __ws) * __k2 + (__wf + __vs) * __k0); 214 return __shift_mix(__r * __k0 + __vs) * __k2; 215 } 216 }; 217 218 // cityhash64 219 template <class _Size> 220 _Size 221 __murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len) 222 { 223 const char* __s = static_cast<const char*>(__key); 224 if (__len <= 32) { 225 if (__len <= 16) { 226 return __hash_len_0_to_16(__s, __len); 227 } else { 228 return __hash_len_17_to_32(__s, __len); 229 } 230 } else if (__len <= 64) { 231 return __hash_len_33_to_64(__s, __len); 232 } 233 234 // For strings over 64 bytes we hash the end first, and then as we 235 // loop we keep 56 bytes of state: v, w, x, y, and z. 236 _Size __x = __loadword<_Size>(__s + __len - 40); 237 _Size __y = __loadword<_Size>(__s + __len - 16) + 238 __loadword<_Size>(__s + __len - 56); 239 _Size __z = __hash_len_16(__loadword<_Size>(__s + __len - 48) + __len, 240 __loadword<_Size>(__s + __len - 24)); 241 pair<_Size, _Size> __v = __weak_hash_len_32_with_seeds(__s + __len - 64, __len, __z); 242 pair<_Size, _Size> __w = __weak_hash_len_32_with_seeds(__s + __len - 32, __y + __k1, __x); 243 __x = __x * __k1 + __loadword<_Size>(__s); 244 245 // Decrease len to the nearest multiple of 64, and operate on 64-byte chunks. 246 __len = (__len - 1) & ~static_cast<_Size>(63); 247 do { 248 __x = __rotate(__x + __y + __v.first + __loadword<_Size>(__s + 8), 37) * __k1; 249 __y = __rotate(__y + __v.second + __loadword<_Size>(__s + 48), 42) * __k1; 250 __x ^= __w.second; 251 __y += __v.first + __loadword<_Size>(__s + 40); 252 __z = __rotate(__z + __w.first, 33) * __k1; 253 __v = __weak_hash_len_32_with_seeds(__s, __v.second * __k1, __x + __w.first); 254 __w = __weak_hash_len_32_with_seeds(__s + 32, __z + __w.second, 255 __y + __loadword<_Size>(__s + 16)); 256 _VSTD::swap(__z, __x); 257 __s += 64; 258 __len -= 64; 259 } while (__len != 0); 260 return __hash_len_16( 261 __hash_len_16(__v.first, __w.first) + __shift_mix(__y) * __k1 + __z, 262 __hash_len_16(__v.second, __w.second) + __x); 263 } 264 265 template <class _Tp, size_t = sizeof(_Tp) / sizeof(size_t)> 266 struct __scalar_hash; 267 268 template <class _Tp> 269 struct __scalar_hash<_Tp, 0> 270 : public __unary_function<_Tp, size_t> 271 { 272 _LIBCPP_INLINE_VISIBILITY 273 size_t operator()(_Tp __v) const _NOEXCEPT 274 { 275 union 276 { 277 _Tp __t; 278 size_t __a; 279 } __u; 280 __u.__a = 0; 281 __u.__t = __v; 282 return __u.__a; 283 } 284 }; 285 286 template <class _Tp> 287 struct __scalar_hash<_Tp, 1> 288 : public __unary_function<_Tp, size_t> 289 { 290 _LIBCPP_INLINE_VISIBILITY 291 size_t operator()(_Tp __v) const _NOEXCEPT 292 { 293 union 294 { 295 _Tp __t; 296 size_t __a; 297 } __u; 298 __u.__t = __v; 299 return __u.__a; 300 } 301 }; 302 303 template <class _Tp> 304 struct __scalar_hash<_Tp, 2> 305 : public __unary_function<_Tp, size_t> 306 { 307 _LIBCPP_INLINE_VISIBILITY 308 size_t operator()(_Tp __v) const _NOEXCEPT 309 { 310 union 311 { 312 _Tp __t; 313 struct 314 { 315 size_t __a; 316 size_t __b; 317 } __s; 318 } __u; 319 __u.__t = __v; 320 return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); 321 } 322 }; 323 324 template <class _Tp> 325 struct __scalar_hash<_Tp, 3> 326 : public __unary_function<_Tp, size_t> 327 { 328 _LIBCPP_INLINE_VISIBILITY 329 size_t operator()(_Tp __v) const _NOEXCEPT 330 { 331 union 332 { 333 _Tp __t; 334 struct 335 { 336 size_t __a; 337 size_t __b; 338 size_t __c; 339 } __s; 340 } __u; 341 __u.__t = __v; 342 return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); 343 } 344 }; 345 346 template <class _Tp> 347 struct __scalar_hash<_Tp, 4> 348 : public __unary_function<_Tp, size_t> 349 { 350 _LIBCPP_INLINE_VISIBILITY 351 size_t operator()(_Tp __v) const _NOEXCEPT 352 { 353 union 354 { 355 _Tp __t; 356 struct 357 { 358 size_t __a; 359 size_t __b; 360 size_t __c; 361 size_t __d; 362 } __s; 363 } __u; 364 __u.__t = __v; 365 return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); 366 } 367 }; 368 369 struct _PairT { 370 size_t first; 371 size_t second; 372 }; 373 374 _LIBCPP_INLINE_VISIBILITY 375 inline size_t __hash_combine(size_t __lhs, size_t __rhs) _NOEXCEPT { 376 typedef __scalar_hash<_PairT> _HashT; 377 const _PairT __p = {__lhs, __rhs}; 378 return _HashT()(__p); 379 } 380 381 template<class _Tp> 382 struct _LIBCPP_TEMPLATE_VIS hash<_Tp*> 383 : public __unary_function<_Tp*, size_t> 384 { 385 _LIBCPP_INLINE_VISIBILITY 386 size_t operator()(_Tp* __v) const _NOEXCEPT 387 { 388 union 389 { 390 _Tp* __t; 391 size_t __a; 392 } __u; 393 __u.__t = __v; 394 return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); 395 } 396 }; 397 398 template <> 399 struct _LIBCPP_TEMPLATE_VIS hash<bool> 400 : public __unary_function<bool, size_t> 401 { 402 _LIBCPP_INLINE_VISIBILITY 403 size_t operator()(bool __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 404 }; 405 406 template <> 407 struct _LIBCPP_TEMPLATE_VIS hash<char> 408 : public __unary_function<char, size_t> 409 { 410 _LIBCPP_INLINE_VISIBILITY 411 size_t operator()(char __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 412 }; 413 414 template <> 415 struct _LIBCPP_TEMPLATE_VIS hash<signed char> 416 : public __unary_function<signed char, size_t> 417 { 418 _LIBCPP_INLINE_VISIBILITY 419 size_t operator()(signed char __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 420 }; 421 422 template <> 423 struct _LIBCPP_TEMPLATE_VIS hash<unsigned char> 424 : public __unary_function<unsigned char, size_t> 425 { 426 _LIBCPP_INLINE_VISIBILITY 427 size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 428 }; 429 430 #ifndef _LIBCPP_HAS_NO_CHAR8_T 431 template <> 432 struct _LIBCPP_TEMPLATE_VIS hash<char8_t> 433 : public __unary_function<char8_t, size_t> 434 { 435 _LIBCPP_INLINE_VISIBILITY 436 size_t operator()(char8_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 437 }; 438 #endif // !_LIBCPP_HAS_NO_CHAR8_T 439 440 template <> 441 struct _LIBCPP_TEMPLATE_VIS hash<char16_t> 442 : public __unary_function<char16_t, size_t> 443 { 444 _LIBCPP_INLINE_VISIBILITY 445 size_t operator()(char16_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 446 }; 447 448 template <> 449 struct _LIBCPP_TEMPLATE_VIS hash<char32_t> 450 : public __unary_function<char32_t, size_t> 451 { 452 _LIBCPP_INLINE_VISIBILITY 453 size_t operator()(char32_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 454 }; 455 456 #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 457 template <> 458 struct _LIBCPP_TEMPLATE_VIS hash<wchar_t> 459 : public __unary_function<wchar_t, size_t> 460 { 461 _LIBCPP_INLINE_VISIBILITY 462 size_t operator()(wchar_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 463 }; 464 #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS 465 466 template <> 467 struct _LIBCPP_TEMPLATE_VIS hash<short> 468 : public __unary_function<short, size_t> 469 { 470 _LIBCPP_INLINE_VISIBILITY 471 size_t operator()(short __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 472 }; 473 474 template <> 475 struct _LIBCPP_TEMPLATE_VIS hash<unsigned short> 476 : public __unary_function<unsigned short, size_t> 477 { 478 _LIBCPP_INLINE_VISIBILITY 479 size_t operator()(unsigned short __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 480 }; 481 482 template <> 483 struct _LIBCPP_TEMPLATE_VIS hash<int> 484 : public __unary_function<int, size_t> 485 { 486 _LIBCPP_INLINE_VISIBILITY 487 size_t operator()(int __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 488 }; 489 490 template <> 491 struct _LIBCPP_TEMPLATE_VIS hash<unsigned int> 492 : public __unary_function<unsigned int, size_t> 493 { 494 _LIBCPP_INLINE_VISIBILITY 495 size_t operator()(unsigned int __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 496 }; 497 498 template <> 499 struct _LIBCPP_TEMPLATE_VIS hash<long> 500 : public __unary_function<long, size_t> 501 { 502 _LIBCPP_INLINE_VISIBILITY 503 size_t operator()(long __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 504 }; 505 506 template <> 507 struct _LIBCPP_TEMPLATE_VIS hash<unsigned long> 508 : public __unary_function<unsigned long, size_t> 509 { 510 _LIBCPP_INLINE_VISIBILITY 511 size_t operator()(unsigned long __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 512 }; 513 514 template <> 515 struct _LIBCPP_TEMPLATE_VIS hash<long long> 516 : public __scalar_hash<long long> 517 { 518 }; 519 520 template <> 521 struct _LIBCPP_TEMPLATE_VIS hash<unsigned long long> 522 : public __scalar_hash<unsigned long long> 523 { 524 }; 525 526 #ifndef _LIBCPP_HAS_NO_INT128 527 528 template <> 529 struct _LIBCPP_TEMPLATE_VIS hash<__int128_t> 530 : public __scalar_hash<__int128_t> 531 { 532 }; 533 534 template <> 535 struct _LIBCPP_TEMPLATE_VIS hash<__uint128_t> 536 : public __scalar_hash<__uint128_t> 537 { 538 }; 539 540 #endif 541 542 template <> 543 struct _LIBCPP_TEMPLATE_VIS hash<float> 544 : public __scalar_hash<float> 545 { 546 _LIBCPP_INLINE_VISIBILITY 547 size_t operator()(float __v) const _NOEXCEPT 548 { 549 // -0.0 and 0.0 should return same hash 550 if (__v == 0.0f) 551 return 0; 552 return __scalar_hash<float>::operator()(__v); 553 } 554 }; 555 556 template <> 557 struct _LIBCPP_TEMPLATE_VIS hash<double> 558 : public __scalar_hash<double> 559 { 560 _LIBCPP_INLINE_VISIBILITY 561 size_t operator()(double __v) const _NOEXCEPT 562 { 563 // -0.0 and 0.0 should return same hash 564 if (__v == 0.0) 565 return 0; 566 return __scalar_hash<double>::operator()(__v); 567 } 568 }; 569 570 template <> 571 struct _LIBCPP_TEMPLATE_VIS hash<long double> 572 : public __scalar_hash<long double> 573 { 574 _LIBCPP_INLINE_VISIBILITY 575 size_t operator()(long double __v) const _NOEXCEPT 576 { 577 // -0.0 and 0.0 should return same hash 578 if (__v == 0.0L) 579 return 0; 580 #if defined(__i386__) || (defined(__x86_64__) && defined(__ILP32__)) 581 // Zero out padding bits 582 union 583 { 584 long double __t; 585 struct 586 { 587 size_t __a; 588 size_t __b; 589 size_t __c; 590 size_t __d; 591 } __s; 592 } __u; 593 __u.__s.__a = 0; 594 __u.__s.__b = 0; 595 __u.__s.__c = 0; 596 __u.__s.__d = 0; 597 __u.__t = __v; 598 return __u.__s.__a ^ __u.__s.__b ^ __u.__s.__c ^ __u.__s.__d; 599 #elif defined(__x86_64__) 600 // Zero out padding bits 601 union 602 { 603 long double __t; 604 struct 605 { 606 size_t __a; 607 size_t __b; 608 } __s; 609 } __u; 610 __u.__s.__a = 0; 611 __u.__s.__b = 0; 612 __u.__t = __v; 613 return __u.__s.__a ^ __u.__s.__b; 614 #else 615 return __scalar_hash<long double>::operator()(__v); 616 #endif 617 } 618 }; 619 620 template <class _Tp, bool = is_enum<_Tp>::value> 621 struct _LIBCPP_TEMPLATE_VIS __enum_hash 622 : public __unary_function<_Tp, size_t> 623 { 624 _LIBCPP_INLINE_VISIBILITY 625 size_t operator()(_Tp __v) const _NOEXCEPT 626 { 627 typedef typename underlying_type<_Tp>::type type; 628 return hash<type>()(static_cast<type>(__v)); 629 } 630 }; 631 template <class _Tp> 632 struct _LIBCPP_TEMPLATE_VIS __enum_hash<_Tp, false> { 633 __enum_hash() = delete; 634 __enum_hash(__enum_hash const&) = delete; 635 __enum_hash& operator=(__enum_hash const&) = delete; 636 }; 637 638 template <class _Tp> 639 struct _LIBCPP_TEMPLATE_VIS hash : public __enum_hash<_Tp> 640 { 641 }; 642 643 #if _LIBCPP_STD_VER > 14 644 645 template <> 646 struct _LIBCPP_TEMPLATE_VIS hash<nullptr_t> 647 : public __unary_function<nullptr_t, size_t> 648 { 649 _LIBCPP_INLINE_VISIBILITY 650 size_t operator()(nullptr_t) const _NOEXCEPT { 651 return 662607004ull; 652 } 653 }; 654 #endif 655 656 #ifndef _LIBCPP_CXX03_LANG 657 template <class _Key, class _Hash> 658 using __check_hash_requirements _LIBCPP_NODEBUG = integral_constant<bool, 659 is_copy_constructible<_Hash>::value && 660 is_move_constructible<_Hash>::value && 661 __invokable_r<size_t, _Hash, _Key const&>::value 662 >; 663 664 template <class _Key, class _Hash = hash<_Key> > 665 using __has_enabled_hash _LIBCPP_NODEBUG = integral_constant<bool, 666 __check_hash_requirements<_Key, _Hash>::value && 667 is_default_constructible<_Hash>::value 668 >; 669 670 #if _LIBCPP_STD_VER > 14 671 template <class _Type, class> 672 using __enable_hash_helper_imp _LIBCPP_NODEBUG = _Type; 673 674 template <class _Type, class ..._Keys> 675 using __enable_hash_helper _LIBCPP_NODEBUG = __enable_hash_helper_imp<_Type, 676 typename enable_if<__all<__has_enabled_hash<_Keys>::value...>::value>::type 677 >; 678 #else 679 template <class _Type, class ...> 680 using __enable_hash_helper _LIBCPP_NODEBUG = _Type; 681 #endif 682 683 #endif // !_LIBCPP_CXX03_LANG 684 685 _LIBCPP_END_NAMESPACE_STD 686 687 #endif // _LIBCPP___FUNCTIONAL_HASH_H 688