except: allow void functions in try_func
This commit is contained in:
parent
8e882fcc5c
commit
d2472e229c
21
except.hpp
21
except.hpp
@ -36,20 +36,31 @@ namespace cruft::vk {
|
|||||||
|
|
||||||
|
|
||||||
/// invokes a supplied function with the given arguments and tests
|
/// invokes a supplied function with the given arguments and tests
|
||||||
/// that it returns indicating success using try_code.
|
/// that it indicates success using try_code iff it returns a VkResult,
|
||||||
|
/// else it returns the result of the function.
|
||||||
|
///
|
||||||
|
/// while it would simplify writing this function to avoid
|
||||||
|
/// non-VkResult functions it simplifies some of the upper layers of
|
||||||
|
/// try_foo functions to allow them anyway (eg,
|
||||||
|
/// vkGetBufferMemoryRequirements is otherwise usable with try_query
|
||||||
|
/// if we ignore the VkResult requirement)
|
||||||
template <
|
template <
|
||||||
typename FuncT,
|
typename FuncT,
|
||||||
typename ...Args
|
typename ...Args
|
||||||
>
|
>
|
||||||
static void
|
static auto
|
||||||
try_func (FuncT &&func, Args &&...args)
|
try_func (FuncT &&func, Args &&...args)
|
||||||
{
|
{
|
||||||
static_assert(std::is_same_v<
|
if constexpr (std::is_same_v<
|
||||||
typename func_traits<FuncT>::return_type,
|
typename func_traits<FuncT>::return_type,
|
||||||
VkResult
|
VkResult
|
||||||
>);
|
>)
|
||||||
|
{
|
||||||
try_code (func (std::forward<Args> (args)...));
|
try_code (func (std::forward<Args> (args)...));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return func (std::forward<Args> (args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user