Sean Hunt | affd9e5 | 2011-07-29 23:31:56 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===------------------------- hash_set ------------------------------------===// |
| 3 | // |
| 4 | // The LLVM Compiler Infrastructure |
| 5 | // |
| 6 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 7 | // Source Licenses. See LICENSE.TXT for details. |
| 8 | // |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | |
| 11 | #ifndef _LIBCPP_EXT_HASH |
| 12 | #define _LIBCPP_EXT_HASH |
| 13 | |
| 14 | #pragma GCC system_header |
| 15 | |
| 16 | #include <string> |
| 17 | #include <cstring> |
| 18 | |
| 19 | namespace __gnu_cxx { |
| 20 | using namespace std; |
| 21 | |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 22 | template <typename T> struct _LIBCPP_TYPE_VIS_ONLY hash : public std::hash<T> |
Sean Hunt | affd9e5 | 2011-07-29 23:31:56 +0000 | [diff] [blame] | 23 | { }; |
| 24 | |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 25 | template <> struct _LIBCPP_TYPE_VIS_ONLY hash<const char*> |
Sean Hunt | affd9e5 | 2011-07-29 23:31:56 +0000 | [diff] [blame] | 26 | : public unary_function<const char*, size_t> |
| 27 | { |
| 28 | _LIBCPP_INLINE_VISIBILITY |
| 29 | size_t operator()(const char *__c) const _NOEXCEPT |
| 30 | { |
| 31 | return __do_string_hash(__c, __c + strlen(__c)); |
| 32 | } |
| 33 | }; |
| 34 | |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 35 | template <> struct _LIBCPP_TYPE_VIS_ONLY hash<char *> |
Sean Hunt | affd9e5 | 2011-07-29 23:31:56 +0000 | [diff] [blame] | 36 | : public unary_function<char*, size_t> |
| 37 | { |
| 38 | _LIBCPP_INLINE_VISIBILITY |
| 39 | size_t operator()(char *__c) const _NOEXCEPT |
| 40 | { |
| 41 | return __do_string_hash<const char *>(__c, __c + strlen(__c)); |
| 42 | } |
| 43 | }; |
| 44 | } |
| 45 | |
Howard Hinnant | 0919dba | 2012-11-06 21:55:44 +0000 | [diff] [blame] | 46 | #endif // _LIBCPP_EXT_HASH |