mirror of
https://github.com/KhronosGroup/Vulkan-Hpp.git
synced 2025-09-09 11:58:06 -04:00
Introduce constructors of ArrayProxy and ArrayProxyNoTemporaries from std::span (C++20)
This commit is contained in:
parent
0957f3a3f1
commit
af80b7aee8
@ -15124,6 +15124,32 @@ int main( int argc, char ** argv )
|
||||
, m_ptr( data.data() )
|
||||
{}
|
||||
|
||||
#if defined( VULKAN_HPP_SUPPORT_SPAN )
|
||||
template <size_t N = std::dynamic_extent>
|
||||
ArrayProxy( std::span<T, N> const & data ) VULKAN_HPP_NOEXCEPT
|
||||
: m_count( static_cast<uint32_t>( data.size() ) )
|
||||
, m_ptr( data.data() )
|
||||
{}
|
||||
|
||||
template <size_t N = std::dynamic_extent, typename B = T, typename std::enable_if<std::is_const<B>::value, int>::type = 0>
|
||||
ArrayProxy( std::span<typename std::remove_const<T>::type, N> const & data ) VULKAN_HPP_NOEXCEPT
|
||||
: m_count( static_cast<uint32_t>( data.size() ) )
|
||||
, m_ptr( data.data() )
|
||||
{}
|
||||
|
||||
template <size_t N = std::dynamic_extent>
|
||||
ArrayProxy( std::span<T, N> & data ) VULKAN_HPP_NOEXCEPT
|
||||
: m_count( static_cast<uint32_t>( data.size() ) )
|
||||
, m_ptr( data.data() )
|
||||
{}
|
||||
|
||||
template <size_t N = std::dynamic_extent, typename B = T, typename std::enable_if<std::is_const<B>::value, int>::type = 0>
|
||||
ArrayProxy( std::span<typename std::remove_const<T>::type, N> & data ) VULKAN_HPP_NOEXCEPT
|
||||
: m_count( static_cast<uint32_t>( data.size() ) )
|
||||
, m_ptr( data.data() )
|
||||
{}
|
||||
#endif
|
||||
|
||||
const T * begin() const VULKAN_HPP_NOEXCEPT
|
||||
{
|
||||
return m_ptr;
|
||||
@ -15321,6 +15347,32 @@ int main( int argc, char ** argv )
|
||||
typename std::enable_if<std::is_const<B>::value, int>::type = 0>
|
||||
ArrayProxyNoTemporaries( std::vector<typename std::remove_const<T>::type, Allocator> && data ) = delete;
|
||||
|
||||
#if defined( VULKAN_HPP_SUPPORT_SPAN )
|
||||
template <size_t N = std::dynamic_extent>
|
||||
ArrayProxyNoTemporaries( std::span<T, N> const & data ) VULKAN_HPP_NOEXCEPT
|
||||
: m_count( static_cast<uint32_t>( data.size() ) )
|
||||
, m_ptr( data.data() )
|
||||
{}
|
||||
|
||||
template <size_t N = std::dynamic_extent, typename B = T, typename std::enable_if<std::is_const<B>::value, int>::type = 0>
|
||||
ArrayProxyNoTemporaries( std::span<typename std::remove_const<T>::type, N> const & data ) VULKAN_HPP_NOEXCEPT
|
||||
: m_count( static_cast<uint32_t>( data.size() ) )
|
||||
, m_ptr( data.data() )
|
||||
{}
|
||||
|
||||
template <size_t N = std::dynamic_extent>
|
||||
ArrayProxyNoTemporaries( std::span<T, N> & data ) VULKAN_HPP_NOEXCEPT
|
||||
: m_count( static_cast<uint32_t>( data.size() ) )
|
||||
, m_ptr( data.data() )
|
||||
{}
|
||||
|
||||
template <size_t N = std::dynamic_extent, typename B = T, typename std::enable_if<std::is_const<B>::value, int>::type = 0>
|
||||
ArrayProxyNoTemporaries( std::span<typename std::remove_const<T>::type, N> & data ) VULKAN_HPP_NOEXCEPT
|
||||
: m_count( static_cast<uint32_t>( data.size() ) )
|
||||
, m_ptr( data.data() )
|
||||
{}
|
||||
#endif
|
||||
|
||||
const T * begin() const VULKAN_HPP_NOEXCEPT
|
||||
{
|
||||
return m_ptr;
|
||||
@ -16670,7 +16722,6 @@ int main( int argc, char ** argv )
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#if 17 <= VULKAN_HPP_CPP_VERSION
|
||||
# include <string_view>
|
||||
#endif
|
||||
@ -16742,6 +16793,11 @@ extern "C" __declspec( dllimport ) FARPROC __stdcall GetProcAddress( HINSTANCE h
|
||||
# include <compare>
|
||||
#endif
|
||||
|
||||
#if ( 201803 <= __cpp_lib_span )
|
||||
# define VULKAN_HPP_SUPPORT_SPAN
|
||||
# include <span>
|
||||
#endif
|
||||
|
||||
)";
|
||||
|
||||
static const std::string structResultValue = R"(
|
||||
|
@ -16,13 +16,15 @@
|
||||
// Compile test on using vk::ArrayProxy
|
||||
|
||||
#include "vulkan/vulkan.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#if ( 20 <= VULKAN_HPP_CPP_VERSION )
|
||||
# include <span>
|
||||
#endif
|
||||
|
||||
void fct(vk::ArrayProxy<int> /*ap*/)
|
||||
{}
|
||||
void fct( vk::ArrayProxy<int> /*ap*/ ) {}
|
||||
|
||||
void fctc(vk::ArrayProxy<const int> /*ap*/)
|
||||
{}
|
||||
void fctc( vk::ArrayProxy<const int> /*ap*/ ) {}
|
||||
|
||||
int main( int /*argc*/, char ** /*argv*/ )
|
||||
{
|
||||
@ -153,6 +155,26 @@ int main(int /*argc*/, char ** /*argv*/)
|
||||
assert( ap20.size() == 2 );
|
||||
vk::ArrayProxy<const int> ap21 = il4;
|
||||
assert( ap21.size() == 2 );
|
||||
|
||||
#if defined( VULKAN_HPP_SUPPORT_SPAN )
|
||||
// std::span<T, N>
|
||||
std::span<int> ss0( sa0.begin(), sa0.size() );
|
||||
fct( ss0 );
|
||||
fctc( ss0 );
|
||||
|
||||
// std::span<T,N> const
|
||||
std::span<const int> ss1( sa1.begin(), sa1.size() );
|
||||
// fct(ss1); // not supported: cannot convert from 'std::span<const int>' to 'vk::ArrayProxy<int>'
|
||||
fctc( ss1 );
|
||||
|
||||
std::span<int> const ss2;
|
||||
fct( ss2 );
|
||||
fctc( ss2 );
|
||||
|
||||
std::span<const int> const ss3( sa3.begin(), sa3.end() );
|
||||
// fct(ss3); // not supported: cannot convert from 'const std::span<const int>' to 'vk::ArrayProxy<int>'
|
||||
fctc( ss3 );
|
||||
#endif
|
||||
}
|
||||
catch ( vk::SystemError const & err )
|
||||
{
|
||||
|
@ -39,7 +39,6 @@
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#if 17 <= VULKAN_HPP_CPP_VERSION
|
||||
# include <string_view>
|
||||
#endif
|
||||
@ -111,6 +110,11 @@ extern "C" __declspec( dllimport ) FARPROC __stdcall GetProcAddress( HINSTANCE h
|
||||
# include <compare>
|
||||
#endif
|
||||
|
||||
#if ( 201803 <= __cpp_lib_span )
|
||||
# define VULKAN_HPP_SUPPORT_SPAN
|
||||
# include <span>
|
||||
#endif
|
||||
|
||||
static_assert( VK_HEADER_VERSION == 187, "Wrong VK_HEADER_VERSION!" );
|
||||
|
||||
// 32-bit vulkan is not typesafe for handles, so don't allow copy constructors on this platform by default.
|
||||
@ -352,6 +356,36 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
, m_ptr( data.data() )
|
||||
{}
|
||||
|
||||
# if defined( VULKAN_HPP_SUPPORT_SPAN )
|
||||
template <size_t N = std::dynamic_extent>
|
||||
ArrayProxy( std::span<T, N> const & data ) VULKAN_HPP_NOEXCEPT
|
||||
: m_count( static_cast<uint32_t>( data.size() ) )
|
||||
, m_ptr( data.data() )
|
||||
{}
|
||||
|
||||
template <size_t N = std::dynamic_extent,
|
||||
typename B = T,
|
||||
typename std::enable_if<std::is_const<B>::value, int>::type = 0>
|
||||
ArrayProxy( std::span<typename std::remove_const<T>::type, N> const & data ) VULKAN_HPP_NOEXCEPT
|
||||
: m_count( static_cast<uint32_t>( data.size() ) )
|
||||
, m_ptr( data.data() )
|
||||
{}
|
||||
|
||||
template <size_t N = std::dynamic_extent>
|
||||
ArrayProxy( std::span<T, N> & data ) VULKAN_HPP_NOEXCEPT
|
||||
: m_count( static_cast<uint32_t>( data.size() ) )
|
||||
, m_ptr( data.data() )
|
||||
{}
|
||||
|
||||
template <size_t N = std::dynamic_extent,
|
||||
typename B = T,
|
||||
typename std::enable_if<std::is_const<B>::value, int>::type = 0>
|
||||
ArrayProxy( std::span<typename std::remove_const<T>::type, N> & data ) VULKAN_HPP_NOEXCEPT
|
||||
: m_count( static_cast<uint32_t>( data.size() ) )
|
||||
, m_ptr( data.data() )
|
||||
{}
|
||||
# endif
|
||||
|
||||
const T * begin() const VULKAN_HPP_NOEXCEPT
|
||||
{
|
||||
return m_ptr;
|
||||
@ -549,6 +583,36 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
typename std::enable_if<std::is_const<B>::value, int>::type = 0>
|
||||
ArrayProxyNoTemporaries( std::vector<typename std::remove_const<T>::type, Allocator> && data ) = delete;
|
||||
|
||||
# if defined( VULKAN_HPP_SUPPORT_SPAN )
|
||||
template <size_t N = std::dynamic_extent>
|
||||
ArrayProxyNoTemporaries( std::span<T, N> const & data ) VULKAN_HPP_NOEXCEPT
|
||||
: m_count( static_cast<uint32_t>( data.size() ) )
|
||||
, m_ptr( data.data() )
|
||||
{}
|
||||
|
||||
template <size_t N = std::dynamic_extent,
|
||||
typename B = T,
|
||||
typename std::enable_if<std::is_const<B>::value, int>::type = 0>
|
||||
ArrayProxyNoTemporaries( std::span<typename std::remove_const<T>::type, N> const & data ) VULKAN_HPP_NOEXCEPT
|
||||
: m_count( static_cast<uint32_t>( data.size() ) )
|
||||
, m_ptr( data.data() )
|
||||
{}
|
||||
|
||||
template <size_t N = std::dynamic_extent>
|
||||
ArrayProxyNoTemporaries( std::span<T, N> & data ) VULKAN_HPP_NOEXCEPT
|
||||
: m_count( static_cast<uint32_t>( data.size() ) )
|
||||
, m_ptr( data.data() )
|
||||
{}
|
||||
|
||||
template <size_t N = std::dynamic_extent,
|
||||
typename B = T,
|
||||
typename std::enable_if<std::is_const<B>::value, int>::type = 0>
|
||||
ArrayProxyNoTemporaries( std::span<typename std::remove_const<T>::type, N> & data ) VULKAN_HPP_NOEXCEPT
|
||||
: m_count( static_cast<uint32_t>( data.size() ) )
|
||||
, m_ptr( data.data() )
|
||||
{}
|
||||
# endif
|
||||
|
||||
const T * begin() const VULKAN_HPP_NOEXCEPT
|
||||
{
|
||||
return m_ptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user