As discussed in the ROOT workshop, I've been working on STL dummy header files
for precompiling STL container classes. As a trial, I implemented a very simpl
e
interface to the STL containers and somehow it works on Linux2.0-egcs and
Windows95-VC++5.0. I'll copy cint5.13.95 with this feature to CERN. This
version of CINT will be exposed in a few days. It can take a little while to
have this integrated into ROOT, though.
The example is in $CINTSYSDIR/demo/makecint/stl directory. You can do
following.
// sample.h
#include <vector>
#include <list>
#include <string>
#include <map>
#include <deque>
using namespace std;
class A {
public:
vector<float> x;
list<float> y;
string z;
deque<float> b;
map<string,float> a;
};
#ifdef __MAKECINT__
#pragma link C++ nestedtypedefs;
#pragma link C++ nestedclasses;
#endif
----------------
$ makecint -mk makefile -dl sample.dll -H sample.h -cint -M0x10
$ make -f makefile
$ cint sample.dll
cint> { vector<float> a; map<string,float> b;}
cint> { a.push_back(1.23); b["PI"]=3.14; }
This time, STL dummy header has following limitations,
1) No default template arguments, Allocator and Compare
STL containers have Allocator and Compare classes as default arguments.
template<class T,class Allocator=allocator<T> > class vector { ... };
For simplicity, dummy header does not have those , for the time being.
template<class T> class vector { ... };
I guess, in most of the case this is not a problem for normal users.
You can use the vector as
vector<int> a;
but not as
vector<int,allocator<int> > a;
2) No iterator_tag resolution for generic algorithm
You can not use some of the STL algorithms which uses iterater_category(firs
t) distinction. There are some problems and I could not make an interface for
iterator_category() function template.
3) The implementation is not stable. Current implementation only allow some
of the only STL usage for vector, list, deque, map and string containers.
You may see warning messages or errors in many platforms.
Thank you
Masaharu Goto