1 // std::hash and std::tr1::hash definitions -*- C++ -*-
3 // Copyright (C) 2007 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this library; see the file COPYING. If not, write to
18 // the Free Software Foundation, 51 Franklin Street, Fifth Floor,
19 // Boston, MA 02110-1301, USA.
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
33 #ifdef __GXX_EXPERIMENTAL_CXX0X__
35 # define _GLIBCXX_BEGIN_NAMESPACE_TR1
36 # define _GLIBCXX_END_NAMESPACE_TR1
38 #include <tr1/functional>
39 # define _GLIBCXX_INCLUDE_AS_TR1
40 # define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 {
41 # define _GLIBCXX_END_NAMESPACE_TR1 }
46 _GLIBCXX_BEGIN_NAMESPACE_TR1
50 hash
<string
>::operator()(string __s
) const
51 { return _Fnv_hash
<>::hash(__s
.data(), __s
.length()); }
55 hash
<const string
&>::operator()(const string
& __s
) const
56 { return _Fnv_hash
<>::hash(__s
.data(), __s
.length()); }
58 #ifdef _GLIBCXX_USE_WCHAR_T
61 hash
<wstring
>::operator()(wstring __s
) const
63 const char* __p
= reinterpret_cast<const char*>(__s
.data());
64 return _Fnv_hash
<>::hash(__p
, __s
.length() * sizeof(wchar_t));
69 hash
<const wstring
&>::operator()(const wstring
& __s
) const
71 const char* __p
= reinterpret_cast<const char*>(__s
.data());
72 return _Fnv_hash
<>::hash(__p
, __s
.length() * sizeof(wchar_t));
76 _GLIBCXX_END_NAMESPACE_TR1