In a previous forum post [1], it was mentioned that saving unique_ptrs in a TTree is possible. I tried using the example code here [2], which writes and reads a TTree using a dictionary, but it doesn’t seem to work.
@pcanal, could you please help me understand how to do this, or point me to a working example? It seems that most TTree examples have been removed…
Dear Alvaro,
Thank you for your question. You even identified the corresponding expert.
I just wanted to mention that due to today’s US holiday, the reply latency may be higher.
Best,
Lukas
Your code looks correct to me. The issue here is that it’s using a unique pointer to a POD (plain old datatype, int in this case). In the ROOT I/O, this is interpreted as array (@pcanal may correct me / give more details). This is typically not a critical limitation because there is anyway limited use in having a pointer to a POD.
If you change the code to store, e.g., a unique pointer to std::string, it works.