Problem 9 - Hash template (using STL option) collides with own classes having 'Hash' members
Summary: Hash template (using STL option) collides with own classes having 'Hash' members
Status: CLOSED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: global (show other problems)
Version: 0.1
Hardware: PC Linux
: P2 normal
Assignee: Gabriele Cosmo
URL:
Depends on:
Blocks:
 
Reported: 1999-08-30 08:53 CEST by V.Hejny
Modified: 2002-04-17 04:38 CEST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description V.Hejny 1999-08-30 08:53:35 CEST
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.
Comment 1 Gabriele Cosmo 1999-09-08 06:09:59 CEST
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.
Comment 2 Gabriele Cosmo 1999-09-14 06:08:59 CEST
Fixed in current HEAD of repository. Will be included in next release.