diff options
author | Martin Lucina <martin@lucina.net> | 2012-01-23 09:00:28 +0100 |
---|---|---|
committer | Martin Lucina <martin@lucina.net> | 2012-01-23 09:00:28 +0100 |
commit | 4016b657973bba87caf75168ba70aaa85d556487 (patch) | |
tree | c2abaf9284f55964bea72a0b76f6b79070335858 /include | |
parent | 978e33ba253a997b41b331b449b474a5cee7bccc (diff) |
Imported Upstream version 2.1.11upstream/2.1.11
Diffstat (limited to 'include')
-rw-r--r-- | include/zmq.h | 2 | ||||
-rw-r--r-- | include/zmq.hpp | 39 |
2 files changed, 40 insertions, 1 deletions
diff --git a/include/zmq.h b/include/zmq.h index 0184569..a507156 100644 --- a/include/zmq.h +++ b/include/zmq.h @@ -55,7 +55,7 @@ extern "C" { /* Version macros for compile-time API version detection */ #define ZMQ_VERSION_MAJOR 2 #define ZMQ_VERSION_MINOR 1 -#define ZMQ_VERSION_PATCH 10 +#define ZMQ_VERSION_PATCH 11 #define ZMQ_MAKE_VERSION(major, minor, patch) \ ((major) * 10000 + (minor) * 100 + (patch)) diff --git a/include/zmq.hpp b/include/zmq.hpp index e147b0e..bfba0f6 100644 --- a/include/zmq.hpp +++ b/include/zmq.hpp @@ -27,6 +27,19 @@ #include <cstring> #include <exception> +// Detect whether the compiler supports C++11 rvalue references. +#if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2)) && defined(__GXX_EXPERIMENTAL_CXX0X__)) +# define ZMQ_HAS_RVALUE_REFS +#endif +#if (defined(__clang__)) +# if __has_feature(cxx_rvalue_references) +# define ZMQ_HAS_RVALUE_REFS +# endif +#endif +#if (defined(_MSC_VER) && (_MSC_VER >= 1600)) +# define ZMQ_HAS_RVALUE_REFS +#endif + namespace zmq { @@ -184,8 +197,22 @@ namespace zmq throw error_t (); } +#ifdef ZMQ_HAS_RVALUE_REFS + inline context_t(context_t&& rhs) : ptr(rhs.ptr) + { + rhs.ptr = NULL; + } + inline context_t& operator=(context_t&& rhs) + { + std::swap(ptr, rhs.ptr); + return *this; + } +#endif + inline ~context_t () { + if (ptr == NULL) + return; int rc = zmq_term (ptr); assert (rc == 0); } @@ -217,6 +244,18 @@ namespace zmq throw error_t (); } +#ifdef ZMQ_HAS_RVALUE_REFS + inline socket_t(socket_t&& rhs) : ptr(rhs.ptr) + { + rhs.ptr = NULL; + } + inline socket_t& operator=(socket_t&& rhs) + { + std::swap(ptr, rhs.ptr); + return *this; + } +#endif + inline ~socket_t () { close(); |