What can I use to dereference a template argument if it’s a pointer (or a smart pointer), or leave it as is if it’s not?
template<class T> void subf(const T& item)
{
item.foo();
}
template<class T> void f(const T& item)
{
subf(magic_dereference_function(item));
}
Anything in Boost is an option.
You’ll have to add overloads for smart pointers individually. There’s no way to detected if a class is a “smart pointer”. You could detect the presence of
operator->, but that doesn’t mean it’s a smart pointer.