mirror of
https://github.com/KhronosGroup/Vulkan-Hpp
synced 2024-11-22 12:20:05 +00:00
41 lines
1008 B
C++
41 lines
1008 B
C++
template <typename T>
|
|
class StridedArrayProxy : protected ArrayProxy<T>
|
|
{
|
|
public:
|
|
using ArrayProxy<T>::ArrayProxy;
|
|
|
|
StridedArrayProxy( uint32_t count, T const * ptr, uint32_t stride ) VULKAN_HPP_NOEXCEPT
|
|
: ArrayProxy<T>( count, ptr )
|
|
, m_stride( stride )
|
|
{
|
|
VULKAN_HPP_ASSERT( sizeof( T ) <= stride );
|
|
}
|
|
|
|
using ArrayProxy<T>::begin;
|
|
|
|
const T * end() const VULKAN_HPP_NOEXCEPT
|
|
{
|
|
return reinterpret_cast<T const *>( static_cast<uint8_t const *>( begin() ) + size() * m_stride );
|
|
}
|
|
|
|
using ArrayProxy<T>::front;
|
|
|
|
const T & back() const VULKAN_HPP_NOEXCEPT
|
|
{
|
|
VULKAN_HPP_ASSERT( begin() && size() );
|
|
return *reinterpret_cast<T const *>( static_cast<uint8_t const *>( begin() ) + ( size() - 1 ) * m_stride );
|
|
}
|
|
|
|
using ArrayProxy<T>::empty;
|
|
using ArrayProxy<T>::size;
|
|
using ArrayProxy<T>::data;
|
|
|
|
uint32_t stride() const
|
|
{
|
|
return m_stride;
|
|
}
|
|
|
|
private:
|
|
uint32_t m_stride = sizeof( T );
|
|
};
|