Where is the dictionary for basic_string?

If I do the following from the command line:

TClass *c = TClass::GetClass("basic_ostream<char,char_traits<char> >"); c->Property();

I get a reasonable number for the Property. However, if I do the following in a C++ program I’ve built:

[code] int nargs = 2;
char *argv[2];
argv[0] = “t_Template_Class.exe”;
argv[1] = “-b”;
TApplication *app = new TApplication (“t_Template_Class”, &nargs, argv);

TClass *c = TClass::GetClass(“basic_ostream<char,char_traits >”);
cout << "Proprety() = " << c->Property() << endl;[/code]

I get zero for property, but probably more importantly I also get the error message:

Warning in <TClass::TClass>: no dictionary for class basic_ostream<char,char_traits<char> > is available OBJ: TClass basic_ostream<char,char_traits<char> >

I’m guessing I need to do something like gSystem->Load(“blah”) in order to get this to work properly, but I can’t figure out which library I need to fetch. And my usual trick of doing c->GetSharedLibs() returns “” for this class - so I can’t figure it out that way either. Further, making sure the 4 libraries that are loaded when I do gSystem->GetLibraries() (Core, Cint, Mathcore, and Rint) doesn’t make the above error go away.

i’m running ROOT v5.19/4.

Many thanks!

Hi Gordon,

that class is known to CINT under its typedef name “ostream”. So TClass::GetClass(“ostream”)->Property() gets you there.

Pretty surprising subject, by the way :slight_smile:

Cheers, Axel.

The subject was actally correct – that was the one that I wanted to write about. However, that one I cut/pasted in was a different template I was having similar problems with. Also, I’m on owl shift here at DZERO, so I’m not really thinking straight. :slight_smile:

This is weird – because there are places in the type system where I get back the full template specification. How does root know the two are the same? What trick can I use to figure that out for myself?

And, finally, does your answer explain the behavior I see? Why it works in root but not in my own compiled porgram?



The dictionary for iostream is properly setup by loading (into CINT) the iostream header. Hence in your application use:gROOT->ProcessLine("#include <iostream>");In the ROOT executable this is done by the object of type TRint (which inherits from TApplication).


Perfect. Thanks, I’ll try that out.