[PATCH v2] gdb::handle_eintr, remove need to specify return type
Tom Tromey
tom@tromey.com
Fri Oct 16 20:51:10 GMT 2020
>>>>> "Pedro" == Pedro Alves <pedro@palves.net> writes:
Pedro> This eliminates the need to specify the return type when using
Pedro> handle_eintr. We let the compiler deduce it for us.
Thanks for doing this. This is closer to how I imagined this wrapper
being written.
Pedro> +template <typename ErrorValType,
Pedro> + typename Fun,
Pedro> + typename... Args>
Pedro> +inline auto
Pedro> +handle_eintr (ErrorValType errval, const Fun &f, const Args &... args)
Pedro> + -> decltype (f(args...))
It seems to me that errval and ErrorValType are unchanging properties of
the function being wrapped. And, normally they are -1 / int.
Also is there ever a case where the return type isn't the same as
ErrorValType?
So maybe instead of requiring these to all be redundantly specified, the
template could use a helper template class that specifies these things
(defaulting to the usual), and then one would write:
pid_t pid = gdb::handle_eintr<::waitpid> (...normal waitpid args);
I'm not sure it's really worth implementing this, but it's closer to
what I was picturing initially.
Tom
More information about the Gdb-patches
mailing list