std::map not treated properly [message #7709] |
Wed, 21 January 2009 14:51 |
Bertram Kopf
Messages: 110 Registered: March 2006
|
continuous participant |
From: *ep1.ruhr-uni-bochum.de
|
|
Dear all,
I took a brief look over the code and I noticed that the usage of the std::map(s) are partly not treated in a correct way. In particular maps which contains pointers as a key are used without any compare operators.
Here are just two examples:
in recotasks/TrackFitStatTask.cxx: "std::map<CbmMCTrack*,int> mctruthmap;"
in emc/EmcData/PndEmcDigi.cxx: "std::map<PndEmcTwoCoordIndex*, PndEmcXtal*> ..."
In these cases the map uses the actual pointer values for the sorting. This results in a randomly ordered map which is in addition very error prone. It's also not possible to decide that two key pointers containing exactly the same thing are equal.
Therefore I would propose to define a base class/structure as a template which defines such "less" comparisons. In addition each key object has to have a "less" operator.
Best regards,
Bertram.
|
|
|