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

Improve socket comparison operators (needed for Catch2) #469

Closed
albestro opened this issue Jan 20, 2021 · 2 comments · Fixed by #470
Closed

Improve socket comparison operators (needed for Catch2) #469

albestro opened this issue Jan 20, 2021 · 2 comments · Fixed by #470

Comments

@albestro
Copy link
Contributor

Reporting here the discussion with the aim to evaluate the best option to improve them.

There still is a problem involving socket_ref and comparison operators, that I quickly workaround (not committed). I'll investigate further and in case I will open an issue to understand the best way to fix it.

Ok, I've just narrowed down the problem. For socket_ref a set of comparison operators is defined (starting from here), moreover it is possible to implicitly cast a socket_t to a socket_ref thanks to

cppzmq/zmq.hpp

Line 2186 in 18db456

operator socket_ref() ZMQ_NOTHROW { return socket_ref(from_handle, _handle); }

so, it is possible to use these comparison operators with both types.

But with Catch a problem arose, because CHECK(sr == s) passes by const& the operands and the cast operator for const socket_t is not available.

Unfortunately, I'm not used to the API of the library, so I would have to dig a bit to understand what's better to do (e.g. enabling the socket_ref operator by adding const). I can commit this proposal, just to see if other problems will come up in CI.

I don't know if you want me to open an issue about this, or if we want to keep it here and solve it directly.

Originally posted by @albestro in #466 (comment)

@albestro
Copy link
Contributor Author

@gummif if I get correctly your suggestion in #466 (comment), the solution would be to implement the different combinations for the various operators.

I was going to quickly implement it, but I'm not really sure that it is the best solution in terms of maintainability.

What do you think about something similar to this? https://github.com/albestro/cppzmq/commit/80914202e44dfbe0b74496333801d8deb2ccc446

@gummif
Copy link
Member

gummif commented Jan 21, 2021

@albestro Yes that could would (if you use const &).

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 a pull request may close this issue.

2 participants