I have the following MWE:
#include <iostream>
#include <memory>
class A {
public:
    int n = 42;
    typedef std::shared_ptr<A> Ptr;
};
template<typename T>
void foo(typename T::Ptr arg) {
    std::cout << arg->n << std::endl;
}
template<typename T>
void bar(T arg) {
    std::cout << arg.n << std::endl;
}
int main() {
    A::Ptr a = A::Ptr(new A());
    foo<A>(a); // Can I avoid giving <A> here explicitly.
    // foo(a); // does not compile
    bar(*a); // after all this does work
    return 0;
}
To me it looks like it should also be possible to call foo(a) instead of foo<A>(a). Why is this not possible and can I somehow change the definition of foo to make this possible?
I realize that I could just skip the ::Ptr in the signature, but I still want to have access to the A type without the pointer.