Specify std::min to work on type size_t for copy operations in struct constructors. (#1782)

This commit is contained in:
Andreas Süßenbach 2024-02-02 21:22:52 +01:00 committed by GitHub
parent 7bd7372016
commit 3a946ddfa1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -10678,7 +10678,7 @@ std::string VulkanHppGenerator::generateStructConstructorsEnhanced( std::pair<st
${copyOp}( ${memberName}, ${memberName}_.data(), ${arraySizeExpression} );)";
std::string arraySizeExpression = ( mit->lenExpressions[0] == "null-terminated" )
? ( "std::min( " + mit->name + "_.size(), " + mit->arraySizes[0] + " )" )
? ( "std::min<size_t>( " + mit->name + "_.size(), " + mit->arraySizes[0] + " )" )
: ( mit->lenExpressions[0] + " * sizeof( " + argumentType + " )" );
copyOps += replaceWithMap( copyOpsTemplate,
{ { "arraySize", mit->arraySizes[0] },
@ -11325,7 +11325,7 @@ std::string VulkanHppGenerator::generateStructSetter( std::string const & struct
${structureName} & set${ArrayName}( std::string const & ${arrayName}_ ) VULKAN_HPP_NOEXCEPT
{
VULKAN_HPP_ASSERT( ${arrayName}_.size() < ${arraySize} );
strncpy( ${arrayName}, ${arrayName}_.data(), std::min( ${arrayName}_.size(), ${arraySize} );
strncpy( ${arrayName}, ${arrayName}_.data(), std::min<size_t>( ${arrayName}_.size(), ${arraySize} );
return *this;
}
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/