I need to make last argument in my function to be a default argument and the type of this argument is *& (reference to pointer). For some reason this doesn’t work for me:
template<class T>
void f(T*& = nullptr);
I’m getting an error:
Error 1 error C2440: ‘default argument’ : cannot convert from ‘
nullptr‘ to ‘T *&‘
How to get around this?
Basically, if you need to call this function with
nullptr(which means “I don’t have a value to pass to the function, but want to call it anyway”), then you would want to take the argument perT**.See How to pass objects to functions in C++? for more on passing arguments.