Quickest way to initialize asio::ip::address_v6()?
boost, boost-asio, c++, initialization, ip-address
Solution
You can't do better than initializing an `asio::ip::address_v6::bytes_type`, which can actually be a `std::array` or a `boost::array`:
// We need an unsigned char* pointer to the IP address
unsigned char *youraddr = reinterpret_cast<unsigned char*>(your_void_ptr);
asio::ip::address_v6::bytes_type myaddr;
// Copy the address into our array
std::copy(youraddr, youraddr + myaddr.size(), myaddr.data());
// Finally, initialize.
asio::ip::address_v6 ipv6(myaddr);
Note that it would be better to directly store a `bytes_type` instead of that `void*`, if you are able to modify that structure, obviously.
Problem
`asio::ip::address_v6` takes a `bytes_type` for a parameter, which is basically a `boost::array` in network-byte order. I have a RAW IPv6 address in a `void *` variable. What's the quickest way to turn a `void *` into a `asio::ip::address_v6`? Preferably using the constructor.