From d566d2200ccbac46890759715f3295d4f531ee07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20S=C3=BC=C3=9Fenbach?= Date: Thu, 16 May 2019 08:07:36 +0200 Subject: [PATCH] Add helper function to copy a vector of UniqueHandles into a vector of UniqueHandle::element_type. (#327) --- VulkanHppGenerator.cpp | 10 +++++++++- vulkan/vulkan.hpp | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 64247df..d4f66b1 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -4604,8 +4604,8 @@ int main( int argc, char **argv ) { private: using Deleter = typename UniqueHandleTraits::deleter; - public: + public: using element_type = Type; explicit UniqueHandle( Type const& value = Type(), Deleter const& deleter = Deleter() ) @@ -4695,6 +4695,14 @@ int main( int argc, char **argv ) Type m_value; }; + template + VULKAN_HPP_INLINE std::vector uniqueToRaw(std::vector const& handles) + { + std::vector newBuffer(handles.size()); + std::transform(handles.begin(), handles.end(), newBuffer.begin(), [](UniqueType const& handle) { return handle.get(); }); + return newBuffer; + } + template VULKAN_HPP_INLINE void swap( UniqueHandle & lhs, UniqueHandle & rhs ) { diff --git a/vulkan/vulkan.hpp b/vulkan/vulkan.hpp index a3a4823..ec59e0a 100644 --- a/vulkan/vulkan.hpp +++ b/vulkan/vulkan.hpp @@ -508,8 +508,8 @@ namespace VULKAN_HPP_NAMESPACE { private: using Deleter = typename UniqueHandleTraits::deleter; - public: + public: using element_type = Type; explicit UniqueHandle( Type const& value = Type(), Deleter const& deleter = Deleter() ) @@ -599,6 +599,14 @@ namespace VULKAN_HPP_NAMESPACE Type m_value; }; + template + VULKAN_HPP_INLINE std::vector uniqueToRaw(std::vector const& handles) + { + std::vector newBuffer(handles.size()); + std::transform(handles.begin(), handles.end(), newBuffer.begin(), [](UniqueType const& handle) { return handle.get(); }); + return newBuffer; + } + template VULKAN_HPP_INLINE void swap( UniqueHandle & lhs, UniqueHandle & rhs ) {