RE: [ROOT] Template class/function in ROOT interpreter?

From: Philippe Canal (pcanal@fnal.gov)
Date: Sat Jul 27 2002 - 17:03:37 MEST


Hi Pierre,

I do not think that templated member functions (of templated class) are
fully implement in CINT.  However you can easily solve the problem by
compiling you macro using ACLiC.
I.e. instead of doing:
	.L QIO.cxx
do
	.L QIO.cxx++

You can then using the full C++ range that you compiler support.
Cheers,
Philippe

-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Pierre-Luc Drouin
Sent: Friday, July 26, 2002 5:08 PM
To: roottalk@pcroot.cern.ch
Subject: [ROOT] Template class/function in ROOT interpreter?


Hello, i'm trying use a QIO<U> (U being the typename) template class that
has a TryCast(W* uptr) template member function in the ROOT interpreter.
Here is a part of my QIO.h file:

template <typename U> class QIO
{
  private:
   template <typename V,typename W> V* TryCast(W* uptr) const;
};

#include "QIO.cxx"


Here is a part of my QIO.cxx file:

template <typename U> template <typename V,typename W> V*
QIO<U>::TryCast(W* uptr) const
{
  V* tobuf=dynamic_cast<V*>(uptr);
  if(!tobuf){
    cout << "ERROR:'" << typeid(W).name() << "' is not derived from '" <<
typeid(V).name() << "'\n";
    throw 1;
  }
  return tobuf;
}

When I type in the ROOT interpreter:

#include "QIO.h"
QIO<TH1F> a;

I get:
no such template V* QIO<TH1F> FILE:QIO.cxx LINE:48
Syntax error FILE:QIO.cxx LINE:48
*** Interpreter error recovered ***

Line 48 is the first line i've pasted for the file QIO.cxx

When I compile my code, everything works perfectly, but it doesn't work
with the ROOT interpreter.

How can I make it to work?

Pierre-Luc Drouin
SNO, Carleton University



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:01 MET