diff --git a/Vulkan-Headers b/Vulkan-Headers index 9d2dfca..f315245 160000 --- a/Vulkan-Headers +++ b/Vulkan-Headers @@ -1 +1 @@ -Subproject commit 9d2dfca53b754dd3ab916899fed567a5290c30aa +Subproject commit f31524575668c6c483356bd54ca974590e31be8e diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 6be28e1..5aa96b2 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -7955,15 +7955,6 @@ namespace std template struct ResultValue> { -#ifdef VULKAN_HPP_HAS_NOEXCEPT - ResultValue(Result r, UniqueHandle & v) VULKAN_HPP_NOEXCEPT -#else - ResultValue(Result r, UniqueHandle& v) -#endif - : result(r) - , value(v) - {} - #ifdef VULKAN_HPP_HAS_NOEXCEPT ResultValue(Result r, UniqueHandle && v) VULKAN_HPP_NOEXCEPT #else @@ -7978,6 +7969,11 @@ namespace std operator std::tuple&>() VULKAN_HPP_NOEXCEPT { return std::tuple&>(result, value); } + operator UniqueHandle& () & VULKAN_HPP_NOEXCEPT + { + return value; + } + operator UniqueHandle() VULKAN_HPP_NOEXCEPT { return std::move(value); diff --git a/tests/ResultValue/CMakeLists.txt b/tests/ResultValue/CMakeLists.txt index d6c2250..3da9aaa 100644 --- a/tests/ResultValue/CMakeLists.txt +++ b/tests/ResultValue/CMakeLists.txt @@ -26,13 +26,9 @@ set(SOURCES source_group(headers FILES ${HEADERS}) source_group(sources FILES ${SOURCES}) -add_library(ResultValue +add_executable(ResultValue ${HEADERS} ${SOURCES} ) -if (UNIX) - target_link_libraries(ResultValue "-ldl") -endif() - set_target_properties(ResultValue PROPERTIES FOLDER "Tests") diff --git a/tests/ResultValue/ResultValue.cpp b/tests/ResultValue/ResultValue.cpp index c33b24b..ec2afb8 100644 --- a/tests/ResultValue/ResultValue.cpp +++ b/tests/ResultValue/ResultValue.cpp @@ -21,34 +21,47 @@ VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE -// Compile only test for issue 589. -void test_conversion() -{ -#if defined(VULKAN_DISABLE_IMPLICIT_RESULT_VALUE_CAST) - static_assert(false, "Conversions not enabled"); -#endif +void as_value( int ) {} +void as_ref( int & ) {} +void as_rvref( int && ) {} +void as_cref( const int & ) {} +void as_crvref( const int && ) {} - void as_value(int); - void as_ref(int&); - void as_cref(const int&); - void as_rvref(int&&); - void as_crvref(const int&&); +void as_cref( const vk::UniquePipeline & ) {} + +int main( int /*argc*/, char ** /*argv*/ ) +{ +#if defined( VULKAN_DISABLE_IMPLICIT_RESULT_VALUE_CAST ) + static_assert( false, "Conversions not enabled" ); +#endif using result = vk::ResultValue; - auto val = result {vk::Result{}, 42}; - const auto cval = result {vk::Result{}, 42}; + auto val = result{ vk::Result{}, 42 }; + const auto cval = result{ vk::Result{}, 42 }; - as_value(val); - as_value(cval); + as_value( val ); + as_value( cval ); - as_ref(val); - //as_ref(cval); // should fail - as_cref(val); - as_cref(cval); + as_ref( val ); + // as_ref(cval); // should fail + as_cref( val ); + as_cref( cval ); - as_rvref(std::move(val)); - //as_rvref(std::move(cval)); // should fail - as_crvref(std::move(val)); - as_crvref(std::move(cval)); + as_rvref( std::move( val ) ); + // as_rvref(std::move(cval)); // should fail + as_crvref( std::move( val ) ); + as_crvref( std::move( cval ) ); + + vk::Pipeline pipe( VkPipeline( 0x8 ) ); // fake a Pipeline here, to have something different from zero + vk::UniquePipeline pipeline( pipe ); + vk::ResultValue rv( {}, std::move( pipeline ) ); + + as_cref( rv ); // does not move out handle + assert( rv.value ); + + auto p = std::move( rv.value ); + p.release(); // release the faked Pipeline, to prevent error on trying to destroy it + + return 0; } diff --git a/vulkan/vulkan.hpp b/vulkan/vulkan.hpp index 41c04e0..eaabbc1 100644 --- a/vulkan/vulkan.hpp +++ b/vulkan/vulkan.hpp @@ -52,7 +52,7 @@ # include #endif -static_assert( VK_HEADER_VERSION == 143, "Wrong VK_HEADER_VERSION!" ); +static_assert( VK_HEADER_VERSION == 144, "Wrong VK_HEADER_VERSION!" ); // 32-bit vulkan is not typesafe for handles, so don't allow copy constructors on this platform by default. // To enable this feature on 32-bit platforms please define VULKAN_HPP_TYPESAFE_CONVERSION @@ -15887,15 +15887,6 @@ namespace VULKAN_HPP_NAMESPACE template struct ResultValue> { -# ifdef VULKAN_HPP_HAS_NOEXCEPT - ResultValue( Result r, UniqueHandle & v ) VULKAN_HPP_NOEXCEPT -# else - ResultValue( Result r, UniqueHandle & v ) -# endif - : result( r ) - , value( v ) - {} - # ifdef VULKAN_HPP_HAS_NOEXCEPT ResultValue( Result r, UniqueHandle && v ) VULKAN_HPP_NOEXCEPT # else @@ -15913,6 +15904,11 @@ namespace VULKAN_HPP_NAMESPACE return std::tuple &>( result, value ); } + operator UniqueHandle &() & VULKAN_HPP_NOEXCEPT + { + return value; + } + operator UniqueHandle() VULKAN_HPP_NOEXCEPT { return std::move( value );