blob: 04975bfd052167c3083150276c9a01b89a8c750c [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
Howard Hinnant0f678bd2013-08-12 18:38:34 +000022template <typename T> struct _LIBCPP_TYPE_VIS_ONLY hash : public std::hash<T>
Sean Huntaffd9e52011-07-29 23:31:56 +000023 { };
24
Howard Hinnant0f678bd2013-08-12 18:38:34 +000025template <> struct _LIBCPP_TYPE_VIS_ONLY hash<const char*>
Sean Huntaffd9e52011-07-29 23:31:56 +000026 : 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 Hinnant0f678bd2013-08-12 18:38:34 +000035template <> struct _LIBCPP_TYPE_VIS_ONLY hash<char *>
Sean Huntaffd9e52011-07-29 23:31:56 +000036 : 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