Using std::map in a macro

Hi all,

I’m sure this question must have been answered somewhere, but I cannot find anything from a Google search or a search of these forums.

I’m trying to use std::map in a macro that I wrote. I want the keys of the map to be of type TString and the values to be of type TGraph*. I have a function that takes a bunch of parameters, creates a new TGraph*, and returns the TGraph*.

I try to return the function and place the the returned value into my std::map, but I keep getting segmentation violations whenever I run the code. I’ve read things about having to tell the root cint to recognize parts of the standard library, but I’m not sure how to do this. When I open cint I type "include ", which seems to deal with removing the symbol not found errors.

Anyway, I’ve attached a small program that reproduces this problem. I’m not sure if the problem is directly attributing to using std::map or not, but I’ve had a lot of trouble just trying to create a std::map, so it seems that a lot of my troubles lie with that.

Thanks for any advice, and sorry if this has been asked and answered many times before.
test.C (501 Bytes)

Hi,

Beside the fact that the #include is indeed required, CINT can not yet handle properly stl container of objects. So you will need to generate the dictionary for the map (see below) or simply compile your script via ACLiCroot [] .L test.C+

Cheers,
Philippe.

With the file loader.C://File loader.C #include <map> #include "TString.h" #include "TGraph.h" #pragma link C++ class map<TString,TGraph*>;create and load the dictionary by simply doing:root [] .L loader.C+

Hi Philippe,

I used the method of generating the dictionary for the class, and this seems to work fine. The method used to generate the dictionary files seems to be interesting, and I’ll definitely look into that some more if I have similar problems in the future.

Thanks for the help!

Dan