Eradicate all uses of std::bind()

Change-Id: I6e1ccf2d87b76142e6d519c1a288d03022e4d167
diff --git a/tools/chunks/catchunks/consumer.cpp b/tools/chunks/catchunks/consumer.cpp
index c1be8e8..ac83227 100644
--- a/tools/chunks/catchunks/consumer.cpp
+++ b/tools/chunks/catchunks/consumer.cpp
@@ -46,7 +46,7 @@
 
   m_discover->onDiscoverySuccess.connect([this] (const Name& versionedName) {
     m_pipeline->run(versionedName,
-                    [this] (const Data& data) { handleData(data); },
+                    FORWARD_TO_MEM_FN(handleData),
                     [] (const std::string& msg) { NDN_THROW(std::runtime_error(msg)); });
   });
   m_discover->onDiscoveryFailure.connect([] (const std::string& msg) {
diff --git a/tools/chunks/catchunks/data-fetcher.cpp b/tools/chunks/catchunks/data-fetcher.cpp
index 43d5076..baed34f 100644
--- a/tools/chunks/catchunks/data-fetcher.cpp
+++ b/tools/chunks/catchunks/data-fetcher.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2016-2019, Regents of the University of California,
+ * Copyright (c) 2016-2021, Regents of the University of California,
  *                          Colorado State University,
  *                          University Pierre & Marie Curie, Sorbonne University.
  *
@@ -85,9 +85,9 @@
 {
   m_nCongestionRetries = 0;
   m_pendingInterest = m_face.expressInterest(interest,
-                                             bind(&DataFetcher::handleData, this, _1, _2, self),
-                                             bind(&DataFetcher::handleNack, this, _1, _2, self),
-                                             bind(&DataFetcher::handleTimeout, this, _1, self));
+    [=] (auto&&... args) { handleData(std::forward<decltype(args)>(args)..., self); },
+    [=] (auto&&... args) { handleNack(std::forward<decltype(args)>(args)..., self); },
+    [=] (auto&&... args) { handleTimeout(std::forward<decltype(args)>(args)..., self); });
 }
 
 void
@@ -113,7 +113,7 @@
 
   if (m_isVerbose)
     std::cerr << "Received Nack with reason " << nack.getReason()
-              << " for Interest " << interest << std::endl;
+              << " for Interest " << interest << "\n";
 
   if (m_nNacks <= m_maxNackRetries || m_maxNackRetries == MAX_RETRIES_INFINITE) {
     Interest newInterest(interest);
@@ -162,7 +162,7 @@
     ++m_nTimeouts;
 
   if (m_isVerbose)
-    std::cerr << "Timeout for Interest " << interest << std::endl;
+    std::cerr << "Timeout for Interest " << interest << "\n";
 
   if (m_nTimeouts <= m_maxTimeoutRetries || m_maxTimeoutRetries == MAX_RETRIES_INFINITE) {
     Interest newInterest(interest);
diff --git a/tools/chunks/catchunks/discover-version.cpp b/tools/chunks/catchunks/discover-version.cpp
index 1efe3b2..e35fc21 100644
--- a/tools/chunks/catchunks/discover-version.cpp
+++ b/tools/chunks/catchunks/discover-version.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2016-2019, Regents of the University of California,
+ * Copyright (c) 2016-2021, Regents of the University of California,
  *                          Colorado State University,
  *                          University Pierre & Marie Curie, Sorbonne University.
  *
@@ -53,12 +53,13 @@
                       .setInterestLifetime(m_options.interestLifetime);
 
   m_fetcher = DataFetcher::fetch(m_face, interest,
-                                 m_options.maxRetriesOnTimeoutOrNack, m_options.maxRetriesOnTimeoutOrNack,
-                                 bind(&DiscoverVersion::handleData, this, _1, _2),
-                                 [this] (const Interest&, const std::string& reason) {
+                                 m_options.maxRetriesOnTimeoutOrNack,
+                                 m_options.maxRetriesOnTimeoutOrNack,
+                                 FORWARD_TO_MEM_FN(handleData),
+                                 [this] (const auto&, const auto& reason) {
                                    onDiscoveryFailure(reason);
                                  },
-                                 [this] (const Interest&, const std::string& reason) {
+                                 [this] (const auto&, const auto& reason) {
                                    onDiscoveryFailure(reason);
                                  },
                                  m_options.isVerbose);
@@ -68,7 +69,7 @@
 DiscoverVersion::handleData(const Interest& interest, const Data& data)
 {
   if (m_options.isVerbose)
-    std::cerr << "Data: " << data << std::endl;
+    std::cerr << "Data: " << data << "\n";
 
   // make a metadata object from received metadata packet
   MetadataObject mobject;
@@ -86,7 +87,7 @@
   }
 
   if (m_options.isVerbose) {
-    std::cerr << "Discovered Data version: " << mobject.getVersionedName()[-1] << std::endl;
+    std::cerr << "Discovered Data version: " << mobject.getVersionedName()[-1] << "\n";
   }
 
   onDiscoverySuccess(mobject.getVersionedName());
diff --git a/tools/chunks/catchunks/pipeline-interests-adaptive.cpp b/tools/chunks/catchunks/pipeline-interests-adaptive.cpp
index 29e0d27..595dcdc 100644
--- a/tools/chunks/catchunks/pipeline-interests-adaptive.cpp
+++ b/tools/chunks/catchunks/pipeline-interests-adaptive.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2016-2019, Regents of the University of California,
+ * Copyright (c) 2016-2021, Regents of the University of California,
  *                          Colorado State University,
  *                          University Pierre & Marie Curie, Sorbonne University.
  *
@@ -133,7 +133,7 @@
 
   if (m_options.isVerbose) {
     std::cerr << (isRetransmission ? "Retransmitting" : "Requesting")
-              << " segment #" << segNo << std::endl;
+              << " segment #" << segNo << "\n";
   }
 
   if (isRetransmission) {
@@ -150,7 +150,7 @@
 
       if (m_options.isVerbose) {
         std::cerr << "# of retries for segment #" << segNo
-                  << " is " << m_retxCount[segNo] << std::endl;
+                  << " is " << m_retxCount[segNo] << "\n";
       }
     }
   }
@@ -163,9 +163,9 @@
 
   SegmentInfo& segInfo = m_segmentInfo[segNo];
   segInfo.interestHdl = m_face.expressInterest(interest,
-                                               bind(&PipelineInterestsAdaptive::handleData, this, _1, _2),
-                                               bind(&PipelineInterestsAdaptive::handleNack, this, _1, _2),
-                                               bind(&PipelineInterestsAdaptive::handleLifetimeExpiration, this, _1));
+                                               FORWARD_TO_MEM_FN(handleData),
+                                               FORWARD_TO_MEM_FN(handleNack),
+                                               FORWARD_TO_MEM_FN(handleLifetimeExpiration));
   segInfo.timeSent = time::steady_clock::now();
   segInfo.rto = m_rttEstimator.getEstimatedRto();
 
@@ -239,7 +239,7 @@
   if (m_options.isVerbose) {
     std::cerr << "Received segment #" << recvSegNo
               << ", rtt=" << rtt.count() / 1e6 << "ms"
-              << ", rto=" << segInfo.rto.count() / 1e6 << "ms" << std::endl;
+              << ", rto=" << segInfo.rto.count() / 1e6 << "ms\n";
   }
 
   if (m_highData < recvSegNo) {
@@ -265,7 +265,7 @@
 
         if (m_options.isVerbose) {
           std::cerr << "Received congestion mark, value = " << data.getCongestionMark()
-                    << ", new cwnd = " << m_cwnd << std::endl;
+                    << ", new cwnd = " << m_cwnd << "\n";
         }
       }
     }
@@ -314,7 +314,7 @@
 
   if (m_options.isVerbose)
     std::cerr << "Received Nack with reason " << nack.getReason()
-              << " for Interest " << interest << std::endl;
+              << " for Interest " << interest << "\n";
 
   uint64_t segNo = getSegmentFromPacket(interest);
 
@@ -360,7 +360,7 @@
 
     if (m_options.isVerbose) {
       std::cerr << "Packet loss event, new cwnd = " << m_cwnd
-                << ", ssthresh = " << m_ssthresh << std::endl;
+                << ", ssthresh = " << m_ssthresh << "\n";
     }
   }
 }
