I have a function template which takes a T&
, this function is supposed to be supplied with a std::invocable<T&,const Foo&>
.
The invocable is itself a template function and I want to deduce it's T
with the already supplied object from the parameter list.
#include <concepts>
struct Foo {
};
template<typename T>
void baz(T& t, const Foo&) {
}
template<typename T, std::invocable<T&,const Foo&> Func>
void bar(T& obj,Func f ) {
Foo foo{};
f(obj,foo);
}
int main() {
int a{0};
bar(a,baz); // baz is meant to be baz<int>(int&,const Foo&), because a is int
//bar(a,baz<int>);// works
}
How can I do that?