From 019d234ffd3e99ceca4a1c5c728e14a80357a7a7 Mon Sep 17 00:00:00 2001
From: Ryan Huffman <ryanhuffman@gmail.com>
Date: Tue, 1 Sep 2015 11:55:26 -0700
Subject: [PATCH] Replace std::bind for methods that use std::unique_ptr with a
 lambda

---
 ice-server/src/IceServer.cpp                 | 2 +-
 libraries/networking/src/LimitedNodeList.cpp | 6 +++---
 tools/udt-test/src/UDTTest.cpp               | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/ice-server/src/IceServer.cpp b/ice-server/src/IceServer.cpp
index a2603269d9..a44b6393de 100644
--- a/ice-server/src/IceServer.cpp
+++ b/ice-server/src/IceServer.cpp
@@ -36,7 +36,7 @@ IceServer::IceServer(int argc, char* argv[]) :
 
     // set processPacket as the verified packet callback for the udt::Socket
     using std::placeholders::_1;
-    _serverSocket.setPacketHandler(std::bind(&IceServer::processPacket, this, _1));
+    _serverSocket.setPacketHandler([this](std::unique_ptr<udt::Packet> packet) { processPacket(std::move(packet));  });
     
     // set packetVersionMatch as the verify packet operator for the udt::Socket
     _serverSocket.setPacketFilterOperator(std::bind(&IceServer::packetVersionMatch, this, _1));
diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp
index 2d1c98287c..74d922ce67 100644
--- a/libraries/networking/src/LimitedNodeList.cpp
+++ b/libraries/networking/src/LimitedNodeList.cpp
@@ -95,8 +95,8 @@ LimitedNodeList::LimitedNodeList(unsigned short socketListenPort, unsigned short
     
     // set &PacketReceiver::handleVerifiedPacket as the verified packet callback for the udt::Socket
     using std::placeholders::_1;
-    _nodeSocket.setPacketHandler(std::bind(&PacketReceiver::handleVerifiedPacket, _packetReceiver, _1));
-    _nodeSocket.setPacketListHandler(std::bind(&PacketReceiver::handleVerifiedPacketList, _packetReceiver, _1));
+    _nodeSocket.setPacketHandler([this](std::unique_ptr<udt::Packet> packet) { _packetReceiver->handleVerifiedPacket(std::move(packet)); });
+    _nodeSocket.setPacketListHandler([this](std::unique_ptr<udt::PacketList> packetList) { _packetReceiver->handleVerifiedPacketList(std::move(packetList)); });
 
     // set our isPacketVerified method as the verify operator for the udt::Socket
     _nodeSocket.setPacketFilterOperator(std::bind(&LimitedNodeList::isPacketVerified, this, _1));
@@ -764,7 +764,7 @@ void LimitedNodeList::possiblyTimeoutSTUNAddressLookup() {
 void LimitedNodeList::addSTUNHandlerToUnfiltered() {
     // make ourselves the handler of STUN packets when they come in
     using std::placeholders::_1;
-    _nodeSocket.addUnfilteredHandler(_stunSockAddr, std::bind(&LimitedNodeList::processSTUNResponse, this, _1));
+    _nodeSocket.addUnfilteredHandler(_stunSockAddr, [this](std::unique_ptr<udt::BasePacket> packet) { processSTUNResponse(std::move(packet)); });
 }
 
 void LimitedNodeList::stopInitialSTUNUpdate(bool success) {
diff --git a/tools/udt-test/src/UDTTest.cpp b/tools/udt-test/src/UDTTest.cpp
index f11ff0d489..d8d20436b4 100644
--- a/tools/udt-test/src/UDTTest.cpp
+++ b/tools/udt-test/src/UDTTest.cpp
@@ -177,7 +177,7 @@ UDTTest::UDTTest(int& argc, char** argv) :
         // this is a receiver - in case there are ordered packets (messages) being sent to us make sure that we handle them
         // so that they can be verified
         using std::placeholders::_1;
-        _socket.setPacketListHandler(std::bind(&UDTTest::handlePacketList, this, _1));
+        _socket.setPacketListHandler([this](std::unique_ptr<udt::PacketList> packetList) { handlePacketList(std::move(packetList));  });
     }
     
     // the sender reports stats every 100 milliseconds, unless passed a custom value