diff --git a/tools/chunks/catchunks/pipeline-interests-adaptive.hpp b/tools/chunks/catchunks/pipeline-interests-adaptive.hpp
index 158656e..596c70e 100644
--- a/tools/chunks/catchunks/pipeline-interests-adaptive.hpp
+++ b/tools/chunks/catchunks/pipeline-interests-adaptive.hpp
@@ -60,7 +60,7 @@
 struct SegmentInfo
 {
   ScopedPendingInterestHandle interestHdl;
-  time::steady_clock::TimePoint timeSent;
+  time::steady_clock::time_point timeSent;
   time::nanoseconds rto;
   SegmentState state;
 };
diff --git a/tools/chunks/catchunks/pipeline-interests-cubic.hpp b/tools/chunks/catchunks/pipeline-interests-cubic.hpp
index 078560c..daa59eb 100644
--- a/tools/chunks/catchunks/pipeline-interests-cubic.hpp
+++ b/tools/chunks/catchunks/pipeline-interests-cubic.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2016-2019, Regents of the University of California,
+ * Copyright (c) 2016-2021, Regents of the University of California,
  *                          Colorado State University,
  *                          University Pierre & Marie Curie, Sorbonne University.
  *
@@ -52,7 +52,7 @@
 private:
   double m_wmax = 0.0; ///< window size before last window decrease
   double m_lastWmax = 0.0; ///< last wmax
