Add ArrayProxy constructors with support for raw array with size
There's a little known C language family feature, which makes it possible to take a pointer or reference to an array with size. Use this feature to add constructors to ArrayProxy and ArrayProxyNoTemporaries which can wrap raw arrays and deduce their size automatically.
This commit is contained in:
@@ -283,6 +283,20 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
{
|
||||
}
|
||||
|
||||
template <std::size_t C>
|
||||
ArrayProxy( T ( &ptr )[C] ) VULKAN_HPP_NOEXCEPT
|
||||
: m_count( C )
|
||||
, m_ptr( ptr )
|
||||
{
|
||||
}
|
||||
|
||||
template <std::size_t C, typename B = T, typename std::enable_if<std::is_const<B>::value, int>::type = 0>
|
||||
ArrayProxy( typename std::remove_const<T>::type ( &ptr )[C] ) VULKAN_HPP_NOEXCEPT
|
||||
: m_count( C )
|
||||
, m_ptr( ptr )
|
||||
{
|
||||
}
|
||||
|
||||
# if __GNUC__ >= 9
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Winit-list-lifetime"
|
||||
@@ -428,6 +442,26 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
{
|
||||
}
|
||||
|
||||
template <std::size_t C>
|
||||
ArrayProxyNoTemporaries( T ( &ptr )[C] ) VULKAN_HPP_NOEXCEPT
|
||||
: m_count( C )
|
||||
, m_ptr( ptr )
|
||||
{
|
||||
}
|
||||
|
||||
template <std::size_t C>
|
||||
ArrayProxyNoTemporaries( T( &&ptr )[C] ) = delete;
|
||||
|
||||
template <std::size_t C, typename B = T, typename std::enable_if<std::is_const<B>::value, int>::type = 0>
|
||||
ArrayProxyNoTemporaries( typename std::remove_const<T>::type ( &ptr )[C] ) VULKAN_HPP_NOEXCEPT
|
||||
: m_count( C )
|
||||
, m_ptr( ptr )
|
||||
{
|
||||
}
|
||||
|
||||
template <std::size_t C, typename B = T, typename std::enable_if<std::is_const<B>::value, int>::type = 0>
|
||||
ArrayProxyNoTemporaries( typename std::remove_const<T>::type( &&ptr )[C] ) = delete;
|
||||
|
||||
ArrayProxyNoTemporaries( std::initializer_list<T> const & list ) VULKAN_HPP_NOEXCEPT
|
||||
: m_count( static_cast<uint32_t>( list.size() ) )
|
||||
, m_ptr( list.begin() )
|
||||
|
||||
Reference in New Issue
Block a user