[zeromq-dev] [PATCH] zmq::msg_t::const_data for const correctness?
ilejncs at narod.ru
Fri May 27 10:26:04 CEST 2011
The idea of the patch was to have something easily applicable.
It does not break current interface, it is harmless, though not very useful.
I hope it can slightly reduce chances of copy() misuse.
27.05.2011, 12:16, "Martin Sustrik" <sustrik at 250bpm.com>:
> On 05/27/2011 10:05 AM, Ilja Golshtein wrote:
>> Yes, it was discussed here
>> Attaching the patch (again)
>> It suggests two overloaded data() methods. The new one is const and
>> returns const void*.
> Yes. This is a better approach but still doesn't deliver consistent
> const semantics.
> Implementing CoW behaviour to get the semantics consistent in
> std::string way is probably not that good an idea because of the
> performance impact of message copying.
> One solution that comes to mind is changing the zmq_msg_copy function in
> such a way that it closes the original non-const message and produces
> two const messages.
> That way the user can't shoot himself in the leg by copying a message
> object (which makes the buffer shared) and overwriting the data in one
> instance behind other instance's back.
> int zmq_msg_copy (const zmq_msg_t *src, const zmq_msg_t **dest1,
> const zmq_msg_t **dest2);
More information about the zeromq-dev