Improve and simplify code with modern C++ features

Change-Id: I28d84df3087492ab2ecbeb91169a2cde12c9e31e
diff --git a/src/net/detail/network-monitor-impl-osx.cpp b/src/net/detail/network-monitor-impl-osx.cpp
index 7af5337..839faaa 100644
--- a/src/net/detail/network-monitor-impl-osx.cpp
+++ b/src/net/detail/network-monitor-impl-osx.cpp
@@ -79,8 +79,7 @@
   IfAddrs()
   {
     if (::getifaddrs(&m_ifaList) < 0) {
-      BOOST_THROW_EXCEPTION(NetworkMonitorImplOsx::Error(std::string("getifaddrs() failed: ") +
-                                                         strerror(errno)));
+      BOOST_THROW_EXCEPTION(NetworkMonitorImplOsx::Error("getifaddrs() failed: "s + strerror(errno)));
     }
   }
 
diff --git a/src/net/detail/network-monitor-impl-rtnl.cpp b/src/net/detail/network-monitor-impl-rtnl.cpp
index 02c84fb..ab797db 100644
--- a/src/net/detail/network-monitor-impl-rtnl.cpp
+++ b/src/net/detail/network-monitor-impl-rtnl.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -96,8 +96,7 @@
 
   int fd = ::socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE);
   if (fd < 0) {
-    BOOST_THROW_EXCEPTION(Error(std::string("Cannot create netlink socket (") +
-                                std::strerror(errno) + ")"));
+    BOOST_THROW_EXCEPTION(Error("Cannot create netlink socket ("s + std::strerror(errno) + ")"));
   }
   m_socket->assign(fd);
 
@@ -107,15 +106,13 @@
                    RTMGRP_IPV4_IFADDR | RTMGRP_IPV4_ROUTE |
                    RTMGRP_IPV6_IFADDR | RTMGRP_IPV6_ROUTE;
   if (::bind(fd, reinterpret_cast<sockaddr*>(&addr), sizeof(addr)) < 0) {
-    BOOST_THROW_EXCEPTION(Error(std::string("Cannot bind netlink socket (") +
-                                std::strerror(errno) + ")"));
+    BOOST_THROW_EXCEPTION(Error("Cannot bind netlink socket ("s + std::strerror(errno) + ")"));
   }
 
   // find out what pid has been assigned to us
   socklen_t len = sizeof(addr);
   if (::getsockname(fd, reinterpret_cast<sockaddr*>(&addr), &len) < 0) {
-    BOOST_THROW_EXCEPTION(Error(std::string("Cannot obtain netlink socket address (") +
-                                std::strerror(errno) + ")"));
+    BOOST_THROW_EXCEPTION(Error("Cannot obtain netlink socket address ("s + std::strerror(errno) + ")"));
   }
   if (len != sizeof(addr)) {
     BOOST_THROW_EXCEPTION(Error("Wrong address length (" + to_string(len) + ")"));
diff --git a/src/net/dns.cpp b/src/net/dns.cpp
index 0043ec9..1204451 100644
--- a/src/net/dns.cpp
+++ b/src/net/dns.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2017 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2018 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -57,7 +57,7 @@
 
     m_resolver.async_resolve(q, bind(&Resolver::onResolveResult, this, _1, _2, self));
 
-    m_resolveTimeout = m_scheduler.scheduleEvent(timeout, bind(&Resolver::onResolveTimeout, this, self));
+    m_resolveTimeout = m_scheduler.scheduleEvent(timeout, [=] { onResolveTimeout(self); });
   }
 
   iterator
@@ -73,7 +73,7 @@
   {
     m_scheduler.cancelEvent(m_resolveTimeout);
     // ensure the Resolver isn't destructed while callbacks are still pending, see #2653
-    m_resolver.get_io_service().post(bind([] (const shared_ptr<Resolver>&) {}, self));
+    m_resolver.get_io_service().post([self] {});
 
     if (error) {
       if (error == boost::asio::error::operation_aborted)
@@ -100,7 +100,7 @@
   {
     m_resolver.cancel();
     // ensure the Resolver isn't destructed while callbacks are still pending, see #2653
-    m_resolver.get_io_service().post(bind([] (const shared_ptr<Resolver>&) {}, self));
+    m_resolver.get_io_service().post([self] {});
 
     if (m_onError)
       m_onError("Hostname resolution timed out");
diff --git a/src/net/face-uri.cpp b/src/net/face-uri.cpp
index ceed453..dc70760 100644
--- a/src/net/face-uri.cpp
+++ b/src/net/face-uri.cpp
@@ -656,11 +656,9 @@
     return;
   }
 
-  static CanonizeSuccessCallback successNop = bind([]{});
-  static CanonizeFailureCallback failureNop = bind([]{});
   cp->canonize(*this,
-               onSuccess ? onSuccess : successNop,
-               onFailure ? onFailure : failureNop,
+               onSuccess ? onSuccess : [] (auto&&) {},
+               onFailure ? onFailure : [] (auto&&) {},
                io, timeout);
 }