Open arsdever opened 4 years ago
This seems like a good idea. But I would think to make it purely virtual function in the base class:
virtual std::string to_string() const =0;
That would force the child classes to output something useful.
But note that this, especially, would be a breaking change in the API. It could break someone's build if they used the sock_address
class for an additional socket type in the library/application.
But note that this, especially, would be a breaking change in the API. It could break someone's build if they used the sock_address class for an additional socket type in the library/application.
That is why I specified default implementation. Maybe merging this to future branch with pure virtual implementation?
Based on my observation and my usage, sometimes it is useful to get the string representation of the IP address of the socket. But in case you have a simple
sock_address
type object, you must do some additional actions (checking the type and casting) to have your job done correctly. For this purpose, I moved theto_string
function up tosock_address
class and made it virtual.