net/IPv[46]Address: make the initializers even more portable

Similar to 5a5229b499: use more C++14
constexpr.
This commit is contained in:
Max Kellermann
2019-01-14 19:21:07 +01:00
parent 22d669da18
commit 1fa99da3c2
2 changed files with 25 additions and 18 deletions

View File

@@ -51,7 +51,12 @@ class IPv4Address {
#ifdef _WIN32
static constexpr struct in_addr ConstructInAddr(uint8_t a, uint8_t b,
uint8_t c, uint8_t d) noexcept {
return {{{ a, b, c, d }}};
struct in_addr result{};
result.s_net = a;
result.s_host = b;
result.s_lh = c;
result.s_impno = d;
return result;
}
#else
@@ -66,7 +71,7 @@ class IPv4Address {
static constexpr struct in_addr ConstructInAddr(uint8_t a, uint8_t b,
uint8_t c, uint8_t d) noexcept {
return { ConstructInAddrT(a, b, c, d) };
return ConstructInAddrBE(ConstructInAddrT(a, b, c, d));
}
#endif