template<typename T>
void foo(T&& p1)
{
p1.get();
}
int main(int argc, char *argv[])
{
auto a = std::unique_ptr<int>();
a = NULL;
// this works because a is a unique ptr and it has a get method
foo(a);
// this does not work because NULL does not has this method. But can it work tho like how we use the raw pointer?
foo(NULL);
return 0;
}
So basically I want to finish some function/API that can receive both nullptr literal and unique_ptr as funtion argument. How can I do it?