Merge pull request #1019 from asuessenbach/hash

Introduce struct hash<vk::Flags<BitType>>
This commit is contained in:
Andreas Süßenbach 2021-07-19 16:18:12 +02:00 committed by GitHub
commit 4e84774ab6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View File

@ -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 );

View File

@ -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 <>