Re: [CINT] FW: [ROOT] ROOT and STL

From: Masaharu Goto (MXJ02154@nifty.ne.jp)
Date: Thu Aug 29 2002 - 03:29:57 MEST


Hello Sam,

It looks that this is not a STL/CINT problem, but a storage
problem.  In terms of CINT and STL, both script works as
expected, I think.  Only difference is that 'vector<int> myv'
is in global scope or local scope.  Will you try having myv in
the global scope?  I could not run this script due to some other
reason and could not try this.

Thank you
Masaharu Goto


#include <vector>

vector<int> myv;

test() { 

  // vector<int> myv;

   for(int i=0; i<100; i++) {
      myv.push_back(i);
   }

  TGraph myg( myv.size() , (int*) &(myv[0]) , (int*) &(myv[0]) );
  myg.Draw("A*");
 
 }
----- Original Message ----- 
From: "Philippe Canal" <pcanal@fnal.gov>
To: "Cint" <cint@pcroot.cern.ch>
Sent: Thursday, August 29, 2002 3:37 AM
Subject: [CINT] FW: [ROOT] ROOT and STL


> 
> 
> -----Original Message-----
> From: owner-roottalk@pcroot.cern.ch
> [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Sam Waldman
> Sent: Wednesday, August 28, 2002 12:35 PM
> To: roottalk@pcroot.cern.ch
> Subject: [ROOT] ROOT and STL
> 
> 
> 
> Hi folks,
> 
> I realize STL and CINT aren't necessarily supposed to play nice
> together,  but I have managed to get it to work,  sort of.  This  script
> works:
> 
> /*******  Working Script -- test.c ***********/
> {
> 
> #include <vector>
> vector<int> myv;
> 
> for(int i=0; i<100; i++) {
>   myv.push_back(i);
> }
> 
> TGraph myg( myv.size() , (int*) &(myv[0]) , (int*) &(myv[0]) );
> myg.Draw("A*");
> 
> }
> 
> // end of script
> 
> And this script doesn't work:
> 
> /******** Broken Script -- test.c **************/
> 
> #include <vector>
> 
> test() {
> 
> vector<int> myv;
> 
> for(int i=0; i<100; i++) {
>   myv.push_back(i);
> }
> 
> TGraph myg( myv.size() , (int*) &(myv[0]) , (int*) &(myv[0]) );
> myg.Draw("A*");
> 
> }
> 
> // end of script
> 
> This script does a variety of bad things.
> Aside from the general fact that this isn't the prettiest code
> ever seen,  and STL and CINT don't work together, is there something I am
> doing wrong?
> 
> Thanks for the help,
> 
> sam
> 
> 
> 



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