Nothing more clear than the old good MCVE:
struct X { auto get(int) const -> int { return {}; } auto get(int) -> int { return {}; } }; template <class R> auto f(auto (X::*)(int) const -> R) {}
This does not work in g ++ (4.9.2 and 5.1.0). However, if the old return type is used:
template <class R> auto f(R (X::*)(int) const) {}
it works.
In clang (3.5.0) both options work.
I know that the return type of the return type changes when the type of the return value is output and its volume, so I will not quickly throw it as a gcc error. So what does the standard say? Which compiler is right?
The most important error message, I think
Failed to output pattern parameter "R"
g ++ full post:
main2.cpp: In function 'int main()': main2.cpp:21:12: error: no matching function for call to 'f(<unresolved overloaded function type>)' f(&X::get); ^ main2.cpp:18:25: note: candidate: template<class R, class auto:1> auto f(auto:1 (X::*)(int) const) template <class R> auto f(auto (X::*)(int) const -> R) {} ^ main2.cpp:18:25: note: template argument deduction/substitution failed: main2.cpp:21:12: note: types 'auto:1 (X::)(int) const' and 'int (X::)(int)' have incompatible cv-qualifiers f(&X::get); ^ main2.cpp:21:12: note: couldn't deduce template parameter 'R' <builtin>: recipe for target 'main2' failed make: *** [main2] Error 1
bolov source share