Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making to_string as a virtual function accessible from sock_address class #48

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

Making to_string as a virtual function accessible from sock_address class #48

wants to merge 2 commits into from

Conversation

arsdever
Copy link
Contributor

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 the to_string function up to sock_address class and made it virtual.

@arsdever arsdever changed the title Marking to_string as a virtual function accessible from sock_address class Making to_string as a virtual function accessible from sock_address class May 23, 2020
@fpagliughi
Copy link
Owner

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.

@arsdever
Copy link
Contributor Author

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?

@arsdever arsdever changed the base branch from master to develop June 3, 2020 21:34
@fpagliughi fpagliughi added this to the v0.9 milestone Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants