[zeromq-dev] [PATCH] C++11 move constructor/assignment operator for socket_t and context_t

Botond Ballo botond_ballo at yahoo.ca
Sat Nov 19 06:20:59 CET 2011


Hello,

I would like to submit a patch to add C++11 move constructors and assignment operators
to zmq::socket_t and zmq::context_t.


These types are not copy-constructible and copy-assignable, for good reason. However,
in C++11, they can be made move-constructible and move-assignable. I have attached
a patch that adds a move constructor and move assignment operator to them.

These functions are only enabled when the compiler supports C++11 rvalue references,
which are needed to implement move constructors and move assignment operators.
Therefore, the code continues to be fully compatible with compilers that do not support
this C++11 feature.

I have added code at the top of the file that detects whether the compiler supports
rvalue references, for three popular compilers: gcc, msvc, and clang. Code that
detects support in other compilers can easily be added if desired. For now, the code
assumes that the compiler does not have rvalue reference support if it's not one of these
three compilers.

The patch is against the 2.1 branch.


Can this patch be added to the next release?

Best regards,
Botond
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20111118/09785361/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-C-11-move-constructor-assignment-operator-for-socket.patch
Type: application/octet-stream
Size: 2371 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20111118/09785361/attachment.obj>


More information about the zeromq-dev mailing list