I want to write a function that looks like this:
template<class T>
void Foo(const std::shared_ptr<const T>& ptr);
so that I can call it like this:
std::shared_ptr<int> ptr;
Foo(ptr);
However, the compiler can't deduce T and I have to make it explicit:
Foo<int>(ptr);
or to overload it with void Foo(const std::shared_ptr<T>& ptr)
.
Can I have a single declaration Foo
with const T
so that T
can be deduced?