Add helper function to copy a vector of UniqueHandles into a vector of UniqueHandle::element_type. (#327)

This commit is contained in:
Andreas Süßenbach 2019-05-16 08:07:36 +02:00 committed by GitHub
parent ac10dafd73
commit d566d2200c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -4604,8 +4604,8 @@ int main( int argc, char **argv )
{
private:
using Deleter = typename UniqueHandleTraits<Type,Dispatch>::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 <typename UniqueType>
VULKAN_HPP_INLINE std::vector<typename UniqueType::element_type> uniqueToRaw(std::vector<UniqueType> const& handles)
{
std::vector<typename UniqueType::element_type> newBuffer(handles.size());
std::transform(handles.begin(), handles.end(), newBuffer.begin(), [](UniqueType const& handle) { return handle.get(); });
return newBuffer;
}
template <typename Type, typename Dispatch>
VULKAN_HPP_INLINE void swap( UniqueHandle<Type,Dispatch> & lhs, UniqueHandle<Type,Dispatch> & rhs )
{

View File

@ -508,8 +508,8 @@ namespace VULKAN_HPP_NAMESPACE
{
private:
using Deleter = typename UniqueHandleTraits<Type,Dispatch>::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 <typename UniqueType>
VULKAN_HPP_INLINE std::vector<typename UniqueType::element_type> uniqueToRaw(std::vector<UniqueType> const& handles)
{
std::vector<typename UniqueType::element_type> newBuffer(handles.size());
std::transform(handles.begin(), handles.end(), newBuffer.begin(), [](UniqueType const& handle) { return handle.get(); });
return newBuffer;
}
template <typename Type, typename Dispatch>
VULKAN_HPP_INLINE void swap( UniqueHandle<Type,Dispatch> & lhs, UniqueHandle<Type,Dispatch> & rhs )
{