ROOT Version: 6.10.06
Platform, compiler: ArchLinux, gcc 7.3.0
After writing an std::vector in aRoot file I can’t get it back in a Root shell session by simply typing its name. Here’s a little demonstrator:
root [0] std::vector<int> test
(std::vector<int> &) {}
root [1] auto *f = TFile::Open("test.root", "RECREATE")
(TFile *) 0x559e43e48af0
root [2] f->WriteObjectAny(&test, TClass::GetClass("std::vector<int>"), "vectorOfInt")
(int) 67
root [3] f->Close()
root [4] auto *f2 = TFile::Open("test.root")
(TFile *) 0x559e43e58e20
root [5] .ls
TFile** test.root
TFile* test.root
KEY: vector<int> vectorOfInt;1 object title
root [6] vectorOfInt
input_line_57:2:3: error: use of undeclared identifier 'vectorOfInt'
(vectorOfInt)
^
Using TFile::Get I can make it work:
root [7] auto *vect = (std::vector<int>*) (f2->Get("vectorOfInt"))
(std::vector<int, allocator<int> > *) 0x561ead369170
root [8] vect->size()
(unsigned long) 0
so it’s not a big issue, but still just typing the name of the object would be more handy. Is this problem related to the fact that the object is not a TObject? Will it be fixed?
Thanks.