diff --git a/snippets/StructureChain.hpp b/snippets/StructureChain.hpp index 5b5e467..8aa535f 100644 --- a/snippets/StructureChain.hpp +++ b/snippets/StructureChain.hpp @@ -22,26 +22,23 @@ template struct StructureChainContains { - static const bool value = - std::is_same>::type>::value || - StructureChainContains::value; + static const bool value = std::is_same>::type>::value || + StructureChainContains::value; }; template struct StructureChainContains<0, T, ChainElements...> { - static const bool value = - std::is_same>::type>::value; + static const bool value = std::is_same>::type>::value; }; template struct StructureChainValidation { - using TestType = typename std::tuple_element>::type; - static const bool valid = - StructExtends>::type>::value && - ( TestType::allowDuplicate || !StructureChainContains::value ) && - StructureChainValidation::valid; + using TestType = typename std::tuple_element>::type; + static const bool valid = StructExtends>::type>::value && + ( TestType::allowDuplicate || !StructureChainContains::value ) && + StructureChainValidation::valid; }; template @@ -56,26 +53,22 @@ public: StructureChain() VULKAN_HPP_NOEXCEPT { - static_assert( StructureChainValidation::valid, - "The structure chain is not valid!" ); + static_assert( StructureChainValidation::valid, "The structure chain is not valid!" ); link(); } StructureChain( StructureChain const & rhs ) VULKAN_HPP_NOEXCEPT : std::tuple( rhs ) { - static_assert( StructureChainValidation::valid, - "The structure chain is not valid!" ); + static_assert( StructureChainValidation::valid, "The structure chain is not valid!" ); link( &std::get<0>( *this ), &std::get<0>( rhs ), reinterpret_cast( &std::get<0>( *this ) ), reinterpret_cast( &std::get<0>( rhs ) ) ); } - StructureChain( StructureChain && rhs ) VULKAN_HPP_NOEXCEPT - : std::tuple( std::forward>( rhs ) ) + StructureChain( StructureChain && rhs ) VULKAN_HPP_NOEXCEPT : std::tuple( std::forward>( rhs ) ) { - static_assert( StructureChainValidation::valid, - "The structure chain is not valid!" ); + static_assert( StructureChainValidation::valid, "The structure chain is not valid!" ); link( &std::get<0>( *this ), &std::get<0>( rhs ), reinterpret_cast( &std::get<0>( *this ) ), @@ -84,8 +77,7 @@ StructureChain( ChainElements const &... elems ) VULKAN_HPP_NOEXCEPT : std::tuple( elems... ) { - static_assert( StructureChainValidation::valid, - "The structure chain is not valid!" ); + static_assert( StructureChainValidation::valid, "The structure chain is not valid!" ); link(); } @@ -104,15 +96,13 @@ template >::type, size_t Which = 0> T & get() VULKAN_HPP_NOEXCEPT { - return std::get::value>( - static_cast &>( *this ) ); + return std::get::value>( static_cast &>( *this ) ); } template >::type, size_t Which = 0> T const & get() const VULKAN_HPP_NOEXCEPT { - return std::get::value>( - static_cast const &>( *this ) ); + return std::get::value>( static_cast const &>( *this ) ); } template @@ -135,39 +125,29 @@ void * pNext = lhs.pNext; lhs = rhs; lhs.pNext = pNext; - return *this; + return *this; } template - typename std::enable_if< - std::is_same>::type>::value && - ( Which == 0 ), - bool>::type + typename std::enable_if>::type>::value && ( Which == 0 ), bool>::type isLinked() const VULKAN_HPP_NOEXCEPT { return true; } template - typename std::enable_if< - !std::is_same>::type>::value || - ( Which != 0 ), - bool>::type + typename std::enable_if>::type>::value || ( Which != 0 ), bool>::type isLinked() const VULKAN_HPP_NOEXCEPT { - static_assert( IsPartOfStructureChain::valid, - "Can't unlink Structure that's not part of this StructureChain!" ); + static_assert( IsPartOfStructureChain::valid, "Can't unlink Structure that's not part of this StructureChain!" ); return isLinked( reinterpret_cast( &get() ) ); } template - typename std::enable_if< - !std::is_same>::type>::value || - ( Which != 0 ), - void>::type relink() VULKAN_HPP_NOEXCEPT + typename std::enable_if>::type>::value || ( Which != 0 ), void>::type + relink() VULKAN_HPP_NOEXCEPT { - static_assert( IsPartOfStructureChain::valid, - "Can't relink Structure that's not part of this StructureChain!" ); + static_assert( IsPartOfStructureChain::valid, "Can't relink Structure that's not part of this StructureChain!" ); auto pNext = reinterpret_cast( &get() ); VULKAN_HPP_ASSERT( !isLinked( pNext ) ); auto & headElement = std::get<0>( static_cast &>( *this ) ); @@ -176,52 +156,41 @@ } template - typename std::enable_if< - !std::is_same>::type>::value || - ( Which != 0 ), - void>::type unlink() VULKAN_HPP_NOEXCEPT + typename std::enable_if>::type>::value || ( Which != 0 ), void>::type + unlink() VULKAN_HPP_NOEXCEPT { - static_assert( IsPartOfStructureChain::valid, - "Can't unlink Structure that's not part of this StructureChain!" ); + static_assert( IsPartOfStructureChain::valid, "Can't unlink Structure that's not part of this StructureChain!" ); unlink( reinterpret_cast( &get() ) ); } private: template struct ChainElementIndex : ChainElementIndex - {}; + { + }; template - struct ChainElementIndex::value, void>::type, - First, - Types...> : ChainElementIndex - {}; + struct ChainElementIndex::value, void>::type, First, Types...> + : ChainElementIndex + { + }; template - struct ChainElementIndex::value, void>::type, - First, - Types...> : ChainElementIndex - {}; + struct ChainElementIndex::value, void>::type, First, Types...> + : ChainElementIndex + { + }; template - struct ChainElementIndex::value, void>::type, - First, - Types...> : std::integral_constant - {}; + struct ChainElementIndex::value, void>::type, First, Types...> + : std::integral_constant + { + }; bool isLinked( VkBaseInStructure const * pNext ) const VULKAN_HPP_NOEXCEPT { - VkBaseInStructure const * elementPtr = reinterpret_cast( - &std::get<0>( static_cast const &>( *this ) ) ); + VkBaseInStructure const * elementPtr = + reinterpret_cast( &std::get<0>( static_cast const &>( *this ) ) ); while ( elementPtr ) { if ( elementPtr->pNext == pNext ) @@ -243,25 +212,24 @@ template typename std::enable_if::type link() VULKAN_HPP_NOEXCEPT - {} + { + } void link( void * dstBase, void const * srcBase, VkBaseOutStructure * dst, VkBaseInStructure const * src ) { while ( src->pNext ) { - std::ptrdiff_t offset = - reinterpret_cast( src->pNext ) - reinterpret_cast( srcBase ); - dst->pNext = reinterpret_cast( reinterpret_cast( dstBase ) + offset ); - dst = dst->pNext; - src = src->pNext; + std::ptrdiff_t offset = reinterpret_cast( src->pNext ) - reinterpret_cast( srcBase ); + dst->pNext = reinterpret_cast( reinterpret_cast( dstBase ) + offset ); + dst = dst->pNext; + src = src->pNext; } dst->pNext = nullptr; } void unlink( VkBaseOutStructure const * pNext ) VULKAN_HPP_NOEXCEPT { - VkBaseOutStructure * elementPtr = - reinterpret_cast( &std::get<0>( static_cast &>( *this ) ) ); + VkBaseOutStructure * elementPtr = reinterpret_cast( &std::get<0>( static_cast &>( *this ) ) ); while ( elementPtr && ( elementPtr->pNext != pNext ) ) { elementPtr = elementPtr->pNext; diff --git a/vulkan/vulkan.hpp b/vulkan/vulkan.hpp index b204b44..c6283c0 100644 --- a/vulkan/vulkan.hpp +++ b/vulkan/vulkan.hpp @@ -1053,6 +1053,17 @@ namespace VULKAN_HPP_NAMESPACE return std::tie( get(), get(), get()... ); } + // assign a complete structure to the StructureChain without modifying the chaining + template >::type, size_t Which = 0> + StructureChain & assign( const T & rhs ) VULKAN_HPP_NOEXCEPT + { + T & lhs = get(); + void * pNext = lhs.pNext; + lhs = rhs; + lhs.pNext = pNext; + return *this; + } + template typename std::enable_if>::type>::value && ( Which == 0 ), bool>::type isLinked() const VULKAN_HPP_NOEXCEPT