Consider the following code:
auto f() -> decltype(auto) { } int main() { f(); }
The return type is displayed and decltype(auto) used as the return type.
The code below is a slightly modified (actually, sfinae'd) version:
struct S { static void f() {} }; struct T {}; template<typename U> auto f(int) -> decltype(U::f(), void()) {
If you pass the exam for this function:
template<typename U> auto f(int) -> decltype(U::f(), void()) {
Question: is it possible to use a return type of return to execute sfinae and still have a return type?
I mean something like the code below (this does not work, of course):
template<typename U> auto f(int) -> decltype(U::f(), auto) {
Note. I'm not looking for alternative approaches with template options, I know them, and I'm just interested to know if this is a viable solution.
source share