I’m wondering what would be the most efficient way to store an IPv6 in C++?
Basically I need a format that offer as much flexibility as possible, and compatibility with existing libraries. My first thought was to use a simple std::vector<int> since that would allow me to access each part of the address easily.
Is that a good solution? Or am I likely to run into troubles later on?
That should be fine but you might want to do a std::vector<uint8_t>. I would personally use the struct sockaddr_in6 from c.
Include this:
That way you can just use static intilization of your address and be done with it. Doing repeated push_backs onto the vector would get very cumbersome and make it a lot harder to read.