A class with std::vector<Float_t> members in a TTree

Hello,
I am experimenting problems in the dictionary generation for a class containing pointers to std::vector<Float_t> (or <Int_t>).
The dictionary is generated with no problems, but when I try to compile it I have several errors of the type:

PhotoDict.cc: In member function ‘virtual void PhotoInfo::Streamer(TBuffer&)’: PhotoDict.cc:118: error: type ‘class std::vector<float, std::allocator<float> >’ argument given to ‘delete’, expected pointer PhotoDict.cc:119: error: no match for ‘operator=’ in ‘*((PhotoInfo*)this)->PhotoInfo::hE = (((const std::allocator<float>&)((const std::allocator<float>*)(& std::allocator<float>()))), (((std::vector<float, std::allocator<float> >*)operator new(12u)), (<statement>, <anonymous>)))’ /usr/include/c++/4.2/bits/vector.tcc:132: note: candidates are: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = float, _Alloc = std::allocator<float>] PhotoDict.cc:120: error: no match for ‘operator*’ in ‘**((PhotoInfo*)this)->PhotoInfo::hE’
I have attached a simplified version of my class (PhotoInfo) and the LinkDef.hh file. That is all you need to reproduce the problem.
To generate the dictionary:

rootcint -f PhotoDict.cc -c -p PhotoInfo.hh LinkDef.hh

To compile it:

g++ -c -I$ROOTSYS/include/ PhotoDict.cc

Thanks in advance… I am stuck with this problem.
PhotoInfo.tar.gz (13 KB)

Though it is not important at this level, I forgot to mention that the aim is to add objects of this class to a TTree branch.

Hi,

please try with a “+” behind the pragma link statement in your LinkDef.hh, i.e.
#pragma link C++ class PhotoInfo+;

You should always put a “+” behind the class name in the pragma link statement, see the users guide.

Cheers, Axel.

Hi,
Thank you very much… It worked.
I always thought that the ‘+’ was an option. I have other programs running with involves the creation of a dictionary with a new class which doesn’t need the +. Why in this case is necessary? I would like to understand… Because I have really spent too much time with this problem.

Hi,

the “+” enables the superior dictionary, e.g. with schema evolution. It should be the default but for backward compatibility reasons it isn’t - so far. You should always use it. The users guide says so, too, so this is not a secret.

The fact that the “+” is needed in your case is because the code generated by the dictionary without “+” is buggy. And instead of me fixing the bug you now have a better dictionary :slight_smile:

Cheers, Axel.