I implemented a generic event emitter class which allows code to register callbacks, and emit events with arguments. I used Boost.Any type erasure to store the callbacks so
The compiler doesn't infer anything because the compiler implements the C++ language, and the language's template argument deduction rules do not allow the deduction in the way you want.
Here's a simple example that represents your situation:
template struct Foo
{
Foo(int) {}
};
template void magic(Foo const &);
int main()
{
magic(10); // what is T?
}