Assume some type MyClass complies with all C++ standards and ROOT6 is used. In principle, should MyClass always be write-able to a .root file, provided it is a public descendant of TObject and includes the ClassDef macro? What if MyClass does’t descend from TObject nor include the ClassDef macro?
Right now, I have trouble in both scenarios and am unsure why that is. For example, the code below compiles via .L Test.cc++, but always yields an error when run:
#include
#include <TFile.h>
using std::array;
struct MyClass {
array<double,4> Vals {{1,2,3,4}};
};
void Test()
{
TFile Out {“TestOut.root”, “recreate”};
MyClass Temp {};
Out.WriteObject(&Temp,“PersistentName”);
}
Warning in TStreamerInfo::Build:: MyClass: array<double,4> has no streamer or dictionary, data member “Vals” will not be saved
This version gives the same error:
#include
#include <TFile.h>
using std::array;
struct MyClass : public TObject {
array<double,4> Vals {{1,2,3,4}};
ClassDef(MyClass,1);
};
void Test()
{
TFile Out {“TestOut.root”, “recreate”};
MyClass Temp {};
Temp.Write(“PersistentName”);
}
I’m running ROOT6 beta 3 on OS X 10.9.2, with Xcode 5.1.