Re: [ROOT] STL in ROOT 4.00/03

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Apr 15 2004 - 08:45:38 MEST


Ralf,

Thanks for reporting this problem.

A fix from Philippe is now in CVS.

Rene Brun

Ralf Ehrlich wrote:
> 
> Hello!
> 
> I tried to compile the following code with the new ROOT version 4.00/03:
> 
> =======================================================
> STLMapStoragePolicy.h
> -------------------------------------------------------
> #ifndef STLMAPPOLICY_H
> #define STLMAPPOLICY_H
> 
> #include <string>
> #include <map>
> 
> using namespace std;
> template <class ElementType> class STLMapStoragePolicy
> {
>   public:
>   typedef string KeyType;
>   typedef map<KeyType,ElementType> map_type;
> 
>   private:
>   map_type map_;
> };
> 
> #endif
> 
> =======================================================
> Track.h
> -------------------------------------------------------
> #include "STLMapStoragePolicy.h"
> #include <TObject.h>
> 
> class Track : public STLMapStoragePolicy<int>
> {
>   public:
>   Track() {;}
>   virtual ~Track() {;}
> 
>   ClassDef(Track,1);
> };
> 
> =======================================================
> LinkDef.h
> -------------------------------------------------------
> #ifdef __CINT__
> 
> #pragma link C++ class Track+;
> #pragma link C++ class STLMapStoragePolicy<int>+;
> 
> #endif
> 
> =======================================================
> Makefile
> -------------------------------------------------------
> libdataclasses.so:     dataclassesDict.o
>                 g++ -shared -O dataclassesDict.o -o libdataclasses.so
> $(EXPLLINKLIBS)
>                 @echo "libdataclasses.so done"
> 
> dataclassesDict.o:       dataclassesDict.cxx
>         @echo "Generating dataclassesDict.o..."
>         g++ -O -Wall -fPIC $(shell root-config --cflags) -c
> dataclassesDict.cxx
> 
> dataclassesDict.cxx:
>         @echo "Generating dictionary dataclassesDict.cxx..."
>         @rootcint -f dataclassesDict.cxx -c STLMapStoragePolicy.h Track.h
> LinkDef.h
> 
> =======================================================
> 
> This leads to the error message:
> 
> Generating dictionary dataclassesDict.cxx...
> Error: Too many template arguments FILE: LINE:0
> rootcint: utils/src/RStl.cxx:222: void ROOT::RStl::WriteStreamer(FILE*,
> G__ClassInfo&): Assertion `0' failed.
> make: *** [dataclassesDict.cxx] Aborted (core dumped)
> make: *** Deleting file `dataclassesDict.cxx'
> 
> I have tried the same code with ROOT version 3.10 and it compiled it
> without error.
> 
> A way around it for version 4.00 is replacing
>     map_type map_;    by    map<string,ElementType> map_;
> in the private part of STLMapStoragePolicy.
> The same problem occurs with STL vectors.
> 
> What is the reason for this behavior?
> 
> Thanks for looking.
> Ralf



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