mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-12-25 04:11:44 +00:00
hash.h: helper function for hashing scoped & unscoped enums
This commit is contained in:
parent
7b3b1d3ffc
commit
d5819ce546
29
src/common/hash.h
Normal file
29
src/common/hash.h
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
mkvmerge -- utility for splicing together matroska files
|
||||
from component media subtypes
|
||||
|
||||
Distributed under the GPL v2
|
||||
see the file COPYING for details
|
||||
or visit http://www.gnu.org/copyleft/gpl.html
|
||||
|
||||
Hash/unordered map helper functions
|
||||
|
||||
Written by Moritz Bunkus <moritz@bunkus.org>.
|
||||
*/
|
||||
|
||||
#ifndef MTX_COMMON_HASH_H
|
||||
#define MTX_COMMON_HASH_H
|
||||
|
||||
#include <functional>
|
||||
|
||||
// Support for hashing all scoped and unscoped enums via their
|
||||
// underlying type.
|
||||
template<typename Tkey>
|
||||
struct std::hash {
|
||||
std::size_t operator()(Tkey const &key) const {
|
||||
using T = typename std::underlying_type<Tkey>::type;
|
||||
return std::hash<T>()(static_cast<T>(key));
|
||||
}
|
||||
};
|
||||
|
||||
#endif // MTX_COMMON_HASH_H
|
Loading…
Reference in New Issue
Block a user