How can one choose a class template member function's argument type depending on the class template parameter value?
Here is an example:
#include <memory>
template <class T, bool plainPointer=true>
class C
{
// pseudocode below
void f(plainPointer ? T * x : std::shared_ptr<T> x) { /*implementation*/ }
};
That is, if plainPointer==true
, the following class member function should be defined:
void f(T * x) { /*implementation*/ }
otherwise, this member function should be defined:
void f(std::shared_ptr<T> x) { /*implementation*/ }
I would like to have a single implementation for both functions, and only the argument type of f
should be plainPointer
dependent.