Core/Flags: Add std::hash specialization
This commit is contained in:
parent
5669b5bc60
commit
1c77a5e549
|
|
@ -3,6 +3,7 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Core/Flags.hpp>
|
#include <Nazara/Core/Flags.hpp>
|
||||||
|
#include <utility>
|
||||||
#include <Nazara/Core/Debug.hpp>
|
#include <Nazara/Core/Debug.hpp>
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
|
|
@ -375,4 +376,19 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
template<typename E>
|
||||||
|
struct hash<Nz::Flags<E>>
|
||||||
|
{
|
||||||
|
std::size_t operator()(const Nz::Flags<E>& flags)
|
||||||
|
{
|
||||||
|
using UnderlyingType = typename Nz::Flags<E>::BitField;
|
||||||
|
using Hasher = hash<UnderlyingType>;
|
||||||
|
Hasher hasher;
|
||||||
|
return hasher(static_cast<UnderlyingType>(flags));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#include <Nazara/Core/DebugOff.hpp>
|
#include <Nazara/Core/DebugOff.hpp>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue