Add templates for derived Key in DBo::CompareById::oprator() [gcc 8].

* Change: In Hurricane::DBo::CompareById, starting from gcc 8, the compare
    function is checked inside the STL map<>/set<> so the lhs & rhs arguments
    are of the exact type of the Key, even excluding a base class.
      So now, in complement of the normal function, we provide a templated
    comparison functor in CompareById.
This commit is contained in:
Jean-Paul Chaput 2019-12-01 13:31:33 +01:00
parent 5ee4487d95
commit a3b006a809
1 changed files with 4 additions and 2 deletions

View File

@ -97,7 +97,8 @@ namespace Hurricane {
mutable set<Property*> _propertySet;
public:
struct CompareById : public std::binary_function<const DBo*,const DBo*,bool> {
inline bool operator() ( const DBo* lhs, const DBo* rhs ) const;
template<typename Key>
inline bool operator() ( const Key* lhs, const Key* rhs ) const;
};
};
@ -107,7 +108,8 @@ namespace Hurricane {
inline bool DBo::hasProperty () const { return !_propertySet.empty(); }
inline unsigned int DBo::getId () const { return _id; }
inline bool DBo::CompareById::operator() ( const DBo* lhs, const DBo* rhs ) const
template<typename Key>
inline bool DBo::CompareById::operator() ( const Key* lhs, const Key* rhs ) const
{ return ((lhs)?lhs->getId():0) < ((rhs)?rhs->getId():0); }