Gather all IP addresses of a host as a vector
I agree with you that the copying of data from s6_addr seems cumbersome.  I would instead just cast without copying:
auto&amp; bytearray = reinterpret_cast&lt;std::array&lt;unsigned char,16&gt;&amp;&gt;(ipv6socket-&gt;sin6_addr.s6_addr);

(If we had needed to copy, we could change auto&amp; to plain auto).
Apart from this, the variable ipv6base is never used, so should just be removed.