From f5a72f273a1c5a3ff32e086f4046b6690c908c11 Mon Sep 17 00:00:00 2001
From: Gerhard Raven <gerhard.raven@nikhef.nl>
Date: Sat, 29 Jul 2017 22:48:56 +0200
Subject: [PATCH] Remove deprecated (and removed in C++17)
 std::{unary,binary}_function

---
 .../src/PersistencySvc/PersistencySvc.h       |  8 ++++----
 GaudiCoreSvc/src/JobOptionsSvc/Property.h     |  4 ++--
 GaudiKernel/GaudiKernel/DirSearchPath.h       |  2 +-
 GaudiKernel/GaudiKernel/FindByMassRange.h     |  6 +-----
 GaudiKernel/GaudiKernel/Hash.h                | 20 +++++++++----------
 5 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/GaudiCommonSvc/src/PersistencySvc/PersistencySvc.h b/GaudiCommonSvc/src/PersistencySvc/PersistencySvc.h
index 04d6589d53..d9027ea3f6 100644
--- a/GaudiCommonSvc/src/PersistencySvc/PersistencySvc.h
+++ b/GaudiCommonSvc/src/PersistencySvc/PersistencySvc.h
@@ -81,14 +81,14 @@ protected:
   };
   typedef std::map<long, ServiceEntry> Services;
   /*
-    class SvcTest : public std::unary_function<ServiceEntry, bool>   {
+    class SvcTest final {
     public:
       SvcTest(long test) : m_test(test)    {
       }
-      bool operator()( const ServiceEntry& testee )  {
-          return m_test == testee.svcType() ? true : false;
+      bool operator()( const ServiceEntry& testee ) const {
+          return m_test == testee.svcType();
       }
-    protected:
+    private:
          long m_test;
     };
   */
diff --git a/GaudiCoreSvc/src/JobOptionsSvc/Property.h b/GaudiCoreSvc/src/JobOptionsSvc/Property.h
index 74d7da714a..e465f04165 100644
--- a/GaudiCoreSvc/src/JobOptionsSvc/Property.h
+++ b/GaudiCoreSvc/src/JobOptionsSvc/Property.h
@@ -17,13 +17,13 @@ class Property final {
 // ----------------------------------------------------------------------------
  public:
 // ----------------------------------------------------------------------------
-	struct LessThen : std::binary_function<Property, Property, bool> {
+	struct LessThen {
 		bool operator()(const Property& first, const Property& second) const {
 			return first.FullName() < second.FullName();
 		}
 	};
 
- class Equal : std::unary_function<Property, bool>  {
+ class Equal {
   public:
     Equal(const std::string& short_name): short_name_(short_name){}
     bool operator()(const Property& property) const {
diff --git a/GaudiKernel/GaudiKernel/DirSearchPath.h b/GaudiKernel/GaudiKernel/DirSearchPath.h
index d2c2f6d57a..68e0d5449d 100644
--- a/GaudiKernel/GaudiKernel/DirSearchPath.h
+++ b/GaudiKernel/GaudiKernel/DirSearchPath.h
@@ -57,7 +57,7 @@ public:
 private:
   //
   /// @class eqPath compare paths name
-  struct eqPath : public std::unary_function<const path&,bool> {
+  struct eqPath {
     eqPath(const path& ref) : m_ref(ref) {}
     bool operator() (const path& p) const {
       return p.string() == m_ref.string();
diff --git a/GaudiKernel/GaudiKernel/FindByMassRange.h b/GaudiKernel/GaudiKernel/FindByMassRange.h
index 7d84bbd8df..7ea46fa3ce 100644
--- a/GaudiKernel/GaudiKernel/FindByMassRange.h
+++ b/GaudiKernel/GaudiKernel/FindByMassRange.h
@@ -8,8 +8,6 @@
 
 
 /** @class FindByMassRange FindByMassRange.h GaudiKernel/FindByMassRange.h
-    The function object must be derived from
-    std::unary_function< IParticlePropertySvc::value_type ,bool >
     IParticlePropertySvc::value_type is a typedef that defines the
     internal service storage type that is returned when an iterator
     is dereferenced. In this case it corresponds to
@@ -17,8 +15,6 @@
     stores all its data in a map. The string will be the map's key
     (usually the particle name) and the pointer is a pointer to the
     ParticleProperty object.
-    The bool template argument states that operator() returns
-    true or false.
 
     The data is accessed in the following manner:
     const IParticlePropertySvc::value_type& pp_ref;
@@ -27,7 +23,7 @@
 
     @author Ian Last
 */
-class GAUDI_API FindByMassRange: public std::unary_function< ParticleProperty* ,bool > {
+class GAUDI_API FindByMassRange {
 
 public:
 
diff --git a/GaudiKernel/GaudiKernel/Hash.h b/GaudiKernel/GaudiKernel/Hash.h
index 413e986259..a60a75258e 100644
--- a/GaudiKernel/GaudiKernel/Hash.h
+++ b/GaudiKernel/GaudiKernel/Hash.h
@@ -5,7 +5,8 @@
 // ============================================================================
 // STD & STL
 // ============================================================================
-#include <functional>
+#include <cstddef>
+#include <numeric>
 // ============================================================================
 // Boost
 // ============================================================================
@@ -25,16 +26,15 @@ namespace GaudiUtils
   //  }
   //  @endcode
   template <class T>
-  struct GenericHash : public std::unary_function<T,std::size_t>
+  struct GenericHash
   {
     // ========================================================================
     /// the generic hash function
     inline std::size_t operator() ( const T& key ) const {
-      std::size_t res = 0 ;
-      std::size_t len = sizeof(T) ;
       const char* p = reinterpret_cast<const char*>( &key );
-      while( len-- ) { res = ( res << 1 ) ^ *p; ++p; }
-      return res;
+      return std::accumulate( p, p + sizeof(T), std::size_t{0},
+                              [](std::size_t res, const char& c)
+                              { return ( res << 1 ) ^ c; } );
     }
     // ========================================================================
   };
@@ -93,7 +93,7 @@ namespace GaudiUtils
    * @date 2005-10-07
    */
   template <class T>
-  struct Hash : public std::unary_function<T,std::size_t>
+  struct Hash
   {
     // ========================================================================
     /// the hash-function
@@ -103,7 +103,7 @@ namespace GaudiUtils
   // ==========================================================================
   /// the partial specialization for pointers
   template <class T>
-  struct Hash<T*> : public std::unary_function<const T*,std::size_t>
+  struct Hash<T*>
   {
     // ========================================================================
     /// the hash-function
@@ -113,7 +113,7 @@ namespace GaudiUtils
   // ==========================================================================
   /// generic specialization for arrays
   template <class T, unsigned N>
-  struct Hash<T(&)[N]> : public std::unary_function<T(&)[N],std::size_t>
+  struct Hash<T(&)[N]>
   {
     // ========================================================================
     /// the hash-function
@@ -123,7 +123,7 @@ namespace GaudiUtils
   } ;
   /// generic specialization for arrays
   template <class T, unsigned N>
-  struct Hash<const T(&)[N]> : public std::unary_function<const T(&)[N],std::size_t>
+  struct Hash<const T(&)[N]>
   {
     // ========================================================================
     /// the hash-function
-- 
GitLab