RE: [ROOT] TGraph vectors

From: Philippe Canal (pcanal@fnal.gov)
Date: Wed Mar 24 2004 - 22:32:32 MET


Hi,

You need to generate the dictionary for vector<TGraph*>.

Just add at the end of your script:

#if defined(__MAKECINT__)
#pragma link C++ class vector<TGraph*>;
#endif

-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Matthew D Wood
Sent: Wednesday, March 24, 2004 1:13 PM
To: roottalk@pcroot.cern.ch
Subject: [ROOT] TGraph vectors


Hi.  I am using root version 3.10/02 and gcc version 2.96.  I have a
question with regard to the use of the STL class 'vector'.  Specifically I
have been using vectors of type TGraph*.  What I would like to do is to
compile a function that operates on a TGraph vector.  So a simple example
is:

#include <vector>
#include "TGraph.h"

int vec_size (vector< TGraph* > vgraph ) {
  cout << vgraph.size() << endl;
  return 0;
}

I compile this with:

root [0] .L vec_size.C+

and I get a library called vec_size_C.so.  However once this library is
loaded any vectors I create interactively don't seem to work properly --
even if I don't use the function I defined:

root [0] .L vec_size_C.so
root [1] #include<vector>
root [2] vector<TGraph*> vgr;
root [3] vgr.size()
Error: Can't call vector<TGraph*,allocator<TGraph*> >::size() in current
scope FILE:(tmpfile) LINE:1
Possible candidates are...
filename       line:size busy function type and name  (in
vector<TGraph*,allocator<TGraph*> >)
Error: Symbol vgr is not defined in current scope  FILE:(tmpfile) LINE:1
Error: Failed to evaluate vgr.size()Possible candidates are...
filename       line:size busy function type and name
*** Interpreter error recovered ***

The same commands work fine if I don't load the library.  Any idea what
I'm doing wrong here?  Thanks.

Matthew Wood



#################################################################
#################################################################
#################################################################
#####
#####
#####
#################################################################
#################################################################
#################################################################



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:06 MET