If I have a function template that has a template parameter by value or ref like
template<class T> void DoSomething(T& t){ t.method();}
if i want to deal with pointers or smart pointers is it best derefernce first so the code works or write a delegating function like
template<class T> void DoSomething(T* t){ Dosomething(*t);}
Like all “is it best” questions, the answer is “it depends”. There will be debates and opinions.
However, I would recommend using the second method. The reason is that, you can then add extra checks in the second form of the function. For example:
But like I said, it most certainly depends on your whole project.