2022-07-28 15:09:08 +00:00
|
|
|
template <typename T>
|
|
|
|
class ArrayProxy
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
VULKAN_HPP_CONSTEXPR ArrayProxy() VULKAN_HPP_NOEXCEPT
|
|
|
|
: m_count( 0 )
|
|
|
|
, m_ptr( nullptr )
|
|
|
|
{}
|
|
|
|
|
|
|
|
VULKAN_HPP_CONSTEXPR ArrayProxy( std::nullptr_t ) VULKAN_HPP_NOEXCEPT
|
|
|
|
: m_count( 0 )
|
|
|
|
, m_ptr( nullptr )
|
|
|
|
{}
|
|
|
|
|
2022-09-12 14:53:44 +00:00
|
|
|
ArrayProxy( T const & value ) VULKAN_HPP_NOEXCEPT
|
2022-07-28 15:09:08 +00:00
|
|
|
: m_count( 1 )
|
|
|
|
, m_ptr( &value )
|
|
|
|
{}
|
|
|
|
|
2022-09-12 14:53:44 +00:00
|
|
|
ArrayProxy( uint32_t count, T const * ptr ) VULKAN_HPP_NOEXCEPT
|
2022-07-28 15:09:08 +00:00
|
|
|
: m_count( count )
|
|
|
|
, m_ptr( ptr )
|
|
|
|
{}
|
|
|
|
|
|
|
|
template <std::size_t C>
|
2022-09-12 14:53:44 +00:00
|
|
|
ArrayProxy( T const ( &ptr )[C] ) VULKAN_HPP_NOEXCEPT
|
2022-07-28 15:09:08 +00:00
|
|
|
: m_count( C )
|
|
|
|
, m_ptr( ptr )
|
|
|
|
{}
|
|
|
|
|
|
|
|
# if __GNUC__ >= 9
|
|
|
|
# pragma GCC diagnostic push
|
|
|
|
# pragma GCC diagnostic ignored "-Winit-list-lifetime"
|
|
|
|
# endif
|
|
|
|
|
|
|
|
ArrayProxy( std::initializer_list<T> const & list ) VULKAN_HPP_NOEXCEPT
|
|
|
|
: m_count( static_cast<uint32_t>( list.size() ) )
|
|
|
|
, m_ptr( list.begin() )
|
|
|
|
{}
|
|
|
|
|
|
|
|
template <typename B = T, typename std::enable_if<std::is_const<B>::value, int>::type = 0>
|
|
|
|
ArrayProxy( std::initializer_list<typename std::remove_const<T>::type> const & list ) VULKAN_HPP_NOEXCEPT
|
|
|
|
: m_count( static_cast<uint32_t>( list.size() ) )
|
|
|
|
, m_ptr( list.begin() )
|
2022-09-12 14:53:44 +00:00
|
|
|
{
|
|
|
|
}
|
2022-07-28 15:09:08 +00:00
|
|
|
|
2022-09-12 14:53:44 +00:00
|
|
|
#if __GNUC__ >= 9
|
2022-07-28 15:09:08 +00:00
|
|
|
# pragma GCC diagnostic pop
|
|
|
|
# endif
|
|
|
|
|
|
|
|
// Any type with a .data() return type implicitly convertible to T*, and a .size() return type implicitly
|
|
|
|
// convertible to size_t. The const version can capture temporaries, with lifetime ending at end of statement.
|
|
|
|
template <typename V,
|
|
|
|
typename std::enable_if<
|
|
|
|
std::is_convertible<decltype( std::declval<V>().data() ), T *>::value &&
|
|
|
|
std::is_convertible<decltype( std::declval<V>().size() ), std::size_t>::value>::type * = nullptr>
|
|
|
|
ArrayProxy( V const & v ) VULKAN_HPP_NOEXCEPT
|
|
|
|
: m_count( static_cast<uint32_t>( v.size() ) )
|
|
|
|
, m_ptr( v.data() )
|
|
|
|
{}
|
|
|
|
|
|
|
|
const T * begin() const VULKAN_HPP_NOEXCEPT
|
|
|
|
{
|
|
|
|
return m_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const T * end() const VULKAN_HPP_NOEXCEPT
|
|
|
|
{
|
|
|
|
return m_ptr + m_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
const T & front() const VULKAN_HPP_NOEXCEPT
|
|
|
|
{
|
|
|
|
VULKAN_HPP_ASSERT( m_count && m_ptr );
|
|
|
|
return *m_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const T & back() const VULKAN_HPP_NOEXCEPT
|
|
|
|
{
|
|
|
|
VULKAN_HPP_ASSERT( m_count && m_ptr );
|
|
|
|
return *( m_ptr + m_count - 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool empty() const VULKAN_HPP_NOEXCEPT
|
|
|
|
{
|
|
|
|
return ( m_count == 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t size() const VULKAN_HPP_NOEXCEPT
|
|
|
|
{
|
|
|
|
return m_count;
|
|
|
|
}
|
|
|
|
|
2022-09-12 14:53:44 +00:00
|
|
|
T const * data() const VULKAN_HPP_NOEXCEPT
|
2022-07-28 15:09:08 +00:00
|
|
|
{
|
|
|
|
return m_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2022-09-12 14:53:44 +00:00
|
|
|
uint32_t m_count;
|
|
|
|
T const * m_ptr;
|
2022-07-28 15:09:08 +00:00
|
|
|
};
|