blob: 21500e894dcd96793d238412b5b15ba90d6f96ce [file] [log] [blame]
Sean Huntaffd9e52011-07-29 23:31:56 +00001// -*- 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
19namespace __gnu_cxx {
20using namespace std;
21
22template <typename T> struct _LIBCPP_VISIBLE hash : public std::hash<T>
23 { };
24
25template <> struct _LIBCPP_VISIBLE hash<const char*>
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
35template <> struct _LIBCPP_VISIBLE hash<char *>
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 Hinnant0919dba2012-11-06 21:55:44 +000046#endif // _LIBCPP_EXT_HASH