Template function in rootcint compiled library

Hi,

I’ve got a little library that I compile (if necessary) and load when ROOT starts up. I’m trying to define a templated function but can’t seem to make it visible from the interpreter:

#ifndef BLAH_H
#define BLAH_H
/* ... */
template<class T> void set_lc(std::vector<T*>& v, Color_t x);

template<class T> void set_lc(std::vector<T*>& v, Color_t x){
  for(uint i=0; i<v.size(); i++) v[i]->SetLineColor(x);
}

#endif

The library compiles but the function doesn’t show up in the interpreter. I tried adding:

#pragma link C++ function set_lc<TH1>(std::vector<TH1*>,Color_t);

which also doesn’t work. I’ve tried a number of variations on this theme, some of which fail to compile. Is the use of templated functions supported under my version of ROOT (4.04.02f)? If so, can someone find my error or suggest the necessary changes? I looked in the user manual and at the CINT site but cannot seem to find the necessary information.

As an aside, I have a number of pragmas in the library:

#pragma link C++ class vector<TH1*>;
#pragma link C++ class vector<TAttLine*>;
#pragma link C++ class vector<TAttFill*>;
/* ... */

when I compile the library (with rootcint) I get a message:
/home/kordosky/macros/blah.h:23: warning: ignoring #pragma link C

But, obviously it is not ignoring the pragmas because with them I can instantiate the corresponding classes and without them I cannot. Thus, I presume the warning is spurious and if so I wonder if it can please be turned off.

mike

Hi Mike,

This was a problem in the CINT parsing that was solved last week!
So please use ROOT v5.06/00 (there is no work-around :frowning: ).

Also instead of #pragma link C++ function set_lc<TH1>(std::vector<TH1*>,Color_t);use#pragma link C++ function set_lc(std::vector<TH1*>,Color_t);
and to prevent [quote]/home/kordosky/macros/blah.h:23: warning: ignoring #pragma link C[/quote]use#ifdef __MAKECINT__ #pragma link ... #endif
Cheers,
Philippe

[quote=“pcanal”]Hi Mike,

This was a problem in the CINT parsing that was solved last week!
So please use ROOT v5.06/00 (there is no work-around :frowning: ).
[/quote]

Ahh, drat. Well, I’ll switch to root 5.06 as soon as the rest of my experiment does. Certainly no sooner than the next “production” release. For now I guess I’ll have to live without the feature.

Thanks, this works like a charm. I had tried something like this in the past but wasn’t using the right define. Probably I was trying CINT.

mike