The following code demonstrates the problem.
#include <functional>
namespace test {
template <class T>
class A {
public:
friend auto foo(const A& obj) { return 1; }
};
template <class Function, class... Args>
void bar(Function f, Args&&... args) {
const auto result = std::invoke(f, std::forward<Args>(args)...);
// do stuff with result
}
} // namespace test
auto main() -> int {
test::A<int> value;
test::bar(foo<int>, value); // results in compile time error
test::bar(test::foo<int>, value); // results in compile time error
return 0;
}
Here is the here link to compiler explorer
It probably has to do something with argument dependent lookup, but i cannot really get it.