From 207031caa4a7c1ee9b1afebe509bc96fc090c59d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20S=C3=BC=C3=9Fenbach?= Date: Thu, 13 Jul 2023 11:26:01 +0200 Subject: [PATCH] change calls to std::find, std::find_if, and std::find_if_not to functionally identical calls to std::any_of, std::all_of, and std::none_of, when appropriate (#1621) --- .../EnableValidationWithCallback.cpp | 7 +- RAII_Samples/RayTracing/RayTracing.cpp | 21 +- .../SurfaceCapabilities.cpp | 12 +- VideoHppGenerator.cpp | 23 +- VulkanHppGenerator.cpp | 350 +++++++++--------- .../EnableValidationWithCallback.cpp | 7 +- samples/RayTracing/RayTracing.cpp | 20 +- samples/utils/utils.cpp | 31 +- vulkan/vulkan.cppm | 2 +- vulkan/vulkansc.cppm | 6 +- vulkan/vulkansc.hpp | 74 ++-- 11 files changed, 270 insertions(+), 283 deletions(-) diff --git a/RAII_Samples/EnableValidationWithCallback/EnableValidationWithCallback.cpp b/RAII_Samples/EnableValidationWithCallback/EnableValidationWithCallback.cpp index 275cba9..43dfcf4 100644 --- a/RAII_Samples/EnableValidationWithCallback/EnableValidationWithCallback.cpp +++ b/RAII_Samples/EnableValidationWithCallback/EnableValidationWithCallback.cpp @@ -109,10 +109,9 @@ bool checkLayers( std::vector const & layers, std::vector cubeData = { @@ -695,11 +698,9 @@ int main( int /*argc*/, char ** /*argv*/ ) for ( auto & pd : physicalDevices ) { std::vector ep = pd.enumerateDeviceExtensionProperties(); - if ( std::find_if( ep.cbegin(), - ep.cend(), - []( vk::ExtensionProperties const & prop ) - { return strcmp( prop.extensionName, VK_NV_RAY_TRACING_EXTENSION_NAME ) == 0; } ) != - ep.cend() ) + if ( std::any_of( ep.cbegin(), + ep.cend(), + []( vk::ExtensionProperties const & prop ) { return strcmp( prop.extensionName, VK_NV_RAY_TRACING_EXTENSION_NAME ) == 0; } ) ) { physicalDevice = pd; break; @@ -733,11 +734,11 @@ int main( int /*argc*/, char ** /*argv*/ ) auto supportedFeatures = physicalDevice.getFeatures2(); vk::raii::Device device = vk::raii::su::makeDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, - { VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, - VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, - VK_KHR_MAINTENANCE_3_EXTENSION_NAME, - VK_KHR_SWAPCHAIN_EXTENSION_NAME, - VK_NV_RAY_TRACING_EXTENSION_NAME }, + { VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, + VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, + VK_KHR_MAINTENANCE_3_EXTENSION_NAME, + VK_KHR_SWAPCHAIN_EXTENSION_NAME, + VK_NV_RAY_TRACING_EXTENSION_NAME }, &supportedFeatures.get().features, &supportedFeatures.get() ); diff --git a/RAII_Samples/SurfaceCapabilities/SurfaceCapabilities.cpp b/RAII_Samples/SurfaceCapabilities/SurfaceCapabilities.cpp index 73f15dd..78f00f8 100644 --- a/RAII_Samples/SurfaceCapabilities/SurfaceCapabilities.cpp +++ b/RAII_Samples/SurfaceCapabilities/SurfaceCapabilities.cpp @@ -50,12 +50,12 @@ int main( int /*argc*/, char ** /*argv*/ ) { vk::raii::Context context; - std::vector instanceExtensionProperties = context.enumerateInstanceExtensionProperties(); - bool supportsGetSurfaceCapabilities2 = ( std::find_if( instanceExtensionProperties.begin(), - instanceExtensionProperties.end(), - []( vk::ExtensionProperties const & ep ) { - return strcmp( ep.extensionName, VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME ) == 0; - } ) != instanceExtensionProperties.end() ); + std::vector instanceExtensionProperties = context.enumerateInstanceExtensionProperties(); + + bool supportsGetSurfaceCapabilities2 = + std::any_of( instanceExtensionProperties.begin(), + instanceExtensionProperties.end(), + []( vk::ExtensionProperties const & ep ) { return strcmp( ep.extensionName, VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME ) == 0; } ); std::vector extensions = vk::su::getInstanceExtensions(); if ( supportsGetSurfaceCapabilities2 ) diff --git a/VideoHppGenerator.cpp b/VideoHppGenerator.cpp index f649dc8..136162b 100644 --- a/VideoHppGenerator.cpp +++ b/VideoHppGenerator.cpp @@ -103,7 +103,7 @@ std::vector::iterator VideoHppGenerator::addImplicitlyRequiredTypes ( *typeIt->second.requiredBy.begin() == extensionData.depends ) ); if ( typeIt->second.requiredBy.empty() && ( std::find( extensionData.requireData.types.begin(), reqIt, typeIt->first ) == reqIt ) ) { - assert( std::find( reqIt, extensionData.requireData.types.end(), typeIt->first ) == extensionData.requireData.types.end() ); + assert( std::none_of( reqIt, extensionData.requireData.types.end(), [&typeIt]( std::string const & type ) { return type == typeIt->first; } ) ); typeIt->second.requiredBy.insert( extensionData.name ); reqIt = std::next( extensionData.requireData.types.insert( reqIt, typeIt->first ) ); } @@ -368,7 +368,7 @@ std::string VideoHppGenerator::generateStructs() const ${structs} )"; - std::string structs; + std::string structs; for ( auto const & extension : m_extensions ) { structs += generateStructs( extension.requireData, extension.name ); @@ -396,7 +396,7 @@ std::string VideoHppGenerator::generateStructs( RequireData const & requireData, bool VideoHppGenerator::isExtension( std::string const & name ) const { - return std::find_if( m_extensions.begin(), m_extensions.end(), [&name]( ExtensionData const & ed ) { return ed.name == name; } ) != m_extensions.end(); + return std::any_of( m_extensions.begin(), m_extensions.end(), [&name]( ExtensionData const & ed ) { return ed.name == name; } ); } void VideoHppGenerator::readEnums( tinyxml2::XMLElement const * element ) @@ -459,9 +459,7 @@ void VideoHppGenerator::readEnumsEnum( tinyxml2::XMLElement const * element, std std::string prefix = toUpperCase( enumIt->first ) + "_"; checkForError( name.starts_with( prefix ), line, "encountered enum value <" + name + "> that does not begin with expected prefix <" + prefix + ">" ); - checkForError( std::find_if( enumIt->second.values.begin(), - enumIt->second.values.end(), - [&name]( EnumValueData const & evd ) { return evd.name == name; } ) == enumIt->second.values.end(), + checkForError( std::none_of( enumIt->second.values.begin(), enumIt->second.values.end(), [&name]( EnumValueData const & evd ) { return evd.name == name; } ), line, "enum value <" + name + "> already part of enum <" + enumIt->first + ">" ); enumIt->second.values.push_back( { name, value, line } ); @@ -670,7 +668,7 @@ void VideoHppGenerator::readStructMember( tinyxml2::XMLElement const * element, } assert( !name.empty() ); - checkForError( std::find_if( members.begin(), members.end(), [&name]( MemberData const & md ) { return md.name == name; } ) == members.end(), + checkForError( std::none_of( members.begin(), members.end(), [&name]( MemberData const & md ) { return md.name == name; } ), line, "struct member name <" + name + "> already used" ); memberData.name = name; @@ -896,12 +894,13 @@ void VideoHppGenerator::sortStructs() ext.requireData.types.erase( it ); reqIt = std::next( ext.requireData.types.insert( reqIt, member.type.type ) ); } -#if !defined(NDEBUG) +#if !defined( NDEBUG ) else { auto depIt = std::find_if( m_extensions.begin(), m_extensions.end(), [&ext]( ExtensionData const & ed ) { return ed.name == ext.depends; } ); - assert( ( depIt != m_extensions.end() ) && - ( std::find( depIt->requireData.types.begin(), depIt->requireData.types.end(), member.type.type ) != depIt->requireData.types.end() ) ); + assert( ( depIt != m_extensions.end() ) && std::any_of( depIt->requireData.types.begin(), + depIt->requireData.types.end(), + [&member]( std::string const & type ) { return type == member.type.type; } ) ); } #endif } @@ -960,9 +959,9 @@ int main( int argc, char ** argv ) generator.generateHppFile(); -# if !defined( CLANG_FORMAT_EXECUTABLE ) +#if !defined( CLANG_FORMAT_EXECUTABLE ) std::cout << "VideoHppGenerator: could not find clang-format. The generated files will not be formatted accordingly.\n"; -# endif +#endif } catch ( std::exception const & e ) { diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 3a996e5..3fd1d93 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -818,8 +818,7 @@ void VulkanHppGenerator::addMissingFlagBits( std::vector & requireD std::string flagBits = bitmaskIt->first.substr( 0, pos + 4 ) + "Bit" + bitmaskIt->first.substr( pos + 4 ); // as the bitmask's requirement is still empty, this flagBits should not be listed in the require list! - assert( std::find_if( require.types.begin(), require.types.end(), [&flagBits]( std::string const & type ) { return ( type == flagBits ); } ) == - require.types.end() ); + assert( std::none_of( require.types.begin(), require.types.end(), [&flagBits]( std::string const & type ) { return ( type == flagBits ); } ) ); bitmaskIt->second.require = flagBits; @@ -866,14 +865,14 @@ std::string VulkanHppGenerator::addTitleAndProtection( std::string const & title bool VulkanHppGenerator::allVectorSizesSupported( std::vector const & params, std::map const & vectorParams ) const { // check if all vector sizes are by value and their type is one of "uint32_t", "VkDeviceSize", or "VkSampleCountFlagBits" - return std::find_if_not( vectorParams.begin(), - vectorParams.end(), - [¶ms]( auto const & vpi ) - { - return params[vpi.second.lenParam].type.isValue() && - ( ( params[vpi.second.lenParam].type.type == "uint32_t" ) || ( params[vpi.second.lenParam].type.type == "VkDeviceSize" ) || - ( params[vpi.second.lenParam].type.type == "VkSampleCountFlagBits" ) ); - } ) == vectorParams.end(); + return std::all_of( vectorParams.begin(), + vectorParams.end(), + [¶ms]( auto const & vpi ) + { + return params[vpi.second.lenParam].type.isValue() && + ( ( params[vpi.second.lenParam].type.type == "uint32_t" ) || ( params[vpi.second.lenParam].type.type == "VkDeviceSize" ) || + ( params[vpi.second.lenParam].type.type == "VkSampleCountFlagBits" ) ); + } ); } void VulkanHppGenerator::appendDispatchLoaderDynamicCommands( std::vector const & requireData, @@ -1121,14 +1120,12 @@ void VulkanHppGenerator::checkEnumCorrectness() const // check that the alias names are known enum values for ( auto const & value : e.second.values ) { - checkForError( value.alias.empty() || - ( std::find_if( e.second.values.begin(), e.second.values.end(), [&value]( auto const & evd ) { return evd.name == value.alias; } ) != - e.second.values.end() ) || - ( std::find_if( e.second.unsupportedValues.begin(), - e.second.unsupportedValues.end(), - [&value]( auto const & evd ) { return evd.name == value.alias; } ) != e.second.unsupportedValues.end() ), - value.xmlLine, - "enum <" + value.name + "> uses unknown alias <" + value.alias + ">" ); + checkForError( + value.alias.empty() || + std::any_of( e.second.values.begin(), e.second.values.end(), [&value]( auto const & evd ) { return evd.name == value.alias; } ) || + std::any_of( e.second.unsupportedValues.begin(), e.second.unsupportedValues.end(), [&value]( auto const & evd ) { return evd.name == value.alias; } ), + value.xmlLine, + "enum <" + value.name + "> uses unknown alias <" + value.alias + ">" ); } } @@ -1261,7 +1258,7 @@ bool VulkanHppGenerator::checkEquivalentSingularConstructor( std::vectorsecond.values.begin(), - objectTypeIt->second.values.end(), - [&handle]( EnumValueData const & evd ) - { return evd.name == handle.second.objTypeEnum; } ) != objectTypeIt->second.values.end(), + checkForError( !isTypeUsed( handle.first ) || std::any_of( objectTypeIt->second.values.begin(), + objectTypeIt->second.values.end(), + [&handle]( EnumValueData const & evd ) { return evd.name == handle.second.objTypeEnum; } ), handle.second.xmlLine, "handle <" + handle.first + "> specifies unknown \"objtypeenum\" <" + handle.second.objTypeEnum + ">" ); } @@ -1368,10 +1364,10 @@ void VulkanHppGenerator::checkHandleCorrectness() const if ( objectTypeValue.name != "VK_OBJECT_TYPE_UNKNOWN" ) { // check for non-alias objectTypes only - checkForError( !objectTypeValue.alias.empty() || ( std::find_if( m_handles.begin(), - m_handles.end(), - [&objectTypeValue]( std::pair const & hd ) - { return hd.second.objTypeEnum == objectTypeValue.name; } ) != m_handles.end() ), + checkForError( !objectTypeValue.alias.empty() || std::any_of( m_handles.begin(), + m_handles.end(), + [&objectTypeValue]( std::pair const & hd ) + { return hd.second.objTypeEnum == objectTypeValue.name; } ), objectTypeValue.xmlLine, "VkObjectType value <" + objectTypeValue.name + "> not specified as \"objtypeenum\" for any handle" ); } @@ -1467,16 +1463,15 @@ void VulkanHppGenerator::checkStructMemberCorrectness( std::string const & assert( !unionMember.selection.empty() ); for ( auto const & selection : unionMember.selection ) { - checkForError( - ( std::find_if( selectorEnumIt->second.values.begin(), - selectorEnumIt->second.values.end(), - [&selection]( EnumValueData const & evd ) { return evd.name == selection; } ) != selectorEnumIt->second.values.end() ) || - ( std::find_if( selectorEnumIt->second.unsupportedValues.begin(), - selectorEnumIt->second.unsupportedValues.end(), - [&selection]( EnumValueData const & evd ) { return evd.name == selection; } ) != selectorEnumIt->second.unsupportedValues.end() ), - unionMember.xmlLine, - "union member <" + unionMember.name + "> uses selection <" + selection + "> that is not part of the selector type <" + selectorIt->type.type + - ">" ); + checkForError( std::any_of( selectorEnumIt->second.values.begin(), + selectorEnumIt->second.values.end(), + [&selection]( EnumValueData const & evd ) { return evd.name == selection; } ) || + std::any_of( selectorEnumIt->second.unsupportedValues.begin(), + selectorEnumIt->second.unsupportedValues.end(), + [&selection]( EnumValueData const & evd ) { return evd.name == selection; } ), + unionMember.xmlLine, + "union member <" + unionMember.name + "> uses selection <" + selection + "> that is not part of the selector type <" + + selectorIt->type.type + ">" ); } } } @@ -1501,12 +1496,11 @@ void VulkanHppGenerator::checkStructMemberCorrectness( std::string const & // check that the value exists in the specified enum (if the struct is used at all) if ( structUsed ) { - checkForError( std::find_if( enumIt->second.values.begin(), - enumIt->second.values.end(), - [&member]( auto const & evd ) { return member.value == evd.name; } ) != enumIt->second.values.end(), - member.xmlLine, - "value <" + member.value + "> for member <" + member.name + "> in structure <" + structureName + "> of enum type <" + - member.type.type + "> not listed" ); + checkForError( + std::any_of( enumIt->second.values.begin(), enumIt->second.values.end(), [&member]( auto const & evd ) { return member.value == evd.name; } ), + member.xmlLine, + "value <" + member.value + "> for member <" + member.name + "> in structure <" + structureName + "> of enum type <" + member.type.type + + "> not listed" ); // special handling for sType: no value should appear more than once if ( member.name == "sType" ) { @@ -1687,8 +1681,9 @@ std::vector VulkanHppGenerator::determineDataTypes( std::vectorfirst ) != returnParams.end() ) && - ( std::find( returnParams.begin(), returnParams.end(), vectorParamIt->second.lenParam ) != returnParams.end() ) ) + if ( ( vectorParamIt != vectorParams.end() ) && + std::any_of( returnParams.begin(), returnParams.end(), [&vectorParamIt]( size_t rp ) { return rp == vectorParamIt->first; } ) && + std::any_of( returnParams.begin(), returnParams.end(), [&vectorParamIt]( size_t rp ) { return rp == vectorParamIt->second.lenParam; } ) ) { dataTypes.push_back( "uint8_t" ); } @@ -1719,13 +1714,13 @@ size_t VulkanHppGenerator::determineDefaultStartIndex( std::vector co bool VulkanHppGenerator::determineEnumeration( std::map const & vectorParams, std::vector const & returnParams ) const { // a command is considered to be enumerating some data, if for at least one vectorParam both, the data and the counter, are returnParams - return std::find_if( vectorParams.begin(), - vectorParams.end(), - [&returnParams]( auto const & vp ) - { - return std::find( returnParams.begin(), returnParams.end(), vp.first ) != returnParams.end() && - std::find( returnParams.begin(), returnParams.end(), vp.second.lenParam ) != returnParams.end(); - } ) != vectorParams.end(); + return std::any_of( vectorParams.begin(), + vectorParams.end(), + [&returnParams]( auto const & vp ) + { + return std::any_of( returnParams.begin(), returnParams.end(), [&vp]( size_t rp ) { return rp == vp.first; } ) && + std::any_of( returnParams.begin(), returnParams.end(), [&vp]( size_t rp ) { return rp == vp.second.lenParam; } ); + } ); } size_t VulkanHppGenerator::determineInitialSkipCount( std::string const & command ) const @@ -1778,11 +1773,10 @@ std::vector::const_iterat std::vector::const_iterator> constructorIts; auto isConstructorCandidate = [this, &handleType]( std::pair const & cd ) { - return isSupported( cd.second.requiredBy ) && ( std::find_if( cd.second.params.begin(), - cd.second.params.end(), - [&handleType]( ParamData const & pd ) { - return ( pd.type.type == handleType ) && pd.type.isNonConstPointer(); - } ) != cd.second.params.end() ); + return isSupported( cd.second.requiredBy ) && + std::any_of( cd.second.params.begin(), + cd.second.params.end(), + [&handleType]( ParamData const & pd ) { return ( pd.type.type == handleType ) && pd.type.isNonConstPointer(); } ); }; for ( auto commandIt = m_commands.begin(); commandIt != m_commands.end(); ) { @@ -1819,13 +1813,12 @@ std::vector::const_iterat }; return ( destructorParam.name == desctructorHandleParamIt->lenExpression ) || - ( std::find_if( commandIt->second.params.begin(), commandIt->second.params.end(), isDestructorParamType ) != commandIt->second.params.end() ); + std::any_of( commandIt->second.params.begin(), commandIt->second.params.end(), isDestructorParamType ); }; // the constructor candidate is valid, if none of the (relevant) destructor parameters is missing in the // constructor candidate params - valid = ( std::find_if_not( destructorIt->second.params.begin(), destructorIt->second.params.end(), isConstructorCandidateParam ) == - destructorIt->second.params.end() ); + valid = std::all_of( destructorIt->second.params.begin(), destructorIt->second.params.end(), isConstructorCandidateParam ); } if ( valid ) { @@ -1905,7 +1898,7 @@ std::set VulkanHppGenerator::determineSkippedParams( std::vector VulkanHppGenerator::determ if ( params[i].lenParams.empty() ) { std::string const & lenExpression = params[i].lenExpression; - assert( std::find_if( params.begin(), params.end(), [&lenExpression]( auto const & pd ) { return ( lenExpression == pd.name ); } ) == params.end() ); + assert( std::none_of( params.begin(), params.end(), [&lenExpression]( auto const & pd ) { return ( lenExpression == pd.name ); } ) ); auto lenIt = std::find_if( params.begin(), params.end(), [this, &lenExpression]( auto const & pd ) { return isLenByStructMember( lenExpression, pd ); } ); assert( lenIt != params.end() ); @@ -2024,10 +2016,9 @@ void VulkanHppGenerator::distributeSecondLevelCommands( std::set co assert( !handleIt->second.constructorIts.empty() ); if ( ( *handleIt->second.constructorIts.begin() )->second.handle == handle.first ) { - assert( std::find_if( handleIt->second.constructorIts.begin(), + assert( std::none_of( handleIt->second.constructorIts.begin(), handleIt->second.constructorIts.end(), - [&handle]( auto const & constructorIt ) - { return constructorIt->second.handle != handle.first; } ) == handleIt->second.constructorIts.end() ); + [&handle]( auto const & constructorIt ) { return constructorIt->second.handle != handle.first; } ) ); handleIt->second.secondLevelCommands.insert( *command ); command = handle.second.commands.erase( command ); foundCommand = true; @@ -2073,7 +2064,7 @@ std::map::const_iterator VulkanHppGe { auto lambda = [&name]( std::pair const & ad ) { return ad.second.name == name; }; auto it = std::find_if( aliases.begin(), aliases.end(), lambda ); - assert( ( it == aliases.end() ) || ( std::find_if( std::next( it ), aliases.end(), lambda ) == aliases.end() ) ); + assert( ( it == aliases.end() ) || std::none_of( std::next( it ), aliases.end(), lambda ) ); return it; } @@ -2338,8 +2329,8 @@ std::string VulkanHppGenerator::generateArgumentListEnhanced( std::vectorfirst ) != returnParams.end() ) && - ( std::find( returnParams.begin(), returnParams.end(), vectorParamIt->second.lenParam ) != returnParams.end() ) ) + std::any_of( returnParams.begin(), returnParams.end(), [&vectorParamIt]( size_t rp ) { return rp == vectorParamIt->first; } ) && + std::any_of( returnParams.begin(), returnParams.end(), [&vectorParamIt]( size_t rp ) { return rp == vectorParamIt->second.lenParam; } ) ) { type = "Uint8_t"; } @@ -2403,8 +2394,9 @@ std::string VulkanHppGenerator::generateArgumentTemplates( std::vectorfirst ) == returnParams.end() ) || - ( std::find( returnParams.begin(), returnParams.end(), vectorParamIt->second.lenParam ) == returnParams.end() ) ) + if ( ( vectorParamIt == vectorParams.end() ) || + std::none_of( returnParams.begin(), returnParams.end(), [&vectorParamIt]( size_t rp ) { return rp == vectorParamIt->first; } ) || + std::none_of( returnParams.begin(), returnParams.end(), [&vectorParamIt]( size_t rp ) { return rp == vectorParamIt->second.lenParam; } ) ) { assert( chainedReturnParams.empty() ); // only templated parameters that are not part of an enumeration are really templated @@ -2925,8 +2917,7 @@ std::string VulkanHppGenerator::generateCallArgumentEnhancedValue( std::vector

( " + param.name + " )"; } // check if this param is used as the stride of an other param - assert( std::find_if( params.begin(), params.end(), [paramIndex]( ParamData const & pd ) { return pd.strideParam.second == paramIndex; } ) == - params.end() ); + assert( std::none_of( params.begin(), params.end(), [paramIndex]( ParamData const & pd ) { return pd.strideParam.second == paramIndex; } ) ); } else { @@ -3000,17 +2991,14 @@ std::string VulkanHppGenerator::generateCallSequence( std::string const & std::string dispatcher = raii ? "getDispatcher()->" : "d."; // if at least one returnParam is a size value of a vector param (and no singular params), we need two calls if ( singularParams.empty() && - ( std::find_if( returnParams.begin(), - returnParams.end(), - [&vectorParams]( size_t rp ) - { - return ( std::find_if( vectorParams.begin(), vectorParams.end(), [rp]( auto const & vp ) { return vp.second.lenParam == rp; } ) != - vectorParams.end() ); - } ) != returnParams.end() ) ) + std::any_of( returnParams.begin(), + returnParams.end(), + [&vectorParams]( size_t rp ) + { return std::any_of( vectorParams.begin(), vectorParams.end(), [rp]( auto const & vp ) { return vp.second.lenParam == rp; } ); } ) ) { auto vectorParamIt = vectorParams.begin(); - assert( std::find( returnParams.begin(), returnParams.end(), vectorParamIt->first ) != returnParams.end() ); - assert( std::find( returnParams.begin(), returnParams.end(), vectorParamIt->second.lenParam ) != returnParams.end() ); + assert( std::any_of( returnParams.begin(), returnParams.end(), [&vectorParamIt]( size_t rp ) { return rp == vectorParamIt->first; } ) ); + assert( std::any_of( returnParams.begin(), returnParams.end(), [&vectorParamIt]( size_t rp ) { return rp == vectorParamIt->second.lenParam; } ) ); std::string firstCallArguments = generateCallArgumentsEnhanced( commandData, initialSkipCount, true, {}, templatedParams, raii ); std::string secondCallArguments = generateCallArgumentsEnhanced( commandData, initialSkipCount, false, {}, templatedParams, raii ); @@ -3079,8 +3067,8 @@ std::string VulkanHppGenerator::generateCallSequence( std::string const & std::string resizes; for ( auto const & vp : vectorParams ) { - assert( ( std::find( returnParams.begin(), returnParams.end(), vp.first ) != returnParams.end() ) && - ( std::find( returnParams.begin(), returnParams.end(), vp.second.lenParam ) != returnParams.end() ) ); + assert( std::any_of( returnParams.begin(), returnParams.end(), [&vp]( size_t rp ) { return rp == vp.first; } ) && + std::any_of( returnParams.begin(), returnParams.end(), [&vp]( size_t rp ) { return rp == vp.second.lenParam; } ) ); resizes += startLowerCase( stripPrefix( commandData.params[vp.first].name, "p" ) ) + ".resize( " + startLowerCase( stripPrefix( commandData.params[vp.second.lenParam].name, "p" ) ) + " );\n"; } @@ -5743,8 +5731,8 @@ std::string VulkanHppGenerator::generateDataPreparation( CommandData const & std::string resizes; for ( auto const & vp : vectorParams ) { - assert( ( std::find( returnParams.begin(), returnParams.end(), vp.first ) != returnParams.end() ) && - ( std::find( returnParams.begin(), returnParams.end(), vp.second.lenParam ) != returnParams.end() ) ); + assert( std::any_of( returnParams.begin(), returnParams.end(), [&vp]( size_t rp ) { return rp == vp.first; } ) && + std::any_of( returnParams.begin(), returnParams.end(), [&vp]( size_t rp ) { return rp == vp.second.lenParam; } ) ); resizes += startLowerCase( stripPrefix( commandData.params[vp.first].name, "p" ) ) + ".resize( " + startLowerCase( stripPrefix( commandData.params[vp.second.lenParam].name, "p" ) ) + " );\n"; } @@ -5830,7 +5818,7 @@ std::string VulkanHppGenerator::generateDataSizeChecks( CommandData const & { auto vectorParamIt = vectorParams.find( returnParams[i] ); if ( ( vectorParamIt != vectorParams.end() ) && ( templatedParams.find( returnParams[i] ) != templatedParams.end() ) && - ( std::find( returnParams.begin(), returnParams.end(), vectorParamIt->second.lenParam ) == returnParams.end() ) ) + std::none_of( returnParams.begin(), returnParams.end(), [&vectorParamIt]( size_t rp ) { return rp == vectorParamIt->second.lenParam; } ) ) { dataSizeChecks += replaceWithMap( dataSizeCheckTemplate, { { "dataSize", commandData.params[vectorParamIt->second.lenParam].name }, { "dataType", returnParamTypes[i] } } ); @@ -7476,7 +7464,7 @@ ${indexTypeTraits} assert( valueName.starts_with( "eUint" ) ); auto beginDigit = valueName.begin() + strlen( "eUint" ); assert( isdigit( *beginDigit ) ); - auto endDigit = std::find_if_not( beginDigit, valueName.end(), []( std::string::value_type c ) { return isdigit( c ); } ); + auto endDigit = std::find_if( beginDigit, valueName.end(), []( std::string::value_type c ) { return !isdigit( c ); } ); cppType = "uint" + valueName.substr( strlen( "eUint" ), endDigit - beginDigit ) + "_t"; } @@ -7585,9 +7573,8 @@ std::string VulkanHppGenerator::generateNoExcept( std::vector const // noexcept is only possible with no error codes, and the return param (if any) is not a vector param (unless it's the singular version) return ( errorCodes.empty() && ( ( flavourFlags & CommandFlavourFlagBits::singular ) || returnParams.empty() || - ( std::find_if( returnParams.begin(), - returnParams.end(), - [&vectorParams]( size_t rp ) { return vectorParams.find( rp ) != vectorParams.end(); } ) == returnParams.end() ) ) ) + std::none_of( + returnParams.begin(), returnParams.end(), [&vectorParams]( size_t rp ) { return vectorParams.find( rp ) != vectorParams.end(); } ) ) ) ? ( vectorSizeCheck ? ( raii ? "" : " VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS" ) : " VULKAN_HPP_NOEXCEPT" ) : ""; } @@ -8425,9 +8412,9 @@ std::string VulkanHppGenerator::generateRAIIHandleConstructorArguments( std::pai #endif continue; } - else if ( std::find_if( constructorIt->second.params.begin(), - constructorIt->second.params.end(), - [¶m]( ParamData const & pd ) { return pd.lenExpression == param.name; } ) != constructorIt->second.params.end() ) + else if ( std::any_of( constructorIt->second.params.begin(), + constructorIt->second.params.end(), + [¶m]( ParamData const & pd ) { return pd.lenExpression == param.name; } ) ) { // this is the len of an other parameter, which will be mapped to an ArrayProxy assert( param.type.isValue() && ( param.type.type == "uint32_t" ) ); @@ -8701,9 +8688,9 @@ std::string VulkanHppGenerator::generateRAIIHandleConstructorParamName( std::str [&type]( ParamData const & destructorParam ) { return destructorParam.type.type == type; } ); if ( destructorParamIt != destructorIt->second.params.end() ) { - assert( std::find_if( std::next( destructorParamIt ), + assert( std::none_of( std::next( destructorParamIt ), destructorIt->second.params.end(), - [&type]( ParamData const & destructorParam ) { return destructorParam.type.type == type; } ) == destructorIt->second.params.end() ); + [&type]( ParamData const & destructorParam ) { return destructorParam.type.type == type; } ) ); if ( !destructorParamIt->type.isValue() ) { return startLowerCase( stripPrefix( stripPluralS( destructorParamIt->name ), "p" ) ); @@ -9215,19 +9202,17 @@ std::string VulkanHppGenerator::generateRAIIHandleDestructorCallArguments( std:: else { assert( param.type.isConstPointer() ); - assert( !param.lenExpression.empty() && - ( std::find_if( destructorIt->second.params.begin(), - destructorIt->second.params.end(), - [¶m]( ParamData const & pd ) { return pd.name == param.lenExpression; } ) != destructorIt->second.params.end() ) ); + assert( !param.lenExpression.empty() && std::any_of( destructorIt->second.params.begin(), + destructorIt->second.params.end(), + [¶m]( ParamData const & pd ) { return pd.name == param.lenExpression; } ) ); arguments += "reinterpret_cast<" + param.type.type + " const *>( &" + argument + " )"; } } else { assert( ( param.type.type == "uint32_t" ) && param.type.isValue() && param.arraySizes.empty() && param.lenExpression.empty() && !param.optional ); - assert( std::find_if( destructorIt->second.params.begin(), - destructorIt->second.params.end(), - [¶m]( ParamData const & pd ) { return pd.lenExpression == param.name; } ) != destructorIt->second.params.end() ); + assert( std::any_of( + destructorIt->second.params.begin(), destructorIt->second.params.end(), [¶m]( ParamData const & pd ) { return pd.lenExpression == param.name; } ) ); arguments += "1"; } encounteredArgument = true; @@ -9276,10 +9261,9 @@ std::tuplesecond.params.begin(), + else if ( std::none_of( handle.second.destructorIt->second.params.begin(), handle.second.destructorIt->second.params.end(), - [&destructorParam]( ParamData const & pd ) - { return pd.lenExpression == destructorParam.name; } ) == handle.second.destructorIt->second.params.end() ) + [&destructorParam]( ParamData const & pd ) { return pd.lenExpression == destructorParam.name; } ) ) { std::string name = destructorParam.name; if ( !destructorParam.type.isValue() ) @@ -9446,15 +9430,13 @@ std::string VulkanHppGenerator::generateRAIIHandleSingularConstructorArguments( for ( auto const & destructorParam : handle.second.destructorIt->second.params ) { if ( ( destructorParam.type.type != parentType ) && ( destructorParam.type.type != handle.first ) && - ( std::find_if( handle.second.destructorIt->second.params.begin(), - handle.second.destructorIt->second.params.end(), - [&destructorParam]( ParamData const & pd ) - { return pd.lenExpression == destructorParam.name; } ) == handle.second.destructorIt->second.params.end() ) ) + std::none_of( handle.second.destructorIt->second.params.begin(), + handle.second.destructorIt->second.params.end(), + [&destructorParam]( ParamData const & pd ) { return pd.lenExpression == destructorParam.name; } ) ) { - if ( std::find_if( constructorIt->second.params.begin(), - constructorIt->second.params.end(), - [&destructorParam]( ParamData const & pd ) - { return pd.type.type == destructorParam.type.type; } ) != constructorIt->second.params.end() ) + if ( std::any_of( constructorIt->second.params.begin(), + constructorIt->second.params.end(), + [&destructorParam]( ParamData const & pd ) { return pd.type.type == destructorParam.type.type; } ) ) { if ( isHandleType( destructorParam.type.type ) ) { @@ -10370,8 +10352,7 @@ std::string VulkanHppGenerator::generateStructConstructors( std::pair const & structData ) const { - if ( std::find_if( structData.second.members.begin(), structData.second.members.end(), [this]( MemberData const & md ) { return hasLen( md ); } ) != - structData.second.members.end() ) + if ( std::any_of( structData.second.members.begin(), structData.second.members.end(), [this]( MemberData const & md ) { return hasLen( md ); } ) ) { // map from len-members to all the array members using that len std::map::const_iterator, std::vector::const_iterator>> lenIts; @@ -11246,10 +11227,11 @@ std::string VulkanHppGenerator::generateTypenameCheck( std::vector const { if ( vectorParams.find( returnParams[i] ) != vectorParams.end() ) { - std::string elementType = ( ( flavourFlags & CommandFlavourFlagBits::chained ) && - ( std::find( chainedReturnParams.begin(), chainedReturnParams.end(), returnParams[i] ) != chainedReturnParams.end() ) ) - ? "StructureChain" - : stripPrefix( dataTypes[i], "VULKAN_HPP_NAMESPACE::" ); + std::string elementType = + ( ( flavourFlags & CommandFlavourFlagBits::chained ) && + std::any_of( chainedReturnParams.begin(), chainedReturnParams.end(), [&returnParams, i]( size_t crp ) { return crp == returnParams[i]; } ) ) + ? "StructureChain" + : stripPrefix( dataTypes[i], "VULKAN_HPP_NAMESPACE::" ); std::string extendedElementType = elementType; if ( flavourFlags & CommandFlavourFlagBits::unique ) { @@ -11304,9 +11286,7 @@ std::string VulkanHppGenerator::generateUnion( std::pairtype; } ) != structure.second.members.end() ); + std::any_of( std::next( memberIt ), structure.second.members.end(), [memberIt]( MemberData const & member ) { return member.type == memberIt->type; } ); std::string memberType = ( memberIt->arraySizes.empty() ) ? memberIt->type.compose( "VULKAN_HPP_NAMESPACE" ) : ( "const " + generateStandardArray( memberIt->type.compose( "VULKAN_HPP_NAMESPACE" ), memberIt->arraySizes ) + "&" ); @@ -11373,10 +11353,8 @@ std::string VulkanHppGenerator::generateUnion( std::pair VulkanHppGenerator::getPoolTypeAndName( std: auto memberIt = std::find_if( structIt->second.members.begin(), structIt->second.members.end(), []( MemberData const & md ) { return md.name.find( "Pool" ) != std::string::npos; } ); assert( memberIt != structIt->second.members.end() ); - assert( std::find_if( std::next( memberIt ), - structIt->second.members.end(), - []( MemberData const & md ) { return md.name.find( "Pool" ) != std::string::npos; } ) == structIt->second.members.end() ); + assert( std::none_of( + std::next( memberIt ), structIt->second.members.end(), []( MemberData const & md ) { return md.name.find( "Pool" ) != std::string::npos; } ) ); return std::make_pair( memberIt->type.type, memberIt->name ); } @@ -11871,7 +11848,9 @@ bool VulkanHppGenerator::handleRemovalCommand( std::string const & command, std: auto requireCommandIt = std::find( requireDataIt->commands.begin(), requireDataIt->commands.end(), command ); if ( requireCommandIt != requireDataIt->commands.end() ) { - assert( std::find( std::next( requireCommandIt ), requireDataIt->commands.end(), command ) == requireDataIt->commands.end() ); + assert( std::none_of( std::next( requireCommandIt ), + requireDataIt->commands.end(), + [&command]( std::string const & requireCommand ) { return requireCommand == command; } ) ); requireDataIt->commands.erase( requireCommandIt ); assert( !requireDataIt->commands.empty() || !requireDataIt->types.empty() ); removed = true; @@ -11879,7 +11858,8 @@ bool VulkanHppGenerator::handleRemovalCommand( std::string const & command, std: #if !defined( NDEBUG ) for ( auto it = std::next( requireDataIt ); it != requireData.end(); ++it ) { - assert( std::find( it->commands.begin(), it->commands.end(), command ) == it->commands.end() ); + assert( + std::none_of( it->commands.begin(), it->commands.end(), [&command]( std::string const & requireCommand ) { return requireCommand == command; } ) ); } #endif } @@ -11906,7 +11886,8 @@ bool VulkanHppGenerator::handleRemovalType( std::string const & type, std::vecto auto requireTypeIt = std::find( requireDataIt->types.begin(), requireDataIt->types.end(), type ); if ( requireTypeIt != requireDataIt->types.end() ) { - assert( std::find( std::next( requireTypeIt ), requireDataIt->types.end(), type ) == requireDataIt->types.end() ); + assert( + std::none_of( std::next( requireTypeIt ), requireDataIt->types.end(), [&type]( std::string const & requireType ) { return requireType == type; } ) ); requireDataIt->types.erase( requireTypeIt ); requireDataIt = ( requireDataIt->commands.empty() && requireDataIt->types.empty() ) ? requireData.erase( requireDataIt ) : std::next( requireDataIt ); removed = true; @@ -11914,7 +11895,7 @@ bool VulkanHppGenerator::handleRemovalType( std::string const & type, std::vecto #if !defined( NDEBUG ) for ( auto it = std::next( requireDataIt ); it != requireData.end(); ++it ) { - assert( std::find( it->types.begin(), it->types.end(), type ) == it->types.end() ); + assert( std::none_of( it->types.begin(), it->types.end(), [&type]( std::string const & requireType ) { return requireType == type; } ) ); } #endif } @@ -12101,12 +12082,12 @@ bool VulkanHppGenerator::isSupported( std::set const & requiredBy ) bool VulkanHppGenerator::isSupportedExtension( std::string const & name ) const { - return std::find_if( m_extensions.begin(), m_extensions.end(), [&name]( ExtensionData const & ed ) { return ed.name == name; } ) != m_extensions.end(); + return std::any_of( m_extensions.begin(), m_extensions.end(), [&name]( ExtensionData const & ed ) { return ed.name == name; } ); } bool VulkanHppGenerator::isSupportedFeature( std::string const & name ) const { - return std::find_if( m_features.begin(), m_features.end(), [&name]( FeatureData const & fd ) { return fd.name == name; } ) != m_features.end(); + return std::any_of( m_features.begin(), m_features.end(), [&name]( FeatureData const & fd ) { return fd.name == name; } ); } bool VulkanHppGenerator::isTypeRequired( std::string const & type ) const @@ -12127,7 +12108,7 @@ bool VulkanHppGenerator::isTypeUsed( std::string const & type ) const { for ( auto const & r : featureIt->requireData ) { - if ( std::find( r.types.begin(), r.types.end(), type ) != r.types.end() ) + if ( std::any_of( r.types.begin(), r.types.end(), [&type]( std::string const & requireType ) { return requireType == type; } ) ) { return true; } @@ -12140,7 +12121,7 @@ bool VulkanHppGenerator::isTypeUsed( std::string const & type ) const { for ( auto const & r : extensionIt->requireData ) { - if ( std::find( r.types.begin(), r.types.end(), type ) != r.types.end() ) + if ( std::any_of( r.types.begin(), r.types.end(), [&type]( std::string const & requireType ) { return requireType == type; } ) ) { return true; } @@ -12159,8 +12140,7 @@ bool VulkanHppGenerator::needsStructureChainResize( std::map>> VulkanHppGenerator::needs std::map> countToVectorMap; for ( auto const & vpi : vectorParams ) { - if ( ( vpi.second.lenParam != INVALID_INDEX ) && ( std::find( returnParams.begin(), returnParams.end(), vpi.first ) == returnParams.end() ) && + if ( ( vpi.second.lenParam != INVALID_INDEX ) && + std::none_of( returnParams.begin(), returnParams.end(), [&vpi]( size_t rp ) { return rp == vpi.first; } ) && ( ( singularParams.find( vpi.second.lenParam ) == singularParams.end() ) || isLenByStructMember( params[vpi.first].lenExpression, params[vpi.second.lenParam] ) ) ) { countToVectorMap[vpi.second.lenParam].push_back( vpi.first ); } } - return std::make_pair( std::find_if( countToVectorMap.begin(), - countToVectorMap.end(), - [this, ¶ms, &skippedParams]( auto const & cvm ) - { - return ( 1 < cvm.second.size() ) || isLenByStructMember( params[cvm.second[0]].lenExpression, params[cvm.first] ) || - ( std::find_if( params[cvm.second[0]].lenParams.begin(), - params[cvm.second[0]].lenParams.end(), - [&skippedParams]( std::pair const & lenParam ) { - return skippedParams.find( lenParam.second ) != skippedParams.end(); - } ) == params[cvm.second[0]].lenParams.end() ); - } ) != countToVectorMap.end(), + return std::make_pair( std::any_of( countToVectorMap.begin(), + countToVectorMap.end(), + [this, ¶ms, &skippedParams]( auto const & cvm ) + { + return ( 1 < cvm.second.size() ) || isLenByStructMember( params[cvm.second[0]].lenExpression, params[cvm.first] ) || + std::none_of( params[cvm.second[0]].lenParams.begin(), + params[cvm.second[0]].lenParams.end(), + [&skippedParams]( std::pair const & lenParam ) + { return skippedParams.find( lenParam.second ) != skippedParams.end(); } ); + } ), countToVectorMap ); } @@ -12389,7 +12369,7 @@ std::pair VulkanHppGenerator::readCommandPa if ( api.empty() || ( api == m_api ) ) { - checkForError( std::find_if( params.begin(), params.end(), [&name = nameData.name]( ParamData const & pd ) { return pd.name == name; } ) == params.end(), + checkForError( std::none_of( params.begin(), params.end(), [&name = nameData.name]( ParamData const & pd ) { return pd.name == name; } ), line, "command param <" + nameData.name + "> already used" ); } @@ -12633,10 +12613,12 @@ void VulkanHppGenerator::readExtensionRequire( tinyxml2::XMLElement const * elem requireData.depends = tokenizeAny( attribute.second, ",+" ); for ( auto const & d : requireData.depends ) { - checkForError( std::find_if( extensionData.requireData.begin(), + checkForError( std::none_of( extensionData.requireData.begin(), extensionData.requireData.end(), - [&d]( RequireData const & rd ) - { return std::find( rd.depends.begin(), rd.depends.end(), d ) != rd.depends.end(); } ) == extensionData.requireData.end(), + [&d]( RequireData const & rd ) { + return std::any_of( + rd.depends.begin(), rd.depends.end(), [&d]( std::string const & requireDepends ) { return requireDepends == d; } ); + } ), line, "required extension <" + d + "> already listed" ); } @@ -12806,18 +12788,18 @@ void VulkanHppGenerator::readExtension( tinyxml2::XMLElement const * element ) } } - checkForWarning( ( std::find( supported.begin(), supported.end(), "disabled" ) != supported.end() ) || extensionData.isDeprecated || ratified.empty() || - ( supported == ratified ), + checkForWarning( std::any_of( supported.begin(), supported.end(), []( std::string const & s ) { return s == "disabled"; } ) || extensionData.isDeprecated || + ratified.empty() || ( supported == ratified ), line, "attribute \"ratified\" differs from attribute \"supported\"" ); - bool extensionSupported = supported.empty() || ( std::find( supported.begin(), supported.end(), m_api ) != supported.end() ); + bool extensionSupported = supported.empty() || std::any_of( supported.begin(), supported.end(), [this]( std::string const & s ) { return s == m_api; } ); checkForError( !extensionSupported || !extensionData.type.empty(), line, "missing attribute \"type\" for supported extension <" + extensionData.name + ">" ); for ( auto child : children ) { readExtensionRequire( child, extensionData, extensionSupported ); } - if ( std::find( supported.begin(), supported.end(), "disabled" ) == supported.end() ) + if ( std::none_of( supported.begin(), supported.end(), []( std::string const & s ) { return s == "disabled"; } ) ) { // extract the tag from the name, which is supposed to look like VK__ size_t tagStart = extensionData.name.find( '_' ); @@ -12868,7 +12850,7 @@ void VulkanHppGenerator::readFeature( tinyxml2::XMLElement const * element ) } } - bool featureSupported = std::find( api.begin(), api.end(), m_api ) != api.end(); + bool featureSupported = std::any_of( api.begin(), api.end(), [this]( std::string const & a ) { return a == m_api; } ); for ( auto child : children ) { std::string value = child->Value(); @@ -12882,7 +12864,9 @@ void VulkanHppGenerator::readFeature( tinyxml2::XMLElement const * element ) } } - checkForError( featureData.name == ( ( std::find( api.begin(), api.end(), "vulkan" ) != api.end() ) ? "VK_VERSION_" : "VKSC_VERSION_" ) + modifiedNumber, + checkForError( featureData.name == + ( std::any_of( api.begin(), api.end(), []( std::string const & a ) { return a == "vulkan"; } ) ? "VK_VERSION_" : "VKSC_VERSION_" ) + + modifiedNumber, line, "unexpected formatting of name <" + featureData.name + ">" ); checkForError( !isFeature( featureData.name ), line, "feature <" + featureData.name + "> already specified" ); @@ -13054,9 +13038,9 @@ void VulkanHppGenerator::readFormat( tinyxml2::XMLElement const * element ) } else { - checkForError( std::find_if( formatIt->second.unsupportedValues.begin(), - formatIt->second.unsupportedValues.end(), - [&name]( EnumValueData const & evd ) { return evd.name == name; } ) != formatIt->second.unsupportedValues.end(), + checkForError( std::any_of( formatIt->second.unsupportedValues.begin(), + formatIt->second.unsupportedValues.end(), + [&name]( EnumValueData const & evd ) { return evd.name == name; } ), line, "unknown format <" + name + ">" ); } @@ -13118,9 +13102,9 @@ void VulkanHppGenerator::readFormatPlane( tinyxml2::XMLElement const * element, plane.compatible = attribute.second; auto formatIt = m_enums.find( "VkFormat" ); assert( formatIt != m_enums.end() ); - checkForError( std::find_if( formatIt->second.values.begin(), - formatIt->second.values.end(), - [&plane]( EnumValueData const & evd ) { return evd.name == plane.compatible; } ) != formatIt->second.values.end(), + checkForError( std::any_of( formatIt->second.values.begin(), + formatIt->second.values.end(), + [&plane]( EnumValueData const & evd ) { return evd.name == plane.compatible; } ), line, "encountered unknown format <" + plane.compatible + ">" ); } @@ -13236,9 +13220,9 @@ void VulkanHppGenerator::readPlatform( tinyxml2::XMLElement const * element ) } } - checkForError( std::find_if( m_platforms.begin(), + checkForError( std::none_of( m_platforms.begin(), m_platforms.end(), - [&protect]( std::pair const & p ) { return p.second.protect == protect; } ) == m_platforms.end(), + [&protect]( std::pair const & p ) { return p.second.protect == protect; } ), line, "protect <" + protect + "> of platform <" + name + "> is already used with some other platform" ); checkForError( m_platforms.insert( { name, { protect, line } } ).second, line, "platform <" + name + "> is already specified" ); @@ -13586,11 +13570,10 @@ void VulkanHppGenerator::readSPIRVCapabilityEnable( tinyxml2::XMLElement const * checkForError( enumIt != m_enums.end(), line, "member <" + member + "> specified for SPIR-V capability requires an unknown enum <" + bitmaskIt->second.require + ">" ); checkForError( - ( std::find_if( enumIt->second.values.begin(), enumIt->second.values.end(), [&value]( EnumValueData const & evd ) { return evd.name == value; } ) != - enumIt->second.values.end() ) || - ( std::find_if( enumIt->second.unsupportedValues.begin(), - enumIt->second.unsupportedValues.end(), - [&value]( EnumValueData const & evd ) { return evd.name == value; } ) != enumIt->second.unsupportedValues.end() ), + std::any_of( enumIt->second.values.begin(), enumIt->second.values.end(), [&value]( EnumValueData const & evd ) { return evd.name == value; } ) || + std::any_of( enumIt->second.unsupportedValues.begin(), + enumIt->second.unsupportedValues.end(), + [&value]( EnumValueData const & evd ) { return evd.name == value; } ), line, "unknown attribute value <" + value + "> specified for SPIR-V capability" ); } @@ -13837,7 +13820,7 @@ void VulkanHppGenerator::readStructMember( tinyxml2::XMLElement const * element, if ( api.empty() || ( api == m_api ) ) { - checkForError( std::find_if( members.begin(), members.end(), [&name]( MemberData const & md ) { return md.name == name; } ) == members.end(), + checkForError( std::none_of( members.begin(), members.end(), [&name]( MemberData const & md ) { return md.name == name; } ), line, "struct member name <" + name + "> already used" ); memberData.name = name; @@ -13980,11 +13963,10 @@ void VulkanHppGenerator::readSyncPipeline( tinyxml2::XMLElement const * element std::vector depends = tokenize( attribute.second, "," ); for ( auto const & d : depends ) { - checkForError( - ( std::find_if( m_extensions.begin(), m_extensions.end(), [&d]( ExtensionData const & ed ) { return ed.name == d; } ) != m_extensions.end() ) || - ( m_unsupportedExtensions.find( d ) != m_unsupportedExtensions.end() ), - line, - "syncpipeline depends on unknown extension <" + d + ">" ); + checkForError( std::any_of( m_extensions.begin(), m_extensions.end(), [&d]( ExtensionData const & ed ) { return ed.name == d; } ) || + ( m_unsupportedExtensions.find( d ) != m_unsupportedExtensions.end() ), + line, + "syncpipeline depends on unknown extension <" + d + ">" ); } } } @@ -14385,9 +14367,9 @@ void VulkanHppGenerator::readTypeFuncpointer( tinyxml2::XMLElement const * eleme argumentName = argumentName.substr( argumentName.find_first_not_of( "* " ) ); argumentName = argumentName.substr( 0, argumentName.find_first_of( ",)" ) ); - checkForError( std::find_if( arguments.begin(), + checkForError( std::none_of( arguments.begin(), arguments.end(), - [&argumentName]( FuncPointerArgumentData const & argument ) { return argument.name == argumentName; } ) == arguments.end(), + [&argumentName]( FuncPointerArgumentData const & argument ) { return argument.name == argumentName; } ), line, "argument <" + argumentName + "> already listed in funcpointer <" + name + ">" ); arguments.push_back( { argumentName, type, argumentLine } ); diff --git a/samples/EnableValidationWithCallback/EnableValidationWithCallback.cpp b/samples/EnableValidationWithCallback/EnableValidationWithCallback.cpp index ed11a42..74af148 100644 --- a/samples/EnableValidationWithCallback/EnableValidationWithCallback.cpp +++ b/samples/EnableValidationWithCallback/EnableValidationWithCallback.cpp @@ -109,10 +109,9 @@ bool checkLayers( std::vector const & layers, std::vector cubeData = { @@ -705,10 +708,9 @@ int main( int /*argc*/, char ** /*argv*/ ) for ( auto pd : physicalDevices ) { std::vector ep = pd.enumerateDeviceExtensionProperties(); - if ( std::find_if( ep.cbegin(), - ep.cend(), - []( vk::ExtensionProperties const & prop ) - { return strcmp( prop.extensionName, VK_NV_RAY_TRACING_EXTENSION_NAME ) == 0; } ) != ep.cend() ) + if ( std::any_of( ep.cbegin(), + ep.cend(), + []( vk::ExtensionProperties const & prop ) { return strcmp( prop.extensionName, VK_NV_RAY_TRACING_EXTENSION_NAME ) == 0; } ) ) { physicalDevice = pd; break; @@ -731,11 +733,11 @@ int main( int /*argc*/, char ** /*argv*/ ) auto supportedFeatures = physicalDevice.getFeatures2(); vk::Device device = vk::su::createDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, - { VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, - VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, - VK_KHR_MAINTENANCE_3_EXTENSION_NAME, - VK_KHR_SWAPCHAIN_EXTENSION_NAME, - VK_NV_RAY_TRACING_EXTENSION_NAME }, + { VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, + VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, + VK_KHR_MAINTENANCE_3_EXTENSION_NAME, + VK_KHR_SWAPCHAIN_EXTENSION_NAME, + VK_NV_RAY_TRACING_EXTENSION_NAME }, &supportedFeatures.get().features, &supportedFeatures.get() ); diff --git a/samples/utils/utils.cpp b/samples/utils/utils.cpp index 425513d..78966a3 100644 --- a/samples/utils/utils.cpp +++ b/samples/utils/utils.cpp @@ -238,17 +238,16 @@ namespace vk enabledExtensions.reserve( extensions.size() ); for ( auto const & ext : extensions ) { - assert( std::find_if( extensionProperties.begin(), - extensionProperties.end(), - [ext]( vk::ExtensionProperties const & ep ) { return ext == ep.extensionName; } ) != extensionProperties.end() ); + assert( std::any_of( + extensionProperties.begin(), extensionProperties.end(), [ext]( vk::ExtensionProperties const & ep ) { return ext == ep.extensionName; } ) ); enabledExtensions.push_back( ext.data() ); } #if !defined( NDEBUG ) - if ( std::find( extensions.begin(), extensions.end(), VK_EXT_DEBUG_UTILS_EXTENSION_NAME ) == extensions.end() && - std::find_if( extensionProperties.begin(), - extensionProperties.end(), - []( vk::ExtensionProperties const & ep ) - { return ( strcmp( VK_EXT_DEBUG_UTILS_EXTENSION_NAME, ep.extensionName ) == 0 ); } ) != extensionProperties.end() ) + if ( std::none_of( + extensions.begin(), extensions.end(), []( std::string const & extension ) { return extension == VK_EXT_DEBUG_UTILS_EXTENSION_NAME; } ) && + std::any_of( extensionProperties.begin(), + extensionProperties.end(), + []( vk::ExtensionProperties const & ep ) { return ( strcmp( VK_EXT_DEBUG_UTILS_EXTENSION_NAME, ep.extensionName ) == 0 ); } ) ) { enabledExtensions.push_back( VK_EXT_DEBUG_UTILS_EXTENSION_NAME ); } @@ -267,17 +266,15 @@ namespace vk enabledLayers.reserve( layers.size() ); for ( auto const & layer : layers ) { - assert( std::find_if( layerProperties.begin(), layerProperties.end(), [layer]( vk::LayerProperties const & lp ) { return layer == lp.layerName; } ) != - layerProperties.end() ); + assert( std::any_of( layerProperties.begin(), layerProperties.end(), [layer]( vk::LayerProperties const & lp ) { return layer == lp.layerName; } ) ); enabledLayers.push_back( layer.data() ); } #if !defined( NDEBUG ) // Enable standard validation layer to find as much errors as possible! - if ( std::find( layers.begin(), layers.end(), "VK_LAYER_KHRONOS_validation" ) == layers.end() && - std::find_if( layerProperties.begin(), - layerProperties.end(), - []( vk::LayerProperties const & lp ) - { return ( strcmp( "VK_LAYER_KHRONOS_validation", lp.layerName ) == 0 ); } ) != layerProperties.end() ) + if ( std::none_of( layers.begin(), layers.end(), []( std::string const & layer ) { return layer == "VK_LAYER_KHRONOS_validation"; } ) && + std::any_of( layerProperties.begin(), + layerProperties.end(), + []( vk::LayerProperties const & lp ) { return ( strcmp( "VK_LAYER_KHRONOS_validation", lp.layerName ) == 0 ); } ) ) { enabledLayers.push_back( "VK_LAYER_KHRONOS_validation" ); } @@ -352,9 +349,9 @@ namespace vk vk::AttachmentReference depthAttachment( 1, vk::ImageLayout::eDepthStencilAttachmentOptimal ); vk::SubpassDescription subpassDescription( vk::SubpassDescriptionFlags(), vk::PipelineBindPoint::eGraphics, - {}, + {}, colorAttachment, - {}, + {}, ( depthFormat != vk::Format::eUndefined ) ? &depthAttachment : nullptr ); return device.createRenderPass( vk::RenderPassCreateInfo( vk::RenderPassCreateFlags(), attachmentDescriptions, subpassDescription ) ); } diff --git a/vulkan/vulkan.cppm b/vulkan/vulkan.cppm index ae6a62b..ec65d45 100644 --- a/vulkan/vulkan.cppm +++ b/vulkan/vulkan.cppm @@ -2910,7 +2910,7 @@ export namespace VULKAN_HPP_NAMESPACE using VULKAN_HPP_RAII_NAMESPACE::BufferCollectionFUCHSIA; #endif /*VK_USE_PLATFORM_FUCHSIA*/ - //=== VK_EXT_opacity_micromap === + //=== VK_EXT_opacity_micromap === using VULKAN_HPP_RAII_NAMESPACE::MicromapEXT; //=== VK_NV_optical_flow === diff --git a/vulkan/vulkansc.cppm b/vulkan/vulkansc.cppm index d58c64d..27fd58c 100644 --- a/vulkan/vulkansc.cppm +++ b/vulkan/vulkansc.cppm @@ -1345,9 +1345,9 @@ export namespace VULKAN_HPP_NAMESPACE using VULKAN_HPP_NAMESPACE::StructExtends; #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ -#if defined( VULKAN_HPP_DYNAMIC_LOADER_TOOL ) +#if defined( VULKAN_HPP_ENABLE_DYNAMIC_LOADER_TOOL ) using VULKAN_HPP_NAMESPACE::DynamicLoader; -#endif /*VULKAN_HPP_DYNAMIC_LOADER_TOOL*/ +#endif /*VULKAN_HPP_ENABLE_DYNAMIC_LOADER_TOOL*/ using VULKAN_HPP_NAMESPACE::DispatchLoaderDynamic; @@ -1390,7 +1390,7 @@ export namespace VULKAN_HPP_NAMESPACE using VULKAN_HPP_NAMESPACE::isObsoletedExtension; using VULKAN_HPP_NAMESPACE::isPromotedExtension; - export namespace VULKAN_HPP_RAII_NAMESPACE + namespace VULKAN_HPP_RAII_NAMESPACE { //====================== //=== RAII HARDCODED === diff --git a/vulkan/vulkansc.hpp b/vulkan/vulkansc.hpp index bd686e7..719cc57 100644 --- a/vulkan/vulkansc.hpp +++ b/vulkan/vulkansc.hpp @@ -212,6 +212,14 @@ constexpr int False = 0; # define VULKAN_HPP_CONST_OR_CONSTEXPR const #endif +#if !defined( VULKAN_HPP_CONSTEXPR_INLINE ) +# if 201606L <= __cpp_inline_variables +# define VULKAN_HPP_CONSTEXPR_INLINE VULKAN_HPP_CONSTEXPR inline +# else +# define VULKAN_HPP_CONSTEXPR_INLINE VULKAN_HPP_CONSTEXPR +# endif +#endif + #if !defined( VULKAN_HPP_NOEXCEPT ) # if defined( _MSC_VER ) && ( _MSC_VER <= 1800 ) # define VULKAN_HPP_NOEXCEPT @@ -4320,32 +4328,32 @@ namespace VULKAN_HPP_NAMESPACE //========================================= //=== CONSTEXPR CONSTANTs AND FUNCTIONs === //========================================= - VULKAN_HPP_CONSTEXPR uint32_t AttachmentUnused = VK_ATTACHMENT_UNUSED; - VULKAN_HPP_CONSTEXPR uint32_t False = VK_FALSE; - VULKAN_HPP_CONSTEXPR float LodClampNone = VK_LOD_CLAMP_NONE; - VULKAN_HPP_CONSTEXPR uint32_t LuidSize = VK_LUID_SIZE; - VULKAN_HPP_CONSTEXPR uint32_t MaxDescriptionSize = VK_MAX_DESCRIPTION_SIZE; - VULKAN_HPP_CONSTEXPR uint32_t MaxDeviceGroupSize = VK_MAX_DEVICE_GROUP_SIZE; - VULKAN_HPP_CONSTEXPR uint32_t MaxDriverInfoSize = VK_MAX_DRIVER_INFO_SIZE; - VULKAN_HPP_CONSTEXPR uint32_t MaxDriverNameSize = VK_MAX_DRIVER_NAME_SIZE; - VULKAN_HPP_CONSTEXPR uint32_t MaxExtensionNameSize = VK_MAX_EXTENSION_NAME_SIZE; - VULKAN_HPP_CONSTEXPR uint32_t MaxGlobalPrioritySizeKhr = VK_MAX_GLOBAL_PRIORITY_SIZE_KHR; - VULKAN_HPP_CONSTEXPR uint32_t MaxMemoryHeaps = VK_MAX_MEMORY_HEAPS; - VULKAN_HPP_CONSTEXPR uint32_t MaxMemoryTypes = VK_MAX_MEMORY_TYPES; - VULKAN_HPP_CONSTEXPR uint32_t MaxPhysicalDeviceNameSize = VK_MAX_PHYSICAL_DEVICE_NAME_SIZE; - VULKAN_HPP_CONSTEXPR uint32_t MaxShaderModuleIdentifierSizeExt = VK_MAX_SHADER_MODULE_IDENTIFIER_SIZE_EXT; - VULKAN_HPP_CONSTEXPR uint32_t QueueFamilyExternal = VK_QUEUE_FAMILY_EXTERNAL; - VULKAN_HPP_CONSTEXPR uint32_t QueueFamilyForeignExt = VK_QUEUE_FAMILY_FOREIGN_EXT; - VULKAN_HPP_CONSTEXPR uint32_t QueueFamilyIgnored = VK_QUEUE_FAMILY_IGNORED; - VULKAN_HPP_CONSTEXPR uint32_t Remaining3DSlicesExt = VK_REMAINING_3D_SLICES_EXT; - VULKAN_HPP_CONSTEXPR uint32_t RemainingArrayLayers = VK_REMAINING_ARRAY_LAYERS; - VULKAN_HPP_CONSTEXPR uint32_t RemainingMipLevels = VK_REMAINING_MIP_LEVELS; - VULKAN_HPP_CONSTEXPR uint32_t ShaderUnusedKhr = VK_SHADER_UNUSED_KHR; - VULKAN_HPP_CONSTEXPR uint32_t SubpassExternal = VK_SUBPASS_EXTERNAL; - VULKAN_HPP_CONSTEXPR uint32_t True = VK_TRUE; - VULKAN_HPP_CONSTEXPR uint32_t UuidSize = VK_UUID_SIZE; - VULKAN_HPP_CONSTEXPR uint64_t WholeSize = VK_WHOLE_SIZE; - VULKAN_HPP_CONSTEXPR uint32_t HeaderVersion = VK_HEADER_VERSION; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t AttachmentUnused = VK_ATTACHMENT_UNUSED; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t False = VK_FALSE; + VULKAN_HPP_CONSTEXPR_INLINE float LodClampNone = VK_LOD_CLAMP_NONE; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t LuidSize = VK_LUID_SIZE; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t MaxDescriptionSize = VK_MAX_DESCRIPTION_SIZE; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t MaxDeviceGroupSize = VK_MAX_DEVICE_GROUP_SIZE; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t MaxDriverInfoSize = VK_MAX_DRIVER_INFO_SIZE; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t MaxDriverNameSize = VK_MAX_DRIVER_NAME_SIZE; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t MaxExtensionNameSize = VK_MAX_EXTENSION_NAME_SIZE; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t MaxGlobalPrioritySizeKhr = VK_MAX_GLOBAL_PRIORITY_SIZE_KHR; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t MaxMemoryHeaps = VK_MAX_MEMORY_HEAPS; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t MaxMemoryTypes = VK_MAX_MEMORY_TYPES; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t MaxPhysicalDeviceNameSize = VK_MAX_PHYSICAL_DEVICE_NAME_SIZE; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t MaxShaderModuleIdentifierSizeExt = VK_MAX_SHADER_MODULE_IDENTIFIER_SIZE_EXT; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t QueueFamilyExternal = VK_QUEUE_FAMILY_EXTERNAL; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t QueueFamilyForeignExt = VK_QUEUE_FAMILY_FOREIGN_EXT; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t QueueFamilyIgnored = VK_QUEUE_FAMILY_IGNORED; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t Remaining3DSlicesExt = VK_REMAINING_3D_SLICES_EXT; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t RemainingArrayLayers = VK_REMAINING_ARRAY_LAYERS; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t RemainingMipLevels = VK_REMAINING_MIP_LEVELS; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t ShaderUnusedKhr = VK_SHADER_UNUSED_KHR; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t SubpassExternal = VK_SUBPASS_EXTERNAL; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t True = VK_TRUE; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t UuidSize = VK_UUID_SIZE; + VULKAN_HPP_CONSTEXPR_INLINE uint64_t WholeSize = VK_WHOLE_SIZE; + VULKAN_HPP_CONSTEXPR_INLINE uint32_t HeaderVersion = VK_HEADER_VERSION; template ::value>::type> VULKAN_HPP_CONSTEXPR uint32_t apiVersionMajor( T const version ) @@ -4405,12 +4413,12 @@ namespace VULKAN_HPP_NAMESPACE return ( (uint32_t)(version)&0xFFFU ); } - VULKAN_HPP_CONSTEXPR auto ApiVersion = makeApiVersion( 0, 1, 0, 0 ); - VULKAN_HPP_CONSTEXPR auto ApiVersion10 = makeApiVersion( 0, 1, 0, 0 ); - VULKAN_HPP_CONSTEXPR auto ApiVersion11 = makeApiVersion( 0, 1, 1, 0 ); - VULKAN_HPP_CONSTEXPR auto ApiVersion12 = makeApiVersion( 0, 1, 2, 0 ); - VULKAN_HPP_CONSTEXPR auto ApiVersion13 = makeApiVersion( 0, 1, 3, 0 ); - VULKAN_HPP_CONSTEXPR auto HeaderVersionComplete = makeApiVersion( VKSC_API_VARIANT, 1, 0, VK_HEADER_VERSION ); + VULKAN_HPP_CONSTEXPR_INLINE auto ApiVersion = makeApiVersion( 0, 1, 0, 0 ); + VULKAN_HPP_CONSTEXPR_INLINE auto ApiVersion10 = makeApiVersion( 0, 1, 0, 0 ); + VULKAN_HPP_CONSTEXPR_INLINE auto ApiVersion11 = makeApiVersion( 0, 1, 1, 0 ); + VULKAN_HPP_CONSTEXPR_INLINE auto ApiVersion12 = makeApiVersion( 0, 1, 2, 0 ); + VULKAN_HPP_CONSTEXPR_INLINE auto ApiVersion13 = makeApiVersion( 0, 1, 3, 0 ); + VULKAN_HPP_CONSTEXPR_INLINE auto HeaderVersionComplete = makeApiVersion( VKSC_API_VARIANT, 1, 0, VK_HEADER_VERSION ); } // namespace VULKAN_HPP_NAMESPACE @@ -7020,7 +7028,7 @@ namespace VULKAN_HPP_NAMESPACE # elif defined( __APPLE__ ) m_library = dlopen( "libvulkan.dylib", RTLD_NOW | RTLD_LOCAL ); # elif defined( _WIN32 ) - m_library = ::LoadLibraryA( "vulkan-1.dll" ); + m_library = ::LoadLibraryA( "vulkan-1.dll" ); # else # error unsupported platform # endif