Relevant previous discussion here: https://root-forum.cern.ch/t/storing-ttreereadervalues-in-std-map/21047/5.
I would like to write a custom classs that would be supplied an arbitrary list of strings of branch names to be read. And I don’t see any other way to do this other than creating a std::map<std::string,TTreeReaderValue> object (ideally also further using std::variant).
I did consider RDataFrame as an alternative, but unfortunately I need lower-level control to the event loop than is allowed/easily-provided by this class.
While the code as written in the poster’s example as a work-around works correctly as expected, it does not work once the TTreeReaderValue object itself goes out of scope, which defeats the purpose of being able to store them in maps for me.
Is there really no way to have TTreeReaderValue objects in std containers?