Problem: sock.get(zmq::sockopt::type) is not typesafe

Solution: Add `zmq::sockopt::socket_type` that is used to `get()` an enumerator
from `zmq::socket_type` instead of plain `int`.

It makes code like this compile:

  #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::socket_type) == zmq::socket_type::push);
      return 0;
  }
This commit is contained in:
Jaakko Moisio
2021-10-21 20:51:33 +03:00
parent 33ed54228e
commit cbe449908e
2 changed files with 42 additions and 36 deletions

View File

@@ -406,7 +406,10 @@ TEST_CASE("socket check integral options", "[socket]")
#endif
#ifdef ZMQ_TYPE
check_integral_opt_get<int>(zmq::sockopt::type, router, "type");
#endif
#ifdef ZMQ_CPP11
check_integral_opt_get<zmq::socket_type>(zmq::sockopt::socket_type, router, "socket_type");
#endif // ZMQ_CPP11
#endif // ZMQ_TYPE
#ifdef ZMQ_HAVE_VMCI
#ifdef ZMQ_VMCI_BUFFER_SIZE