mirror of
https://github.com/KhronosGroup/Vulkan-Hpp.git
synced 2024-10-14 16:32:17 +00:00
Introduce struct hash<vk::Flags<BitType>>
Allows the use of any vk::*Flags type as the key in a std::unordered_map
This commit is contained in:
parent
f70d4291e4
commit
488780dfd4
@ -409,7 +409,17 @@ std::string VulkanHppGenerator::generateHashStructures() const
|
||||
${hashes}
|
||||
)";
|
||||
|
||||
std::string hashes;
|
||||
// start with the hash on Flags<BitType>
|
||||
std::string hashes = R"(
|
||||
template <typename BitType> struct hash<VULKAN_HPP_NAMESPACE::Flags<BitType>>
|
||||
{
|
||||
std::size_t operator()(VULKAN_HPP_NAMESPACE::Flags<BitType> const& flags) const VULKAN_HPP_NOEXCEPT
|
||||
{
|
||||
return std::hash<typename std::underlying_type<BitType>::type>{}(static_cast<typename std::underlying_type<BitType>::type>(flags));
|
||||
}
|
||||
};
|
||||
)";
|
||||
|
||||
for ( auto const & feature : m_features )
|
||||
{
|
||||
hashes += generateHashStructures( feature.second.types, feature.first );
|
||||
|
@ -13263,6 +13263,16 @@ namespace std
|
||||
//=== HASH structures ===
|
||||
//=======================
|
||||
|
||||
template <typename BitType>
|
||||
struct hash<VULKAN_HPP_NAMESPACE::Flags<BitType>>
|
||||
{
|
||||
std::size_t operator()( VULKAN_HPP_NAMESPACE::Flags<BitType> const & flags ) const VULKAN_HPP_NOEXCEPT
|
||||
{
|
||||
return std::hash<typename std::underlying_type<BitType>::type>{}(
|
||||
static_cast<typename std::underlying_type<BitType>::type>( flags ) );
|
||||
}
|
||||
};
|
||||
|
||||
//=== VK_VERSION_1_0 ===
|
||||
|
||||
template <>
|
||||
|
Loading…
Reference in New Issue
Block a user