Core/Flags: Add std::hash specialization

This commit is contained in:
Jérôme Leclercq 2021-07-17 20:56:03 +02:00
parent 5669b5bc60
commit 1c77a5e549
1 changed files with 16 additions and 0 deletions

View File

@ -3,6 +3,7 @@
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Core/Flags.hpp>
#include <utility>
#include <Nazara/Core/Debug.hpp>
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>