]> git.pld-linux.org Git - packages/boost.git/blob - boost-hash-enum.patch
- fix hash_value() issue in wesnoth
[packages/boost.git] / boost-hash-enum.patch
1 $NetBSD: patch-boost_functional_hash_hash.hpp,v 1.1 2012/08/31 12:20:56 adam Exp $
2
3 Allow hashing enums.
4
5 --- boost/functional/hash/hash.hpp.orig 2012-07-15 23:28:30.000000000 +0000
6 +++ boost/functional/hash/hash.hpp
7 @@ -15,6 +15,8 @@
8  #include <boost/functional/hash/detail/hash_float.hpp>
9  #include <string>
10  #include <boost/limits.hpp>
11 +#include <boost/type_traits/is_enum.hpp>
12 +#include <boost/utility/enable_if.hpp>
13  
14  #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
15  #include <boost/type_traits/is_pointer.hpp>
16 @@ -90,6 +92,10 @@ namespace boost
17      template <typename T>
18      typename boost::hash_detail::ulong_numbers<T>::type hash_value(T);
19  
20 +    template <typename T>
21 +    typename boost::enable_if<boost::is_enum<T>, std::size_t>::type
22 +       hash_value(T);
23 +
24  #if !BOOST_WORKAROUND(__DMC__, <= 0x848)
25      template <class T> std::size_t hash_value(T* const&);
26  #else
27 @@ -179,6 +185,13 @@ namespace boost
28          return hash_detail::hash_value_unsigned(v);
29      }
30  
31 +    template <typename T>
32 +    typename boost::enable_if<boost::is_enum<T>, std::size_t>::type
33 +       hash_value(T v)
34 +    {
35 +       return static_cast<std::size_t>(v);
36 +    }
37 +
38      // Implementation by Alberto Barbati and Dave Harris.
39  #if !BOOST_WORKAROUND(__DMC__, <= 0x848)
40      template <class T> std::size_t hash_value(T* const& v)
This page took 0.077819 seconds and 3 git commands to generate.