eliminate using namespace

This commit is contained in:
Martin Michelsen
2026-05-25 16:38:31 -07:00
parent 4503d09c77
commit e9c2ac34a3
98 changed files with 6022 additions and 6531 deletions
+6 -8
View File
@@ -17,18 +17,16 @@
#include <phosg/Strings.hh>
#include <stdexcept>
using namespace std;
map<string, uint32_t> get_local_addresses() {
map<string, uint32_t> ret;
std::map<std::string, uint32_t> get_local_addresses() {
std::map<std::string, uint32_t> ret;
#ifndef PHOSG_WINDOWS
struct ifaddrs* ifa_raw;
if (getifaddrs(&ifa_raw)) {
auto s = phosg::string_for_error(errno);
throw runtime_error(std::format("failed to get interface addresses: {}", s));
throw std::runtime_error(std::format("failed to get interface addresses: {}", s));
}
unique_ptr<struct ifaddrs, void (*)(struct ifaddrs*)> ifa(ifa_raw, freeifaddrs);
std::unique_ptr<struct ifaddrs, void (*)(struct ifaddrs*)> ifa(ifa_raw, freeifaddrs);
for (struct ifaddrs* i = ifa.get(); i; i = i->ifa_next) {
if (!i->ifa_addr) {
@@ -56,7 +54,7 @@ map<string, uint32_t> get_local_addresses() {
}
if (result != NO_ERROR) {
throw runtime_error(std::format("GetAdaptersAddresses failed: {}", result));
throw std::runtime_error(std::format("GetAdaptersAddresses failed: {}", result));
}
for (IP_ADAPTER_ADDRESSES* adapter = adapters; adapter != nullptr; adapter = adapter->Next) {
@@ -92,7 +90,7 @@ bool is_local_address(const sockaddr_storage& daddr) {
return is_local_address(ntohl(sin->sin_addr.s_addr));
}
string string_for_address(uint32_t address) {
std::string string_for_address(uint32_t address) {
return std::format("{}.{}.{}.{}",
static_cast<uint8_t>(address >> 24), static_cast<uint8_t>(address >> 16),
static_cast<uint8_t>(address >> 8), static_cast<uint8_t>(address));