net/IPv[46]Address: make the initializers more portable
Thanks to C++14, we can declare and fill variables inside `constexpr` functions. This means me can stop make assumptions on the `struct` layouts without losing `constexpr`. Closes #393
This commit is contained in:
@@ -68,16 +68,12 @@ class IPv6Address {
|
||||
static constexpr struct sockaddr_in6 Construct(struct in6_addr address,
|
||||
uint16_t port,
|
||||
uint32_t scope_id) noexcept {
|
||||
return {
|
||||
#if defined(__APPLE__)
|
||||
sizeof(struct sockaddr_in6),
|
||||
#endif
|
||||
AF_INET6,
|
||||
ToBE16(port),
|
||||
0,
|
||||
address,
|
||||
scope_id,
|
||||
};
|
||||
struct sockaddr_in6 sin{};
|
||||
sin.sin6_family = AF_INET6;
|
||||
sin.sin6_port = ToBE16(port);
|
||||
sin.sin6_addr = address;
|
||||
sin.sin6_scope_id = scope_id;
|
||||
return sin;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user