I realized I could just use TObjArrays instead - someone pointed that out. So I gave up on vectors. And the push_back worked for the first 2 objects always - just not on the third... Dave On Wed, 16 Jan 2002, Fons Rademakers wrote: Hi David, does it work if you do: vector<TString> hts; TString nname(mr->GetName()) hts.push_back(nname); Cheers, Fons. David R. Relyea wrote: > Push_back from stl::vector is giving me problems. If I run this code: > > #include <vector> > (many other includes) > > void something() { > > mfile = TMapFile::Create("e.map"); > > // Get all data entries in file > > TMapRec *mr = mfile->GetFirst(); > > vector< TString* > hts; > > while (mfile->OrgAddress(mr)) { > TString boo = mr->GetClassName(); > if(boo.Contains("TH1F")) { > TString* nname=new TString(mr->GetName()); > hts.push_back(nname); > cout << boo << "\t" << nname->Data() << endl; > } > mr = mr->GetNext(); > } > } > > If I comment out the line > > hts.push_back(nname); > > , this runs perfectly well (in CINT) over my entire TMapfile. However, if > I uncomment that line (as shown) and run this in CINT, it seg faults after > two iterations of the while loop, specifically on the > > TString boo = mr->GetClassName() > > . Is this a problem CINT has with vectors (which I doubt), or does this > have something to do with how TMapFile handles pointers? Any advice would > be appreciated. Thanks. > > David Relyea > > -- Org: CERN, European Laboratory for Particle Physics. Mail: 1211 Geneve 23, Switzerland E-Mail: Fons.Rademakers@cern.ch Phone: +41 22 7679248 WWW: http://root.cern.ch/~rdm/ Fax: +41 22 7679480
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:39 MET