Saturday, February 14, 2009

Using CINT - C/C++ Interpreter - An experiment with vector

Let do something with vector
cint.exe> L vector
cint.exe> {vector<int> temps;}
cint.exe> {temps.push_back(6);}
cint.exe> {temps.push_back(4);}
cint.exe> {temps.push_back(5);}
cint.exe> {temps.size();}
(const unsigned int)3
cint.exe> {temps[0];}
(int)6
cint.exe> {temps[1];}
(int)4
cint.exe> {temps[2];}
(int)5
cint.exe>
So it works well, now there is time to try some algorithm
cint.exe> L algorithm
cint.exe> {sort(temps.begin(),temps.end());}
Error: Template Function value_type(first) is not defined in current scope  algo.h(735)
!!!Dictionary position rewound... !!!Error recovered!!!
cint.exe>
It seems that there is some problem with STL lib coming with CINT in Windows. Looking at STL header files, I found that Function value_type is declared in _iterator.h surrounded by a condition for whatever reason
#if (G__GNUC>=3)

#if (G__GNUC_VER>=3001) 
...
template  
inline T* value_type(const vector::iterator&) {return (T*)(0);}
..
#endif
#endif
To fix it is fairly simple
d:\cint-5.16.19\cint.exe
cint : C/C++ interpreter  (mailing list 'cint@root.cern.ch')
   Copyright(c) : 1995~2005 Masaharu Goto (gotom@hanno.jp)
   revision     : 5.16.19, March 16, 2007 by M.Goto

No main() function found in given source file. Interactive interface started.
'h':help, 'q':quit, '{statements;}' or 'p [expr]' to evaluate

cint.exe> {#define G__GNUC 4}
cint.exe> {#define G__GNUC_VER 4001}
cint.exe> L vector
cint.exe> L algorithm
cint.exe> {vector<int> temps;}
cint.exe> {temps.push_back(6);}
cint.exe> {temps.push_back(4);}
cint.exe> {temps.push_back(5);}
cint.exe> {temps.size();}
(const unsigned int)3
cint.exe> {temps[0];}
(int)6
cint.exe> {temps[1];}
(int)4
cint.exe> {temps[2];}
(int)5
cint.exe> {sort(temps.begin(),temps.end());}
cint.exe> {temps[0];}
(int)4
cint.exe> {temps[1];}
(int)5
cint.exe> {temps[2];}
(int)6
cint.exe>

No comments: