except: automatically detect ValueT for try_value

This commit is contained in:
Danny Robson 2017-09-07 12:49:58 +10:00
parent d2472e229c
commit acedac53d0

View File

@ -64,13 +64,20 @@ namespace cruft::vk {
}
/// requests a ValueT using a invokable FuncT with arguments
/// returns a ValueT using an invokable FuncT with arguments
/// [Args..., &ValueT] and returns the result after testing for
/// success.
template <typename ValueT, typename FuncT, typename ...Args>
static ValueT
template <typename FuncT, typename ...Args>
static auto
try_query (FuncT &&func, Args &&...args)
{
using ValueT = std::remove_pointer_t<
std::tuple_element_t<
sizeof... (Args),
typename func_traits<FuncT>::argument_types
>
>;
ValueT value;
try_func (func, std::forward<Args> (args)..., &value);
return value;