Hi Lorenzo, it does understand it, it just can't do much with it. To be able to call it interactively, Cint needs to forward the call to one method. Now, which method would that be? As you know, a templated method might be 'instantiated' several times (i.e. there might be several versions of your method in the objects), depending on the call (its type) you use. And Cint can't generate one method wrapper for each possible type and class... So you need to specify the specializations you're going to use in your linkdef. See http://root.cern.ch/root/Cint.phtml?ref, search for template. It'll tell you what the new Cint does, but that allows you to see how it works. Read the Cint / rootcint doc for generic info on dictionaries and templates. Summary: you need to specify a #pragma link for each of the specializations you use (usually you just give the specialization of the class, but as you see you can also just give one method), and the templated method's code has to be inside the class definition (in place inline). Axel. > Hi, rooters. > > I need to use function templates. > Unfortunately, I can't use traditional compilation, so I have to work with > macros. Can my macro include template code? Why root's interpreter > (CINT???) does not understand something more complex, then > template<class T>void fun(T); > > just try to instantiate something like > template<class T> void fun(const TString &, T) (e.g. fun("lalala", 10)) > and you'll get an error message: > > Error: Function fun("lalala", 10) is not defined in current scope > FILE:t.C LINE:8 > >
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:16 MET