diff --git a/snippets/ArrayProxyNoTemporaries.hpp b/snippets/ArrayProxyNoTemporaries.hpp index 50742d551..e936d6647 100644 --- a/snippets/ArrayProxyNoTemporaries.hpp +++ b/snippets/ArrayProxyNoTemporaries.hpp @@ -5,101 +5,61 @@ VULKAN_HPP_CONSTEXPR ArrayProxyNoTemporaries() VULKAN_HPP_NOEXCEPT : m_count( 0 ) , m_ptr( nullptr ) - {} + { + } VULKAN_HPP_CONSTEXPR ArrayProxyNoTemporaries( std::nullptr_t ) VULKAN_HPP_NOEXCEPT : m_count( 0 ) , m_ptr( nullptr ) - {} - - ArrayProxyNoTemporaries( T & value ) VULKAN_HPP_NOEXCEPT - : m_count( 1 ) - , m_ptr( &value ) - {} - - template - ArrayProxyNoTemporaries( V && value ) = delete; + { + } - template ::value, int>::type = 0> - ArrayProxyNoTemporaries( typename std::remove_const::type & value ) VULKAN_HPP_NOEXCEPT + template ::value && std::is_lvalue_reference::value, int>::type = 0> + ArrayProxyNoTemporaries( B && value ) VULKAN_HPP_NOEXCEPT : m_count( 1 ) , m_ptr( &value ) - {} - - template ::value, int>::type = 0> - ArrayProxyNoTemporaries( typename std::remove_const::type && value ) = delete; + { + } ArrayProxyNoTemporaries( uint32_t count, T * ptr ) VULKAN_HPP_NOEXCEPT : m_count( count ) , m_ptr( ptr ) - {} - - template ::value, int>::type = 0> - ArrayProxyNoTemporaries( uint32_t count, typename std::remove_const::type * ptr ) VULKAN_HPP_NOEXCEPT - : m_count( count ) - , m_ptr( ptr ) - {} + { + } template - ArrayProxyNoTemporaries( T (& ptr)[C] ) VULKAN_HPP_NOEXCEPT + ArrayProxyNoTemporaries( T ( &ptr )[C] ) VULKAN_HPP_NOEXCEPT : m_count( C ) , m_ptr( ptr ) - {} + { + } template - ArrayProxyNoTemporaries( T (&& ptr)[C] ) = delete; + ArrayProxyNoTemporaries( T ( &&ptr )[C] ) = delete; - template ::value, int>::type = 0> - ArrayProxyNoTemporaries( typename std::remove_const::type (& ptr)[C] ) VULKAN_HPP_NOEXCEPT - : m_count( C ) - , m_ptr( ptr ) - {} - - template ::value, int>::type = 0> - ArrayProxyNoTemporaries( typename std::remove_const::type (&& ptr)[C] ) = delete; - - ArrayProxyNoTemporaries( std::initializer_list const & list ) VULKAN_HPP_NOEXCEPT - : m_count( static_cast( list.size() ) ) - , m_ptr( list.begin() ) - {} - - ArrayProxyNoTemporaries( std::initializer_list const && list ) = delete; - - template ::value, int>::type = 0> - ArrayProxyNoTemporaries( std::initializer_list::type> const & list ) - VULKAN_HPP_NOEXCEPT - : m_count( static_cast( list.size() ) ) - , m_ptr( list.begin() ) - {} - - template ::value, int>::type = 0> - ArrayProxyNoTemporaries( std::initializer_list::type> const && list ) = delete; - - ArrayProxyNoTemporaries( std::initializer_list & list ) VULKAN_HPP_NOEXCEPT - : m_count( static_cast( list.size() ) ) - , m_ptr( list.begin() ) - {} - - ArrayProxyNoTemporaries( std::initializer_list && list ) = delete; - - template ::value, int>::type = 0> - ArrayProxyNoTemporaries( std::initializer_list::type> & list ) VULKAN_HPP_NOEXCEPT - : m_count( static_cast( list.size() ) ) - , m_ptr( list.begin() ) - {} - - template ::value, int>::type = 0> - ArrayProxyNoTemporaries( std::initializer_list::type> && list ) = delete; - - // Any type with a .data() return type implicitly convertible to T*, and a .size() return type implicitly convertible to size_t. + // Any l-value reference with a .data() return type implicitly convertible to T*, and a .size() return type implicitly convertible to size_t. template ().data() ), T *>::value && - std::is_convertible().size() ), std::size_t>::value>::type * = nullptr> - ArrayProxyNoTemporaries( V & v ) VULKAN_HPP_NOEXCEPT + typename std::enable_if().data() )>::value && + std::is_convertible().data() ), T *>::value && + std::is_convertible().size() ), std::size_t>::value && std::is_lvalue_reference::value, + int>::type = 0> + ArrayProxyNoTemporaries( V && v ) VULKAN_HPP_NOEXCEPT : m_count( static_cast( v.size() ) ) , m_ptr( v.data() ) - {} + { + } + + // Any l-value reference with a .begin() return type implicitly convertible to T*, and a .size() return type implicitly convertible to size_t. + template ().begin() )>::value && + std::is_convertible().begin() ), T *>::value && + std::is_convertible().size() ), std::size_t>::value && std::is_lvalue_reference::value, + int>::type = 0> + ArrayProxyNoTemporaries( V && v ) VULKAN_HPP_NOEXCEPT + : m_count( static_cast( v.size() ) ) + , m_ptr( v.begin() ) + { + } const T * begin() const VULKAN_HPP_NOEXCEPT { diff --git a/tests/ArrayProxyNoTemporaries/ArrayProxyNoTemporaries.cpp b/tests/ArrayProxyNoTemporaries/ArrayProxyNoTemporaries.cpp index 463b156c2..cb7594488 100644 --- a/tests/ArrayProxyNoTemporaries/ArrayProxyNoTemporaries.cpp +++ b/tests/ArrayProxyNoTemporaries/ArrayProxyNoTemporaries.cpp @@ -37,13 +37,13 @@ int getInt() return 1; } -int( &&getArrayReference() )[2] +int ( &&getArrayReference() )[2] { static int arr[2] = { 1, 2 }; return std::move( arr ); } -int const( &&getConstArrayReference() )[2] +int const ( &&getConstArrayReference() )[2] { static int const arr[2] = { 1, 2 }; return std::move( arr ); @@ -69,49 +69,54 @@ std::vector const getConstVector() return { 1, 2 }; } -//std::initializer_list getInitializerList() -//{ -// return { 1, 2 }; -//} +std::initializer_list getInitializerList() +{ + return { 1, 2 }; +} -//std::initializer_list const getConstInitializerList() -//{ -// return { 1, 2 }; -//} +std::initializer_list const getConstInitializerList() +{ + return { 1, 2 }; +} int main( int /*argc*/, char ** /*argv*/ ) { try { + // no args + fct( {} ); + fctc( {} ); + // nullptr_t fct( nullptr ); fctc( nullptr ); - vk::ArrayProxyNoTemporaries ap0 = nullptr; - assert( ap0.size() == 0 ); + vk::ArrayProxyNoTemporaries apnt1 = nullptr; + assert( apnt1.size() == 0 ); // Type - // fct(2); // not supported: attempting to reference a deleted function: ArrayProxyNoTemporaries(int &&) - // fctc(1); // not supported: attempting to reference a deleted function: ArrayProxyNoTemporaries(int &&) + // fct(2); // not supported: cannot convert argument 1 from 'int' to 'vk::ArrayProxyNoTemporaries' + // fctc(1); // not supported: cannot convert argument 1 from 'int' to 'vk::ArrayProxyNoTemporaries' // getInt() - // fct( getInt() ); // not supported: attempting to reference a deleted function: ArrayProxyNoTemporaries(int &&) - // fctc( getInt() ); // not supported: attempting to reference a deleted function: ArrayProxyNoTemporaries(int &&) + // fct( getInt() ); // not supported: cannot convert argument 1 from 'int' to 'vk::ArrayProxyNoTemporaries' + // fctc( getInt() ); // not supported: cannot convert argument 1 from 'int' to 'vk::ArrayProxyNoTemporaries' int i0 = 1; fct( i0 ); fctc( i0 ); const int i1 = 2; - // fct(i1); // not supported: ArrayProxyNoTemporaries(const int &) + // fct(i1); // not supported: cannot convert from 'const int *' to 'T * fctc( i1 ); - // vk::ArrayProxyNoTemporaries ap1 = 1; // not supported: ArrayProxyNoTemporaries::ArrayProxyNoTemporaries(int &&) + // vk::ArrayProxyNoTemporaries apnt2 = 1; // not supported: cannot convert from 'int' to 'vk::ArrayProxyNoTemporaries' + // vk::ArrayProxyNoTemporaries apnt3 = 1; // not supported: cannot convert from 'int' to 'vk::ArrayProxyNoTemporaries' - vk::ArrayProxyNoTemporaries ap2 = i0; - assert( ap2.size() == 1 ); - vk::ArrayProxyNoTemporaries ap3 = i1; - assert( ap3.size() == 1 ); + vk::ArrayProxyNoTemporaries apnt4 = i0; + assert( apnt4.size() == 1 ); + vk::ArrayProxyNoTemporaries apnt5 = i1; + assert( apnt5.size() == 1 ); // count, T * int * i0p = &i0; @@ -120,13 +125,13 @@ int main( int /*argc*/, char ** /*argv*/ ) // count, T const* int const * i1p = &i1; - // fct({ 1, i1p }); // not supported: cannot convert argument 1 from 'initializer list' to 'vk::ArrayProxyNoTemporaries' + // fct( { 1, i1p } ); // not supported: cannot convert argument 1 from 'initializer list' to 'vk::ArrayProxyNoTemporaries' fctc( { 1, i1p } ); - vk::ArrayProxyNoTemporaries ap4 = { 1, i0p }; - assert( ap4.size() == 1 ); - vk::ArrayProxyNoTemporaries ap5 = { 1, i1p }; - assert( ap5.size() == 1 ); + vk::ArrayProxyNoTemporaries apnt6 = { 1, i0p }; + assert( apnt6.size() == 1 ); + vk::ArrayProxyNoTemporaries apnt7 = { 1, i1p }; + assert( apnt7.size() == 1 ); // T[count] int ia0[2] = { 0, 1 }; @@ -138,16 +143,16 @@ int main( int /*argc*/, char ** /*argv*/ ) // fct( ia1 ); // not supported: cannot convert argument 1 from 'const int [2]' to 'vk::ArrayProxyNoTemporaries' fctc( ia1 ); - vk::ArrayProxyNoTemporaries ap6 = ia0; - assert( ap6.size() == 2 ); - vk::ArrayProxyNoTemporaries ap7 = ia1; - assert( ap7.size() == 2 ); + vk::ArrayProxyNoTemporaries apnt8 = ia0; + assert( apnt8.size() == 2 ); + vk::ArrayProxyNoTemporaries apnt9 = ia1; + assert( apnt9.size() == 2 ); // getArrayReference - // fct( getConstArrayReference() ); // not supported - // fctc( getConstArrayReference() ); // not supported - // fct( getArrayReference() ); // not supported - // fctc( getArrayReference() ); // not supported + // fct( getConstArrayReference() ); // not supported: cannot convert argument 1 from 'const int [2]' to 'vk::ArrayProxyNoTemporaries' + // fctc( getConstArrayReference() ); // not supported: attempting to reference a deleted function + // fct( getArrayReference() ); // not supported: attempting to reference a deleted function + // fctc( getArrayReference() ); // not supported: attempting to reference a deleted function // std::array std::array sa0 = { 0, 1 }; @@ -156,42 +161,42 @@ int main( int /*argc*/, char ** /*argv*/ ) // std::array std::array sa1 = { 0, 1 }; - // fct(sa1); // not supported: attempting to reference a deleted function: ArrayProxyNoTemporaries&>(V) + // fct( sa1 ); // not supported: cannot convert argument 1 from 'std::array' to 'vk::ArrayProxyNoTemporaries' fctc( sa1 ); // std::array const std::array const sa2 = { 1, 2 }; - // fct(sa2); // not supported: attempting to reference a deleted function: ArrayProxyNoTemporaries&>(V) + // fct( sa2 ); // not supported: cannot convert argument 1 from 'const std::array' to 'vk::ArrayProxyNoTemporaries' fctc( sa2 ); // std::array const std::array const sa3 = { 1, 2 }; - // fct(sa3); // not supported: attempting to reference a deleted function: ArrayProxyNoTemporaries&>(V) + // fct( sa3 ); // not supported: cannot convert argument 1 from 'const std::array' to 'vk::ArrayProxyNoTemporaries' fctc( sa3 ); // getArray - // fct( getConstArray() ); // not supported: attempting to reference a deleted function: ArrayProxyNoTemporaries>(V &&) - // fctc( getConstArray() ); // not supported: attempting to reference a deleted function: ArrayProxyNoTemporaries>(V &&) - // fct( getArray() ); // not supported: attempting to reference a deleted function: ArrayProxyNoTemporaries>(V &&) - // fctc( getArray() ); // not supported: attempting to reference a deleted function: ArrayProxyNoTemporaries>(V &&) + // fct( getConstArray() ); // not supported: cannot convert argument 1 from 'const std::array' to 'vk::ArrayProxyNoTemporaries' + // fctc( getConstArray() ); // not supported: cannot convert argument 1 from 'const std::array' to 'vk::ArrayProxyNoTemporaries' + // fct( getArray() ); // not supported: cannot convert argument 1 from 'std::array' to 'vk::ArrayProxyNoTemporaries' + // fctc( getArray() ); // not supported: cannot convert argument 1 from 'std::array' to 'vk::ArrayProxyNoTemporaries' // from std::array constructors - vk::ArrayProxyNoTemporaries ap8 = sa0; - assert( ap8.size() == 2 ); - - // vk::ArrayProxyNoTemporaries ap9 = sa1; // not supported: attempting to reference a deleted function: ArrayProxyNoTemporaries&>(V) vk::ArrayProxyNoTemporaries ap10 = sa2; // not supported: attempting to reference a deleted function: ArrayProxyNoTemporaries&>(V) vk::ArrayProxyNoTemporaries ap11 = sa3; // not supported: attempting to reference a deleted function: - // ArrayProxyNoTemporaries&>(V) - - vk::ArrayProxyNoTemporaries ap12 = sa0; - assert( ap12.size() == 2 ); - vk::ArrayProxyNoTemporaries ap13 = sa1; - assert( ap13.size() == 2 ); - vk::ArrayProxyNoTemporaries ap14 = sa2; - assert( ap14.size() == 2 ); - vk::ArrayProxyNoTemporaries ap15 = sa3; - assert( ap15.size() == 2 ); + vk::ArrayProxyNoTemporaries apnt10 = sa0; + assert( apnt10.size() == 2 ); + + // vk::ArrayProxyNoTemporaries apnt11 = sa1; // not supported: cannot convert from 'std::array' to 'vk::ArrayProxyNoTemporaries' + // vk::ArrayProxyNoTemporaries apnt12 = sa2; // not supported: cannot convert from 'const std::array' to 'vk::ArrayProxyNoTemporaries' + // vk::ArrayProxyNoTemporaries apnt13 = sa3; // not supported: cannot convert from 'const std::array' to + // 'vk::ArrayProxyNoTemporaries' + + vk::ArrayProxyNoTemporaries apnt14 = sa0; + assert( apnt14.size() == 2 ); + vk::ArrayProxyNoTemporaries apnt15 = sa1; + assert( apnt15.size() == 2 ); + vk::ArrayProxyNoTemporaries apnt16 = sa2; + assert( apnt16.size() == 2 ); + vk::ArrayProxyNoTemporaries apnt17 = sa3; + assert( apnt17.size() == 2 ); // std::vector std::vector sv0 = { 0, 1 }; @@ -200,85 +205,78 @@ int main( int /*argc*/, char ** /*argv*/ ) // std::vector const std::vector const sv1 = { 0, 1 }; - // fct(sv1); // not supported: attempting to reference a deleted function: ArrayProxyNoTemporaries>&>(V) + // fct( sv1 ); // not supported: cannot convert argument 1 from 'const std::vector>' to 'vk::ArrayProxyNoTemporaries' fctc( sv1 ); // getVector - // fct( getConstVector() ); // not supported: attempting to reference a deleted function: ArrayProxyNoTemporaries>>(V &&) fctc( getConstVector() ); // not supported: attempting to reference a deleted function: - // ArrayProxyNoTemporaries>>(V &&) fct( getVector() ); // not supported: attempting to reference a deleted - // function: ArrayProxyNoTemporaries>>(V &&) fctc( getVector() ); // not supported: attempting to reference a - // deleted function: ArrayProxyNoTemporaries>>(V &&) + // fct( getConstVector() ); // not supported: cannot convert argument 1 from 'const std::vector>' to 'vk::ArrayProxyNoTemporaries' + // fctc( getConstVector() ); // not supported: cannot convert argument 1 from 'const std::vector>' to 'vk::ArrayProxyNoTemporaries' + // fct( getVector() ); // not supported: cannot convert argument 1 from 'std::vector>' to 'vk::ArrayProxyNoTemporaries' + // fctc( getVector() ); // not supported: cannot convert argument 1 from 'std::vector>' to 'vk::ArrayProxyNoTemporaries' - vk::ArrayProxyNoTemporaries ap16 = sv0; - assert( ap16.size() == 2 ); + vk::ArrayProxyNoTemporaries apnt18 = sv0; + assert( apnt18.size() == 2 ); - // vk::ArrayProxyNoTemporaries ap17 = sv1; // not supported: attempting to reference a deleted function: ArrayProxyNoTemporaries>&>(V) + // vk::ArrayProxyNoTemporaries apnt19 = sv1; // not supported: cannot convert from 'const std::vector>' to 'vk::ArrayProxyNoTemporaries' - vk::ArrayProxyNoTemporaries ap18 = sv0; - assert( ap18.size() == 2 ); - vk::ArrayProxyNoTemporaries ap19 = sv1; - assert( ap19.size() == 2 ); + vk::ArrayProxyNoTemporaries apnt20 = sv0; + assert( apnt20.size() == 2 ); + vk::ArrayProxyNoTemporaries apnt21 = sv1; + assert( apnt21.size() == 2 ); // std::initializer_list - fct( {} ); - fctc( {} ); - - // fct({ 0, 1 }); // not supported: cannot convert argument 1 from 'initializer list' to 'vk::ArrayProxyNoTemporaries' - // fctc({ 0, 1 }); // not supported: cannot convert argument 1 from 'initializer list' to 'vk::ArrayProxyNoTemporaries' + // fct( { 0, 1 } ); // not supported: cannot convert argument 1 from 'initializer list' to 'vk::ArrayProxyNoTemporaries' + // fctc( { 0, 1 } ); // not supported: cannot convert argument 1 from 'initializer list' to 'vk::ArrayProxyNoTemporaries' // int a = 0; // int b = 1; - // fct({ a, b }); // not supported: cannot convert argument 1 from 'initializer list' to 'vk::ArrayProxyNoTemporaries' - // fctc({ a,b }); // not supported: cannot convert argument 1 from 'initializer list' to 'vk::ArrayProxyNoTemporaries' + // fct( { a, b } ); // not supported: cannot convert argument 1 from 'initializer list' to 'vk::ArrayProxyNoTemporaries' + // fctc( { a, b } ); // not supported: cannot convert argument 1 from 'initializer list' to 'vk::ArrayProxyNoTemporaries' auto il0 = { 0, 1 }; // -> std::initializer_list - // fct(il0); // not supported: cannot convert from 'const int *' to 'int *' + // fct( il0 ); // not supported: cannot convert from 'const int *' to 'int *' fctc( il0 ); std::initializer_list il1 = { 0, 1 }; - // fct(il1); // not supported: cannot convert from 'const int *' to 'int *' + // fct( il1 ); // not supported: cannot convert argument 1 from 'std::initializer_list<_Ty>' to 'vk::ArrayProxyNoTemporaries' fctc( il1 ); std::initializer_list il2 = { 0, 1 }; - // fct(il2); // not supported: attempting to reference a deleted function : ArrayProxyNoTemporaries&>(V) + // fct( il2 ); // not supported: cannot convert argument 1 from 'std::initializer_list' to 'vk::ArrayProxyNoTemporaries' fctc( il2 ); std::initializer_list const il3 = { 0, 1 }; - // fct(il3); // not supported: cannot convert from 'const int *' to 'int *' + // fct( il3 ); // not supported: cannot convert argument 1 from 'const std::initializer_list<_Ty>' to 'vk::ArrayProxyNoTemporaries' fctc( il3 ); std::initializer_list const il4 = { 0, 1 }; - // fct(il4); // not supported: attempting to reference a deleted function: ArrayProxyNoTemporaries&>(V) + // fct( il4 ); // not supported: cannot convert argument 1 from 'const std::initializer_list' to 'vk::ArrayProxyNoTemporaries' fctc( il4 ); // getInitializerList - // fct( getConstInitializerList() ); // not supported: attempting to reference a deleted function: ArrayProxyNoTemporaries(const - // std::initializer_list &&) fctc( getConstInitializerList() ); // not supported: attempting to reference a deleted function: - // ArrayProxyNoTemporaries(const std::initializer_list &&) fct( getInitializerList() ); // not supported: attempting to reference a - // deleted function: ArrayProxyNoTemporaries(std::initializer_list &&) fctc( getInitializerList() ); // not supported: attempting to reference - // a deleted function: ArrayProxyNoTemporaries(std::initializer_list &&) - - // vk::ArrayProxyNoTemporaries ap20 = il1; // not supported: cannot convert from 'const int *' to 'int *' - // vk::ArrayProxyNoTemporaries ap21 = il2; // not supported: attempting to reference a deleted function: - // ArrayProxyNoTemporaries&>(V) vk::ArrayProxyNoTemporaries ap22 = il3; // not supported: cannot convert from 'const int *' - // to 'int *' vk::ArrayProxyNoTemporaries ap23 = il4; // not supported: attempting to reference a deleted function: ArrayProxyNoTemporaries&>(V) - - vk::ArrayProxyNoTemporaries ap24 = {}; - assert( ap24.size() == 0 ); - - // vk::ArrayProxyNoTemporaries ap25 = { 0, 1 }; // not supported - - vk::ArrayProxyNoTemporaries ap26 = il1; - assert( ap26.size() == 2 ); - vk::ArrayProxyNoTemporaries ap27 = il2; - assert( ap27.size() == 2 ); - vk::ArrayProxyNoTemporaries ap28 = il3; - assert( ap28.size() == 2 ); - vk::ArrayProxyNoTemporaries ap29 = il4; - assert( ap29.size() == 2 ); + // fct( getConstInitializerList() ); // not supported: cannot convert argument 1 from 'const std::initializer_list<_Ty>' to 'vk::ArrayProxyNoTemporaries' + // fctc( getConstInitializerList() ); // not supported: cannot convert argument 1 from 'const std::initializer_list<_Ty>' to 'vk::ArrayProxyNoTemporaries' + // fct( getInitializerList() ); // not supported: cannot convert argument 1 from 'std::initializer_list<_Ty>' to 'vk::ArrayProxyNoTemporaries' + // fctc( getInitializerList() ); // not supported: cannot convert argument 1 from 'std::initializer_list<_Ty>' to 'vk::ArrayProxyNoTemporaries' + + // vk::ArrayProxyNoTemporaries apnt22 = il1; // not supported: cannot convert from 'std::initializer_list<_Ty>' to 'vk::ArrayProxyNoTemporaries' + // vk::ArrayProxyNoTemporaries apnt23 = il2; // not supported: cannot convert from 'std::initializer_list' to 'vk::ArrayProxyNoTemporaries' + // vk::ArrayProxyNoTemporaries apnt24 = il3; // not supported: cannot convert from 'const std::initializer_list<_Ty>' to 'vk::ArrayProxyNoTemporaries' + // vk::ArrayProxyNoTemporaries apnt25 = il4; // not supported: cannot convert from 'const std::initializer_list' to 'vk::ArrayProxyNoTemporaries' + + vk::ArrayProxyNoTemporaries apnt26 = {}; + assert( apnt26.size() == 0 ); + + // vk::ArrayProxyNoTemporaries apnt27 = { 0, 1 }; // not supported: cannot convert from 'initializer list' to 'vk::ArrayProxyNoTemporaries' + + vk::ArrayProxyNoTemporaries apnt28 = il1; + assert( apnt28.size() == 2 ); + vk::ArrayProxyNoTemporaries apnt29 = il2; + assert( apnt29.size() == 2 ); + vk::ArrayProxyNoTemporaries apnt30 = il3; + assert( apnt30.size() == 2 ); + vk::ArrayProxyNoTemporaries apnt31 = il4; + assert( apnt31.size() == 2 ); } catch ( vk::SystemError const & err ) { diff --git a/tests/ArrayProxyNoTemporaries/CMakeLists.txt b/tests/ArrayProxyNoTemporaries/CMakeLists.txt index d941b3cc0..1014e39a7 100644 --- a/tests/ArrayProxyNoTemporaries/CMakeLists.txt +++ b/tests/ArrayProxyNoTemporaries/CMakeLists.txt @@ -13,5 +13,5 @@ # limitations under the License. if( NOT VULKAN_HPP_TESTS_BUILD_ONLY_DYNAMIC ) - vulkan_hpp__setup_test( NAME ArrayProxyNoTemporaries ) + vulkan_hpp__setup_test( NAME ArrayProxyNoTemporaries NO_UTILS ) endif() \ No newline at end of file diff --git a/vulkan/vulkan.hpp b/vulkan/vulkan.hpp index 03bd5c031..6505a5af6 100644 --- a/vulkan/vulkan.hpp +++ b/vulkan/vulkan.hpp @@ -388,38 +388,19 @@ namespace VULKAN_HPP_NAMESPACE { } - ArrayProxyNoTemporaries( T & value ) VULKAN_HPP_NOEXCEPT + template ::value && std::is_lvalue_reference::value, int>::type = 0> + ArrayProxyNoTemporaries( B && value ) VULKAN_HPP_NOEXCEPT : m_count( 1 ) , m_ptr( &value ) { } - template - ArrayProxyNoTemporaries( V && value ) = delete; - - template ::value, int>::type = 0> - ArrayProxyNoTemporaries( typename std::remove_const::type & value ) VULKAN_HPP_NOEXCEPT - : m_count( 1 ) - , m_ptr( &value ) - { - } - - template ::value, int>::type = 0> - ArrayProxyNoTemporaries( typename std::remove_const::type && value ) = delete; - ArrayProxyNoTemporaries( uint32_t count, T * ptr ) VULKAN_HPP_NOEXCEPT : m_count( count ) , m_ptr( ptr ) { } - template ::value, int>::type = 0> - ArrayProxyNoTemporaries( uint32_t count, typename std::remove_const::type * ptr ) VULKAN_HPP_NOEXCEPT - : m_count( count ) - , m_ptr( ptr ) - { - } - template ArrayProxyNoTemporaries( T ( &ptr )[C] ) VULKAN_HPP_NOEXCEPT : m_count( C ) @@ -430,59 +411,27 @@ namespace VULKAN_HPP_NAMESPACE template ArrayProxyNoTemporaries( T ( &&ptr )[C] ) = delete; - template ::value, int>::type = 0> - ArrayProxyNoTemporaries( typename std::remove_const::type ( &ptr )[C] ) VULKAN_HPP_NOEXCEPT - : m_count( C ) - , m_ptr( ptr ) - { - } - - template ::value, int>::type = 0> - ArrayProxyNoTemporaries( typename std::remove_const::type ( &&ptr )[C] ) = delete; - - ArrayProxyNoTemporaries( std::initializer_list const & list ) VULKAN_HPP_NOEXCEPT - : m_count( static_cast( list.size() ) ) - , m_ptr( list.begin() ) - { - } - - ArrayProxyNoTemporaries( std::initializer_list const && list ) = delete; - - template ::value, int>::type = 0> - ArrayProxyNoTemporaries( std::initializer_list::type> const & list ) VULKAN_HPP_NOEXCEPT - : m_count( static_cast( list.size() ) ) - , m_ptr( list.begin() ) - { - } - - template ::value, int>::type = 0> - ArrayProxyNoTemporaries( std::initializer_list::type> const && list ) = delete; - - ArrayProxyNoTemporaries( std::initializer_list & list ) VULKAN_HPP_NOEXCEPT - : m_count( static_cast( list.size() ) ) - , m_ptr( list.begin() ) - { - } - - ArrayProxyNoTemporaries( std::initializer_list && list ) = delete; - - template ::value, int>::type = 0> - ArrayProxyNoTemporaries( std::initializer_list::type> & list ) VULKAN_HPP_NOEXCEPT - : m_count( static_cast( list.size() ) ) - , m_ptr( list.begin() ) + // Any l-value reference with a .data() return type implicitly convertible to T*, and a .size() return type implicitly convertible to size_t. + template ().data() )>::value && + std::is_convertible().data() ), T *>::value && + std::is_convertible().size() ), std::size_t>::value && std::is_lvalue_reference::value, + int>::type = 0> + ArrayProxyNoTemporaries( V && v ) VULKAN_HPP_NOEXCEPT + : m_count( static_cast( v.size() ) ) + , m_ptr( v.data() ) { } - template ::value, int>::type = 0> - ArrayProxyNoTemporaries( std::initializer_list::type> && list ) = delete; - - // Any type with a .data() return type implicitly convertible to T*, and a .size() return type implicitly convertible to size_t. + // Any l-value reference with a .begin() return type implicitly convertible to T*, and a .size() return type implicitly convertible to size_t. template ().data() ), T *>::value && - std::is_convertible().size() ), std::size_t>::value>::type * = nullptr> - ArrayProxyNoTemporaries( V & v ) VULKAN_HPP_NOEXCEPT + typename std::enable_if().begin() )>::value && + std::is_convertible().begin() ), T *>::value && + std::is_convertible().size() ), std::size_t>::value && std::is_lvalue_reference::value, + int>::type = 0> + ArrayProxyNoTemporaries( V && v ) VULKAN_HPP_NOEXCEPT : m_count( static_cast( v.size() ) ) - , m_ptr( v.data() ) + , m_ptr( v.begin() ) { } diff --git a/vulkan/vulkansc.hpp b/vulkan/vulkansc.hpp index c7dc102b7..f3648a59a 100644 --- a/vulkan/vulkansc.hpp +++ b/vulkan/vulkansc.hpp @@ -388,38 +388,19 @@ namespace VULKAN_HPP_NAMESPACE { } - ArrayProxyNoTemporaries( T & value ) VULKAN_HPP_NOEXCEPT + template ::value && std::is_lvalue_reference::value, int>::type = 0> + ArrayProxyNoTemporaries( B && value ) VULKAN_HPP_NOEXCEPT : m_count( 1 ) , m_ptr( &value ) { } - template - ArrayProxyNoTemporaries( V && value ) = delete; - - template ::value, int>::type = 0> - ArrayProxyNoTemporaries( typename std::remove_const::type & value ) VULKAN_HPP_NOEXCEPT - : m_count( 1 ) - , m_ptr( &value ) - { - } - - template ::value, int>::type = 0> - ArrayProxyNoTemporaries( typename std::remove_const::type && value ) = delete; - ArrayProxyNoTemporaries( uint32_t count, T * ptr ) VULKAN_HPP_NOEXCEPT : m_count( count ) , m_ptr( ptr ) { } - template ::value, int>::type = 0> - ArrayProxyNoTemporaries( uint32_t count, typename std::remove_const::type * ptr ) VULKAN_HPP_NOEXCEPT - : m_count( count ) - , m_ptr( ptr ) - { - } - template ArrayProxyNoTemporaries( T ( &ptr )[C] ) VULKAN_HPP_NOEXCEPT : m_count( C ) @@ -430,59 +411,27 @@ namespace VULKAN_HPP_NAMESPACE template ArrayProxyNoTemporaries( T ( &&ptr )[C] ) = delete; - template ::value, int>::type = 0> - ArrayProxyNoTemporaries( typename std::remove_const::type ( &ptr )[C] ) VULKAN_HPP_NOEXCEPT - : m_count( C ) - , m_ptr( ptr ) - { - } - - template ::value, int>::type = 0> - ArrayProxyNoTemporaries( typename std::remove_const::type ( &&ptr )[C] ) = delete; - - ArrayProxyNoTemporaries( std::initializer_list const & list ) VULKAN_HPP_NOEXCEPT - : m_count( static_cast( list.size() ) ) - , m_ptr( list.begin() ) - { - } - - ArrayProxyNoTemporaries( std::initializer_list const && list ) = delete; - - template ::value, int>::type = 0> - ArrayProxyNoTemporaries( std::initializer_list::type> const & list ) VULKAN_HPP_NOEXCEPT - : m_count( static_cast( list.size() ) ) - , m_ptr( list.begin() ) - { - } - - template ::value, int>::type = 0> - ArrayProxyNoTemporaries( std::initializer_list::type> const && list ) = delete; - - ArrayProxyNoTemporaries( std::initializer_list & list ) VULKAN_HPP_NOEXCEPT - : m_count( static_cast( list.size() ) ) - , m_ptr( list.begin() ) - { - } - - ArrayProxyNoTemporaries( std::initializer_list && list ) = delete; - - template ::value, int>::type = 0> - ArrayProxyNoTemporaries( std::initializer_list::type> & list ) VULKAN_HPP_NOEXCEPT - : m_count( static_cast( list.size() ) ) - , m_ptr( list.begin() ) + // Any l-value reference with a .data() return type implicitly convertible to T*, and a .size() return type implicitly convertible to size_t. + template ().data() )>::value && + std::is_convertible().data() ), T *>::value && + std::is_convertible().size() ), std::size_t>::value && std::is_lvalue_reference::value, + int>::type = 0> + ArrayProxyNoTemporaries( V && v ) VULKAN_HPP_NOEXCEPT + : m_count( static_cast( v.size() ) ) + , m_ptr( v.data() ) { } - template ::value, int>::type = 0> - ArrayProxyNoTemporaries( std::initializer_list::type> && list ) = delete; - - // Any type with a .data() return type implicitly convertible to T*, and a .size() return type implicitly convertible to size_t. + // Any l-value reference with a .begin() return type implicitly convertible to T*, and a .size() return type implicitly convertible to size_t. template ().data() ), T *>::value && - std::is_convertible().size() ), std::size_t>::value>::type * = nullptr> - ArrayProxyNoTemporaries( V & v ) VULKAN_HPP_NOEXCEPT + typename std::enable_if().begin() )>::value && + std::is_convertible().begin() ), T *>::value && + std::is_convertible().size() ), std::size_t>::value && std::is_lvalue_reference::value, + int>::type = 0> + ArrayProxyNoTemporaries( V && v ) VULKAN_HPP_NOEXCEPT : m_count( static_cast( v.size() ) ) - , m_ptr( v.data() ) + , m_ptr( v.begin() ) { }