Can't obtain std::vector from Root file by name

std::vector *vect; f2->GetObject(“vectorOfInt”, vect);

Well, this is more or less the workaround I mention in my original post, but what I would like to be able to do is something like:

vectorOfInt->size()

in the same way you can do for e.g. a TH1F stored in a Root file. To be more specific, if for a TH1F I do the same operations I described for std::vector then I get no error:

root [0] TH1F h
(TH1F &) Name:  Title:  NbinsX: 1
root [1] auto *f = TFile::Open("test.root", "RECREATE")
(TFile *) 0x5625507a82d0
root [2] f->WriteObjectAny(&h, TClass::GetClass("TH1F"), "histo")
(int) 226
root [3] f->Close()
root [4] auto *f2 = TFile::Open("test.root")
(TFile *) 0x562550b4f580
root [5] .ls
TFile**         test.root
 TFile*         test.root
  KEY: TH1F     histo;1 object title
root [6] histo->GetName()
(const char *) ""