From acedac53d0b168b9279849abef80eaf7ee467f10 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 7 Sep 2017 12:49:58 +1000 Subject: [PATCH] except: automatically detect ValueT for try_value --- except.hpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/except.hpp b/except.hpp index 3b8769e..f0272d5 100644 --- a/except.hpp +++ b/except.hpp @@ -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 - static ValueT + template + static auto try_query (FuncT &&func, Args &&...args) { + using ValueT = std::remove_pointer_t< + std::tuple_element_t< + sizeof... (Args), + typename func_traits::argument_types + > + >; + ValueT value; try_func (func, std::forward (args)..., &value); return value;