From a3b006a809e024418990469864ad09679c21ec1c Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Sun, 1 Dec 2019 13:31:33 +0100 Subject: [PATCH] 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. --- hurricane/src/hurricane/hurricane/DBo.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hurricane/src/hurricane/hurricane/DBo.h b/hurricane/src/hurricane/hurricane/DBo.h index 4a4096d4..5c28b52f 100644 --- a/hurricane/src/hurricane/hurricane/DBo.h +++ b/hurricane/src/hurricane/hurricane/DBo.h @@ -97,7 +97,8 @@ namespace Hurricane { mutable set _propertySet; public: struct CompareById : public std::binary_function { - inline bool operator() ( const DBo* lhs, const DBo* rhs ) const; + template + 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 + inline bool DBo::CompareById::operator() ( const Key* lhs, const Key* rhs ) const { return ((lhs)?lhs->getId():0) < ((rhs)?rhs->getId():0); }