Fix function StructureChain::unlink().

This commit is contained in:
asuessenbach
2021-01-21 16:56:14 +01:00
parent a82ea0f9b0
commit 8a21c2e0eb
3 changed files with 48 additions and 61 deletions

View File

@@ -1066,15 +1066,14 @@ namespace VULKAN_HPP_NAMESPACE
}
template <typename ClassType, size_t Which = 0>
void relink() VULKAN_HPP_NOEXCEPT
typename std::enable_if<
!std::is_same<ClassType, typename std::tuple_element<0, std::tuple<ChainElements...>>::type>::value ||
( Which != 0 ),
void>::type
relink() VULKAN_HPP_NOEXCEPT
{
static_assert( IsPartOfStructureChain<ClassType, ChainElements...>::valid,
"Can't relink Structure that's not part of this StructureChain!" );
static_assert(
!std::is_same<ClassType, typename std::tuple_element<0, std::tuple<ChainElements...>>::type>::value ||
( Which != 0 ),
"It's not allowed to have the first element unlinked!" );
auto pNext = reinterpret_cast<VkBaseInStructure *>( &get<ClassType, Which>() );
VULKAN_HPP_ASSERT( !isLinked( pNext ) );
auto & headElement = std::get<0>( static_cast<std::tuple<ChainElements...> &>( *this ) );
@@ -1083,17 +1082,15 @@ namespace VULKAN_HPP_NAMESPACE
}
template <typename ClassType, size_t Which = 0>
void unlink() VULKAN_HPP_NOEXCEPT
typename std::enable_if<
!std::is_same<ClassType, typename std::tuple_element<0, std::tuple<ChainElements...>>::type>::value ||
( Which != 0 ),
void>::type
unlink() VULKAN_HPP_NOEXCEPT
{
static_assert( IsPartOfStructureChain<ClassType, ChainElements...>::valid,
"Can't unlink Structure that's not part of this StructureChain!" );
static_assert(
!std::is_same<ClassType, typename std::tuple_element<0, std::tuple<ChainElements...>>::type>::value ||
( Which != 0 ),
"It's not allowed to unlink the first element!" );
unlink<sizeof...( ChainElements ) - 1>(
reinterpret_cast<VkBaseOutStructure const *>( &get<ClassType, Which>() ) );
unlink( reinterpret_cast<VkBaseOutStructure const *>( &get<ClassType, Which>() ) );
}
private:
@@ -1155,27 +1152,17 @@ namespace VULKAN_HPP_NAMESPACE
typename std::enable_if<Index == 0, void>::type link() VULKAN_HPP_NOEXCEPT
{}
template <size_t Index>
typename std::enable_if<Index != 0, void>::type unlink( VkBaseOutStructure const * pNext ) VULKAN_HPP_NOEXCEPT
void unlink( VkBaseOutStructure const * pNext ) VULKAN_HPP_NOEXCEPT
{
auto & element = std::get<Index>( static_cast<std::tuple<ChainElements...> &>( *this ) );
if ( element.pNext == pNext )
VkBaseOutStructure * elementPtr =
reinterpret_cast<VkBaseOutStructure *>( &std::get<0>( static_cast<std::tuple<ChainElements...> &>( *this ) ) );
while ( elementPtr && ( elementPtr->pNext != pNext ) )
{
element.pNext = pNext->pNext;
elementPtr = elementPtr->pNext;
}
else
if ( elementPtr )
{
unlink<Index - 1>( pNext );
}
}
template <size_t Index>
typename std::enable_if<Index == 0, void>::type unlink( VkBaseOutStructure const * pNext ) VULKAN_HPP_NOEXCEPT
{
auto & element = std::get<0>( static_cast<std::tuple<ChainElements...> &>( *this ) );
if ( element.pNext == pNext )
{
element.pNext = pNext->pNext;
elementPtr->pNext = pNext->pNext;
}
else
{