Remove implicit cast operators on ResultValue<T>

As it turned out to not provide a complete solution to the C++-API-change issue on logical-change of the C-API, we simply remove those implicit cast operators. That is, accessing the result and the value need to be explicit.
This commit is contained in:
asuessenbach
2020-07-20 13:48:03 +02:00
committed by Markus Tavenrath
parent 4cdc51ba0f
commit fba2516d9c
9 changed files with 206 additions and 134 deletions

View File

@@ -67,6 +67,8 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::DeviceMemory deviceMemory = device->allocateMemory( {} );
vk::UniqueDeviceMemory uniqueDeviceMemory = vk::UniqueDeviceMemory( deviceMemory, *device );
vk::ResultValue<std::vector<vk::UniquePipeline>> pipelines = device->createGraphicsPipelinesUnique( nullptr, {} );
}
catch ( vk::SystemError const & err )
{

View File

@@ -1,34 +0,0 @@
# Copyright(c) 2020, Collabora Ltd. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.2)
project(ResultValue)
set(HEADERS
)
set(SOURCES
ResultValue.cpp
)
source_group(headers FILES ${HEADERS})
source_group(sources FILES ${SOURCES})
add_executable(ResultValue
${HEADERS}
${SOURCES}
)
set_target_properties(ResultValue PROPERTIES FOLDER "Tests")

View File

@@ -1,67 +0,0 @@
// Copyright(c) 2020, Collabora Ltd. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// VulkanHpp Tests : ResultValue
// Compile-test for ResultValue
#define VULKAN_HPP_DISPATCH_LOADER_DYNAMIC 1
#include "vulkan/vulkan.hpp"
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE
void as_value( int ) {}
void as_ref( int & ) {}
void as_rvref( int && ) {}
void as_cref( const 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<int>;
auto val = result{ vk::Result{}, 42 };
const auto cval = result{ vk::Result{}, 42 };
as_value( val );
as_value( 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 ) );
vk::Pipeline pipe( VkPipeline( 0x8 ) ); // fake a Pipeline here, to have something different from zero
vk::UniquePipeline pipeline( pipe );
vk::ResultValue<vk::UniquePipeline> 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;
}