Yes, it was discussed here http://thread.gmane.org/gmane.network.zeromq.devel/8565/focus=8603
Attaching the patch (again)
It suggests two overloaded data() methods. The new one is const and returns const void*.
27.05.2011, 04:23, "Steven McCoy" <[email protected]>:
I'm sure there has been similar discussion before but it seems to be on other API, I propose a const_data() API to msg_t in order to permit const correctness in higher APIs. A primary example being CZMQ's zmsgdup API (zmsg_copy).Is there a better way of doing this in C++?--Steve-o_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
--
Best regards,
Ilja Golshtein.
Best regards,
Ilja Golshtein.
--- ../../zeromq2-1/include/zmq.hpp 2011-04-25 12:02:20.000000000 +0400
+++ ./zmq.hpp 2011-04-25 13:23:18.000000000 +0400
@@ -146,7 +146,7 @@
throw error_t ();
}
- inline void copy (message_t *msg_)
+ inline void copy (const message_t *msg_)
{
int rc = zmq_msg_copy (this, (zmq_msg_t*) msg_);
if (rc != 0)
@@ -158,9 +158,14 @@
return zmq_msg_data (this);
}
- inline size_t size ()
+ inline const void *data () const
{
- return zmq_msg_size (this);
+ return zmq_msg_data (const_cast<message_t*>(this));
+ }
+
+ inline size_t size () const
+ {
+ return zmq_msg_size (const_cast<message_t*>(this));
}
private:_______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
