| Summary: | Hash template (using STL option) collides with own classes having 'Hash' members | ||
|---|---|---|---|
| Product: | Geant4 | Reporter: | V.Hejny |
| Component: | global | Assignee: | Gabriele Cosmo <Gabriele.Cosmo> |
| Status: | CLOSED FIXED | ||
| Severity: | normal | CC: | V.Hejny |
| Priority: | P2 | ||
| Version: | 0.1 | ||
| Hardware: | PC | ||
| OS: | Linux | ||
Problem analysed. Will be fixed in next patch or major release.
NB: concerning the clash with ROOT, a similar fix would be needed
in ROOT as well since it pollutes the global scope; either by
using a proper namespace or changing the global function name
for Hash.
Fixed in current HEAD of repository. Will be included in next release. |
The problem first arose when using ROOT in the GEANT4 envionment to produce an output file, but it is not limited to this special case. There, e.g., the class TString contains two global functions inline unsigned Hash(const TString& s) { return s.Hash(); } inline unsigned Hash(const TString *s) { return s->Hash(); } In the file geant4.0.1/source/global/STLInterface/rw/tvhdict.h there is a definition for a template class: template < class K > class Hash { public: Hash(unsigned (*f)( const K& )=HashDefault):fhashfun(f){} unsigned operator()( const K& key ) const; private: unsigned (*fhashfun)( const K& ); This makes it impossible to use the two classes together. When using Tools.h++ this was no problem. Since this is special GEANT4 class this class should be called G4Hash and not Hash.