From 085de240c257f4687d8b069d2956a5b79a554c83 Mon Sep 17 00:00:00 2001 From: Alexey Rybalchenko Date: Tue, 25 Apr 2017 15:37:54 +0200 Subject: [PATCH] FairMQ: fix missing includes. --- fairmq/tools/FairMQTools.h | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/fairmq/tools/FairMQTools.h b/fairmq/tools/FairMQTools.h index 702ca809..2762ee2c 100644 --- a/fairmq/tools/FairMQTools.h +++ b/fairmq/tools/FairMQTools.h @@ -18,11 +18,8 @@ #include #include #include -#include #include -using namespace std; - namespace FairMQ { namespace tools @@ -30,13 +27,13 @@ namespace tools // make_unique implementation, until C++14 is default template -unique_ptr make_unique(Args&& ...args) +std::unique_ptr make_unique(Args&& ...args) { - return unique_ptr(new T(forward(args)...)); + return std::unique_ptr(new T(std::forward(args)...)); } // returns a map with network interface names as keys and their IP addresses as values -int getHostIPs(map& addressMap) +int getHostIPs(std::map& addressMap) { struct ifaddrs *ifaddr, *ifa; int s; @@ -60,11 +57,11 @@ int getHostIPs(map& addressMap) s = getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in), host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); if (s != 0) { - cout << "getnameinfo() failed: " << gai_strerror(s) << endl; + std::cout << "getnameinfo() failed: " << gai_strerror(s) << std::endl; return -1; } - addressMap.insert(pair(ifa->ifa_name, host)); + addressMap.insert(std::pair(ifa->ifa_name, host)); } } freeifaddrs(ifaddr); @@ -73,10 +70,10 @@ int getHostIPs(map& addressMap) } // get IP address of a given interface name -string getInterfaceIP(string interface) +std::string getInterfaceIP(std::string interface) { - map IPs; - FairMQ::tools::getHostIPs(IPs); + std::map IPs; + getHostIPs(IPs); if (IPs.count(interface)) { return IPs[interface]; @@ -89,15 +86,15 @@ string getInterfaceIP(string interface) } // get name of the default route interface -string getDefaultRouteNetworkInterface() +std::string getDefaultRouteNetworkInterface() { - array buffer; - string interfaceName; + std::array buffer; + std::string interfaceName; #ifdef __APPLE__ // MacOS - unique_ptr file(popen("route -n get default | grep interface | cut -d \":\" -f 2", "r"), pclose); + std::unique_ptr file(popen("route -n get default | grep interface | cut -d \":\" -f 2", "r"), pclose); #else // Linux - unique_ptr file(popen("ip route | grep default | cut -d \" \" -f 5", "r"), pclose); + std::unique_ptr file(popen("ip route | grep default | cut -d \" \" -f 5", "r"), pclose); #endif if (!file)