You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The new sock.get(zmq::sockopt::option) API does a good job in retrieving socket options in a typesafe manner, and is definitely an improvement over the old sock.getsockopt() API.
But I think that sock.get(zmq::sockopt::type) in particular works illogically. Currently, this won't compile:
$ cat test.cc
#include <zmq.hpp>
#include <cassert>
int main()
{
zmq::context_t ctx;
zmq::socket_t sock(ctx, zmq::socket_type::push);
assert(sock.get(zmq::sockopt::type) == zmq::socket_type::push);
return 0;
}
$ g++ -c test.cc
In file included from /usr/include/c++/10/cassert:44,
from test.cc:3:
test.cc: In function ‘int main()’:
test.cc:9:41: error: no match for ‘operator==’ (operand types are ‘int’ and ‘zmq::socket_type’)
9 | assert(sock.get(zmq::sockopt::type) == zmq::socket_type::push);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~ ~~~~~~~~~~~~~~~~~~~~~~
| | |
| int zmq::socket_type
Would it make more sense that in C++11 and above sock.get(zmq::sockopt::type) would return enumerator from zmq::socket_type instead of an int? int is neither typesafe nor used to represent socket types elsewhere in the library. This change would break backward compatibility slightly, but in a way that I'm sure any user of zmq::sockopt::type would accept.
What do you think?
The text was updated successfully, but these errors were encountered:
The new
sock.get(zmq::sockopt::option)
API does a good job in retrieving socket options in a typesafe manner, and is definitely an improvement over the oldsock.getsockopt()
API.But I think that
sock.get(zmq::sockopt::type)
in particular works illogically. Currently, this won't compile:Would it make more sense that in C++11 and above
sock.get(zmq::sockopt::type)
would return enumerator fromzmq::socket_type
instead of anint
?int
is neither typesafe nor used to represent socket types elsewhere in the library. This change would break backward compatibility slightly, but in a way that I'm sure any user ofzmq::sockopt::type
would accept.What do you think?
The text was updated successfully, but these errors were encountered: