Can the return type of the function be obtained from within the function?
Call the function with a decltype. decltype(foo(p)) f{};
Call the function with a decltype. decltype(foo(p)) f{};
Since it is an expression that comma is simply the comma operator (meaning the type is the type of the rhs side: void), not another argument. That code is using SFINAE – it’s enabled if t.reserve(n) exists but it wants to keep the return type as void.
There are certain cases where you must use a trailing return type. Most notably, a lambda return type, if specified, must be specified via a trailing return type. Also, if your return type utilizes a decltype that requires that the argument names are in scope, a trailing return type must be used (however, one can … Read more