From 771b58f58786d3f176a23b10be9db2b937491584 Mon Sep 17 00:00:00 2001
From: Guilherme Amadio <amadio@cern.ch>
Date: Fri, 8 Dec 2017 15:04:20 +0100
Subject: [PATCH] Replace deprecated std::bind2nd with equivalent code

Removed in C++17. No functionality change intended.
---
 hist/hist/src/TKDE.cxx             | 3 ++-
 math/mathcore/src/GoFTest.cxx      | 6 ++++--
 misc/memstat/inc/TMemStatHelpers.h | 2 +-
 net/glite/src/TGLite.cxx           | 6 +++---
 tmva/tmva/src/MethodFDA.cxx        | 3 ---
 tmva/tmva/src/RuleFitParams.cxx    | 6 ++++--
 6 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/hist/hist/src/TKDE.cxx b/hist/hist/src/TKDE.cxx
index 2d0d39c7c8e..0771da51c77 100644
--- a/hist/hist/src/TKDE.cxx
+++ b/hist/hist/src/TKDE.cxx
@@ -720,7 +720,8 @@ void TKDE::TKernel::ComputeAdaptiveWeights() {
    }
    Double_t kAPPROX_GEO_MEAN = 0.241970724519143365; // 1 / TMath::Power(2 * TMath::Pi(), .5) * TMath::Exp(-.5). Approximated geometric mean over pointwise data (the KDE function is substituted by the "real Gaussian" pdf) and proportional to sigma. Used directly when the mirroring is enabled, otherwise computed from the data
    fKDE->fAdaptiveBandwidthFactor = fKDE->fUseMirroring ? kAPPROX_GEO_MEAN / fKDE->fSigmaRob : std::sqrt(std::exp(fKDE->fAdaptiveBandwidthFactor / fKDE->fData.size()));
-   transform(weights.begin(), weights.end(), fWeights.begin(), std::bind2nd(std::multiplies<Double_t>(), fKDE->fAdaptiveBandwidthFactor));
+   transform(weights.begin(), weights.end(), fWeights.begin(),
+             std::bind(std::multiplies<Double_t>(), std::placeholders::_1, fKDE->fAdaptiveBandwidthFactor));
    //printf("adaptive bandwidth factor % f weight 0 %f , %f \n",fKDE->fAdaptiveBandwidthFactor, weights[0],fWeights[0] );
 }
 
diff --git a/math/mathcore/src/GoFTest.cxx b/math/mathcore/src/GoFTest.cxx
index a6575e0ca72..f5badbbe241 100644
--- a/math/mathcore/src/GoFTest.cxx
+++ b/math/mathcore/src/GoFTest.cxx
@@ -670,7 +670,8 @@ void GoFTest::AndersonDarling2SamplesTest(Double_t& pvalue, Double_t& testStat)
       for (std::vector<Double_t>::iterator data = z.begin(); data != endUnique; ++data) {
          UInt_t n = std::count(fCombinedSamples.begin(), fCombinedSamples.end(), *data);
          h.push_back(n);
-         H.push_back(std::count_if(fCombinedSamples.begin(), fCombinedSamples.end(), bind2nd(std::less<Double_t>(), *data)) + n / 2.);
+         H.push_back(std::count_if(fCombinedSamples.begin(), fCombinedSamples.end(),
+                     std::bind(std::less<Double_t>(), std::placeholders::_1, *data)) + n / 2.);
       }
       std::cout << "time for H";
       w.Print();
@@ -679,7 +680,8 @@ void GoFTest::AndersonDarling2SamplesTest(Double_t& pvalue, Double_t& testStat)
       for (UInt_t i = 0; i < nSamples; ++i) {
          for (std::vector<Double_t>::iterator data = z.begin(); data != endUnique; ++data) {
             UInt_t n = std::count(fSamples[i].begin(), fSamples[i].end(), *data);
-            F[i].push_back(std::count_if(fSamples[i].begin(), fSamples[i].end(), bind2nd(std::less<Double_t>(), *data)) + n / 2.);
+            F[i].push_back(std::count_if(fSamples[i].begin(), fSamples[i].end(),
+                           std::bind(std::less<Double_t>(), std::placeholders::_1, *data)) + n / 2.);
          }
       }
       std::cout << "time for F";
