That will still work. The check is for rvalue references only:
void ok()
{
vtkNew<vtkPolyData> pd;
// argument is an lvalue, implicit cast to T* allowed
filter->SetInputData(pd);
}
void not_ok()
{
// argument is rvalue, implicit cast to T* disallowed
filter->SetInputData(vtkNew<PolyData>{}); // <-- compile error
}
void ok_again()
{
// Argument is raw pointer, no implicit cast needed.
// The explicit Get() call implies that the author has thought
// about reference counting in the callee and is aware that this is a
// boundary between automatic and manual reference counting.
filter->SetInputData(vtkNew<vtkPolyData>{}.Get());
}
So basically, the implicit cast only works when the vtkNew
object is not a temporary rvalue that would be destroyed at the end of the statement. If someone really wants to get the pointer out of the temporary, they can use Get()
, but that’s a “here be dragons” operation and requiring the extra call prevents mistakes.