Can I use `TFile::Write()` to write a temporary object?

Related: Is shared_ptr supported in class member derived from TObject? - #5 by pcanal