diff --git a/misc/memstat/inc/TMemStatHelpers.h b/misc/memstat/inc/TMemStatHelpers.h
index 87b5ef16ecf..10c59621ef4 100644
--- a/misc/memstat/inc/TMemStatHelpers.h
+++ b/misc/memstat/inc/TMemStatHelpers.h
@@ -48,7 +48,7 @@ namespace Memstat {
 
       iterator_t iter(&_Container);
       iterator_t found(
-         std::find_if(iter.Begin(), iterator_t::End(), bind2nd(SFind_t(), _ToFind))
+         std::find_if(iter.Begin(), iterator_t::End(), std::bind(SFind_t(), std::placeholders::_1, _ToFind))
       );
       return ((!(*found)) ? -1 : std::distance(iter.Begin(), found));
    }
diff --git a/net/glite/src/TGLite.cxx b/net/glite/src/TGLite.cxx
index 2735fa36eab..389a59b6f0c 100644
--- a/net/glite/src/TGLite.cxx
+++ b/net/glite/src/TGLite.cxx
@@ -202,7 +202,7 @@ struct SAddMapElementFunc: public binary_function<SLFCFileInfo_t, TGLiteResult*,
       // Add replication info
       for_each(_lfc_info.m_LFCRepInfoVector.begin(),
                _lfc_info.m_LFCRepInfoVector.end(),
-               bind2nd(SAddRepInfo(), map));
+               std::bind(SAddRepInfo(), std::placeholders::_1, map));
 
       _Result->Add(map);
       return true;
@@ -321,7 +321,7 @@ TGridResult* TGLite::Query(const char *_path, const char *_pattern /*= NULL*/, c
 
    // Creating ROOT containers to store the resultset
    TGLiteResult *result = new TGLiteResult();
-   for_each(container.begin(), container.end(), bind2nd(SAddMapElementFunc(), result));
+   for_each(container.begin(), container.end(), std::bind(SAddMapElementFunc(), std::placeholders::_1, result));
 
    return result;
 }
@@ -369,7 +369,7 @@ TGridResult* TGLite::Ls(const char *_ldn, Option_t* /*options*/, Bool_t /*verbos
 
    // Creating a ROOT container to store the resultset
    TGLiteResult *result = new TGLiteResult();
-   for_each(container.begin(), container.end(), bind2nd(SAddMapElementFunc(), result));
+   for_each(container.begin(), container.end(), std::bind(SAddMapElementFunc(), std::placeholders::_1, result));
 
    return result;
 }
diff --git a/tmva/tmva/src/MethodFDA.cxx b/tmva/tmva/src/MethodFDA.cxx
index 0e540f912da..c9d51208a24 100644
--- a/tmva/tmva/src/MethodFDA.cxx
+++ b/tmva/tmva/src/MethodFDA.cxx
@@ -596,9 +596,6 @@ void TMVA::MethodFDA::CalculateMulticlassValues( const TMVA::Event*& evt, std::v
       values.push_back( value );
       sum += value;
    }
-
-   //    // normalize to sum of value (commented out, .. have to think of how to treat negative classifier values)
-   //    std::transform( fMulticlassReturnVal.begin(), fMulticlassReturnVal.end(), fMulticlassReturnVal.begin(), bind2nd( std::divides<float>(), sum) );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/tmva/tmva/src/RuleFitParams.cxx b/tmva/tmva/src/RuleFitParams.cxx
index c2aa58d10ec..6824d0c209c 100644
--- a/tmva/tmva/src/RuleFitParams.cxx
+++ b/tmva/tmva/src/RuleFitParams.cxx
@@ -1079,11 +1079,13 @@ Double_t TMVA::RuleFitParams::ErrorRateRocRaw( std::vector<Double_t> & sFsig,
    //
    for (Int_t i=0; i<np; i++) {
       fcut = minf + df*Double_t(i);
-      indit = std::find_if( sFsig.begin(), sFsig.end(), std::bind2nd(std::greater_equal<Double_t>(), fcut));
+      indit = std::find_if(sFsig.begin(), sFsig.end(),
+                           std::bind(std::greater_equal<Double_t>(), std::placeholders::_1, fcut));
       nesig = sFsig.end()-indit; // number of sig accepted with F>cut
       if (TMath::Abs(pnesig-nesig)>0) {
          npok++;
-         indit = std::find_if( sFbkg.begin(), sFbkg.end(), std::bind2nd(std::greater_equal<Double_t>(), fcut));
+         indit = std::find_if(sFbkg.begin(), sFbkg.end(),
+                              std::bind(std::greater_equal<Double_t>(), std::placeholders::_1, fcut));
          nrbkg = indit-sFbkg.begin(); // number of bkg rejected with F>cut
          rejb = Double_t(nrbkg)/Double_t(nbkg);
          effs = Double_t(nesig)/Double_t(nsig);
-- 
GitLab