This question is regarding exception handling in Vulkan-Hpp (official Vulkan C++ bindings).
I wrote a small application using Vulkan-Hpp without VULKAN_HPP_NO_EXCEPTIONS
defined (and with exception handlers). But after coming across this stackoverflow question (Are Exceptions in C++ really slow) I started worrying about the penalty for using exceptions there. Then I found out about the define VULKAN_HPP_NO_EXCEPTIONS
, but it changes the syntax completely for all calls which could throw an exception (because of different return values): that means, one has to decide before starting implementation to either use VULKAN_HPP_NO_EXCEPTIONS
or not (i.e. they can't be enabled for the "Debug" Configuration and disabled for the "Release" Configuration easily).
If exception handling is disabled by defining
VULKAN_HPP_NO_EXCEPTIONS
ResultValue<SomeType>::type
is a struct which contains the return value and the error code in the fields result and value.
i.e.
surface = instance.createWin32SurfaceKHR(surfaceCreateInfo);
becomes
vk::ResultValue<vk::SurfaceKHR> surfaceResult = instance.createWin32SurfaceKHR(surfaceCreateInfo);
if (surfaceResult.result == vk::Result::eSuccess) {
surface = surfaceResult.value;
}
So given that it is not trivial to change the strategy regarding VULKAN_HPP_NO_EXCEPTIONS
at a later stage in development, I wonder in which situations I should use VULKAN_HPP_NO_EXCEPTIONS
for my project and in which situations I shouldn't?
I assume there must be some technical rationale behind it, other than just personal taste/opinion.