-  time::steady_clock::TimePoint m_lastDecrease; ///< time of last window decrease
+  time::steady_clock::time_point m_lastDecrease; ///< time of last window decrease
 };
 
 } // namespace chunks
diff --git a/tools/chunks/catchunks/pipeline-interests-fixed.cpp b/tools/chunks/catchunks/pipeline-interests-fixed.cpp
index ce11295..7fab8e3 100644
--- a/tools/chunks/catchunks/pipeline-interests-fixed.cpp
+++ b/tools/chunks/catchunks/pipeline-interests-fixed.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2016-2019, Regents of the University of California,
+ * Copyright (c) 2016-2021, Regents of the University of California,
  *                          Colorado State University,
  *                          University Pierre & Marie Curie, Sorbonne University.
  *
@@ -79,7 +79,7 @@
 
   // send interest for next segment
   if (m_options.isVerbose)
-    std::cerr << "Requesting segment #" << nextSegmentNo << std::endl;
+    std::cerr << "Requesting segment #" << nextSegmentNo << "\n";
 
   auto interest = Interest()
                   .setName(Name(m_prefix).appendSegment(nextSegmentNo))
@@ -90,9 +90,15 @@
   auto fetcher = DataFetcher::fetch(m_face, interest,
                                     m_options.maxRetriesOnTimeoutOrNack,
                                     m_options.maxRetriesOnTimeoutOrNack,
-                                    bind(&PipelineInterestsFixed::handleData, this, _1, _2, pipeNo),
-                                    bind(&PipelineInterestsFixed::handleFail, this, _2, pipeNo),
-                                    bind(&PipelineInterestsFixed::handleFail, this, _2, pipeNo),
+                                    [=] (const auto& interest, const auto& data) {
+                                      handleData(interest, data, pipeNo);
+                                    },
+                                    [=] (const auto&, const auto& reason) {
+                                      handleFail(reason, pipeNo);
+                                    },
+                                    [=] (const auto&, const auto& reason) {
+                                      handleFail(reason, pipeNo);
+                                    },
                                     m_options.isVerbose);
 
   BOOST_ASSERT(!m_segmentFetchers[pipeNo].first || !m_segmentFetchers[pipeNo].first->isRunning());
@@ -122,7 +128,7 @@
   BOOST_ASSERT(data.getName().equals(interest.getName()));
 
   if (m_options.isVerbose)
-    std::cerr << "Received segment #" << getSegmentFromPacket(data) << std::endl;
+    std::cerr << "Received segment #" << getSegmentFromPacket(data) << "\n";
 
   onData(data);
 
diff --git a/tools/chunks/catchunks/pipeline-interests.hpp b/tools/chunks/catchunks/pipeline-interests.hpp
index dd8b5de..9fc3389 100644
--- a/tools/chunks/catchunks/pipeline-interests.hpp
+++ b/tools/chunks/catchunks/pipeline-interests.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2016-2019, Regents of the University of California,
+ * Copyright (c) 2016-2021, Regents of the University of California,
  *                          Colorado State University,
  *                          University Pierre & Marie Curie, Sorbonne University.
  *
@@ -80,7 +80,7 @@
   cancel();
 
 protected:
-  time::steady_clock::TimePoint
+  time::steady_clock::time_point
   getStartTime() const
   {
     return m_startTime;
@@ -166,7 +166,7 @@
   DataCallback m_onData;
   FailureCallback m_onFailure;
   uint64_t m_nextSegmentNo;
-  time::steady_clock::TimePoint m_startTime;
+  time::steady_clock::time_point m_startTime;
   bool m_isStopping;
 };