~ubuntu-branches/ubuntu/wily/mkvtoolnix/wily

« back to all changes in this revision

Viewing changes to src/common/hash.h

  • Committer: Package Import Robot
  • Author(s): Christian Marillat
  • Date: 2015-04-26 10:36:27 UTC
  • mfrom: (1.1.29) (4.2.45 sid)
  • Revision ID: package-import@ubuntu.com-20150426103627-k53p8hrai2ynikaa
Tags: 7.8.0-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
   mkvmerge -- utility for splicing together matroska files
 
3
   from component media subtypes
 
4
 
 
5
   Distributed under the GPL v2
 
6
   see the file COPYING for details
 
7
   or visit http://www.gnu.org/copyleft/gpl.html
 
8
 
 
9
   Hash/unordered map helper functions
 
10
 
 
11
   Written by Moritz Bunkus <moritz@bunkus.org>.
 
12
*/
 
13
 
 
14
#ifndef MTX_COMMON_HASH_H
 
15
#define MTX_COMMON_HASH_H
 
16
 
 
17
#include <functional>
 
18
 
 
19
namespace mtx {
 
20
 
 
21
// Support for hashing all scoped and unscoped enums via their
 
22
// underlying type.
 
23
template<typename Tkey>
 
24
struct hash {
 
25
  std::size_t operator()(Tkey const &key) const {
 
26
    using T = typename std::underlying_type<Tkey>::type;
 
27
    return std::hash<T>()(static_cast<T>(key));
 
28
  }
 
29
};
 
30
 
 
31
}
 
32
 
 
33
#endif  // MTX_COMMON_HASH_H