From 5d8c550b0dcc1f3241724ac3d0bdd8ebaaf4ada5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20S=C3=BC=C3=9Fenbach?= Date: Tue, 27 Jun 2023 11:31:29 +0200 Subject: [PATCH] Mark vk::ResultValue::asTuple() & as deprecated, introduce vk::ResultValue::asTuple() && (#1605) --- snippets/ResultValue.hpp | 22 +++++++++++++++++++--- tests/UniqueHandle/UniqueHandle.cpp | 7 +++++++ vulkan/vulkan.hpp | 20 ++++++++++++++++++-- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/snippets/ResultValue.hpp b/snippets/ResultValue.hpp index 4763e6e..7c9ada4 100644 --- a/snippets/ResultValue.hpp +++ b/snippets/ResultValue.hpp @@ -40,12 +40,20 @@ , value(std::move(v)) {} - std::tuple> asTuple() + VULKAN_HPP_DEPRECATED( + "asTuple() on an l-value is deprecated, as it implicitly moves the UniqueHandle out of the ResultValue. Use asTuple() on an r-value instead, requiring to explicitly move the UniqueHandle." ) + std::tuple> + asTuple() & { return std::make_tuple( result, std::move( value ) ); } - Result result; + std::tuple> asTuple() && + { + return std::make_tuple( result, std::move( value ) ); + } + + Result result; UniqueHandle value; }; @@ -61,7 +69,15 @@ , value( std::move( v ) ) {} - std::tuple>> asTuple() + VULKAN_HPP_DEPRECATED( + "asTuple() on an l-value is deprecated, as it implicitly moves the UniqueHandle out of the ResultValue. Use asTuple() on an r-value instead, requiring to explicitly move the UniqueHandle." ) + std::tuple>> + asTuple() & + { + return std::make_tuple( result, std::move( value ) ); + } + + std::tuple>> asTuple() && { return std::make_tuple( result, std::move( value ) ); } diff --git a/tests/UniqueHandle/UniqueHandle.cpp b/tests/UniqueHandle/UniqueHandle.cpp index 5179212..c80e0a6 100644 --- a/tests/UniqueHandle/UniqueHandle.cpp +++ b/tests/UniqueHandle/UniqueHandle.cpp @@ -262,6 +262,13 @@ int main( int /*argc*/, char ** /*argv*/ ) ); // create a GraphicsPipeline + vk::ResultValue rv = device->createGraphicsPipelineUnique( *pipelineCache, graphicsPipelineCreateInfo ); +#if 17 <= VULKAN_HPP_CPP_VERSION + auto [r, v] = std::move( rv ); +#endif + // auto trv = rv.asTuple(); // asTuple() on an l-value is deprecated !! + auto trv1 = std::move( rv ).asTuple(); + vk::UniquePipeline graphicsPipeline = device->createGraphicsPipelineUnique( *pipelineCache, graphicsPipelineCreateInfo ).value; vk::UniquePipeline graphicsPipeline2 = diff --git a/vulkan/vulkan.hpp b/vulkan/vulkan.hpp index 7cf1c62..82adb52 100644 --- a/vulkan/vulkan.hpp +++ b/vulkan/vulkan.hpp @@ -6788,7 +6788,15 @@ namespace VULKAN_HPP_NAMESPACE { } - std::tuple> asTuple() + VULKAN_HPP_DEPRECATED( + "asTuple() on an l-value is deprecated, as it implicitly moves the UniqueHandle out of the ResultValue. Use asTuple() on an r-value instead, requiring to explicitly move the UniqueHandle." ) + + std::tuple> asTuple() & + { + return std::make_tuple( result, std::move( value ) ); + } + + std::tuple> asTuple() && { return std::make_tuple( result, std::move( value ) ); } @@ -6810,7 +6818,15 @@ namespace VULKAN_HPP_NAMESPACE { } - std::tuple>> asTuple() + VULKAN_HPP_DEPRECATED( + "asTuple() on an l-value is deprecated, as it implicitly moves the UniqueHandle out of the ResultValue. Use asTuple() on an r-value instead, requiring to explicitly move the UniqueHandle." ) + + std::tuple>> asTuple() & + { + return std::make_tuple( result, std::move( value ) ); + } + + std::tuple>> asTuple() && { return std::make_tuple( result, std::move( value ) ); }