diff --git a/configure.ac b/configure.ac
index 800171f..337a266 100644
--- a/configure.ac
+++ b/configure.ac
@@ -93,7 +93,15 @@
AX_CHECK_COMPILE_FLAG([-Wc++98-compat -Wc++98-compat-pedantic], [CXXFLAGS+=" -Wc++98-compat"], [])
AC_LANG_POP([C++])
else
- AX_CXX_COMPILE_STDCXX_11([ext], [optional])
+ AC_ARG_ENABLE([cxx11],
+ [AS_HELP_STRING([--enable-cxx11],
+ [enable C++11 for C++ compiler [default=no]])],
+ [zmq_enable_cxx11=$enableval],
+ [zmq_enable_cxx11="no"])
+ if test "x$zmq_enable_cxx11" != "xno"; then
+ AX_CXX_COMPILE_STDCXX_11([ext], [mandatory])
+ AC_DEFINE(ZMQ_USE_CXX11, 1, [Enable C++11])
+ fi
fi
# Check whether to build a with debug symbols
diff --git a/perf/benchmark_radix_tree.cpp b/perf/benchmark_radix_tree.cpp
index 432d535..e5f097b 100644
--- a/perf/benchmark_radix_tree.cpp
+++ b/perf/benchmark_radix_tree.cpp
@@ -27,7 +27,7 @@
along with this program. If not, see .
*/
-#if __cplusplus >= 201103L
+#if defined(ZMQ_USE_CXX11)
#include "radix_tree.hpp"
#include "trie.hpp"
diff --git a/src/atomic_counter.hpp b/src/atomic_counter.hpp
index d05837a..8a1c7ad 100644
--- a/src/atomic_counter.hpp
+++ b/src/atomic_counter.hpp
@@ -35,7 +35,7 @@
#if defined ZMQ_FORCE_MUTEXES
#define ZMQ_ATOMIC_COUNTER_MUTEX
-#elif (defined __cplusplus && __cplusplus >= 201103L) \
+#elif defined(ZMQ_USE_CXX11) \
|| (defined _MSC_VER && _MSC_VER >= 1900)
#define ZMQ_ATOMIC_COUNTER_CXX11
#elif defined ZMQ_HAVE_ATOMIC_INTRINSICS
diff --git a/src/atomic_ptr.hpp b/src/atomic_ptr.hpp
index fa8bc7c..51b8058 100644
--- a/src/atomic_ptr.hpp
+++ b/src/atomic_ptr.hpp
@@ -34,7 +34,7 @@
#if defined ZMQ_FORCE_MUTEXES
#define ZMQ_ATOMIC_PTR_MUTEX
-#elif (defined __cplusplus && __cplusplus >= 201103L) \
+#elif defined(ZMQ_USE_CXX11) \
|| (defined _MSC_VER && _MSC_VER >= 1900)
#define ZMQ_ATOMIC_PTR_CXX11
#elif defined ZMQ_HAVE_ATOMIC_INTRINSICS
diff --git a/src/blob.hpp b/src/blob.hpp
index 5422161..9106bbc 100644
--- a/src/blob.hpp
+++ b/src/blob.hpp
@@ -38,7 +38,7 @@
#include
#include
-#if __cplusplus >= 201103L || defined(_MSC_VER) && _MSC_VER > 1700
+#if defined(ZMQ_USE_CXX11) || defined(_MSC_VER) && _MSC_VER > 1700
#define ZMQ_HAS_MOVE_SEMANTICS
#define ZMQ_MAP_INSERT_OR_EMPLACE(k, v) emplace (k, v)
#define ZMQ_PUSH_OR_EMPLACE_BACK emplace_back
diff --git a/src/ctx.cpp b/src/ctx.cpp
index 2b64c51..6dec399 100644
--- a/src/ctx.cpp
+++ b/src/ctx.cpp
@@ -725,7 +725,7 @@
end = _endpoints.end ();
it != end;) {
if (it->second.socket == socket_)
-#if __cplusplus >= 201103L || (defined _MSC_VER && _MSC_VER >= 1700)
+#if defined(ZMQ_USE_CXX11) || (defined _MSC_VER && _MSC_VER >= 1700)
it = _endpoints.erase (it);
#else
_endpoints.erase (it++);
diff --git a/src/mtrie.hpp b/src/mtrie.hpp
index b5ca3ac..52cdeaa 100644
--- a/src/mtrie.hpp
+++ b/src/mtrie.hpp
@@ -32,7 +32,7 @@
#include "generic_mtrie.hpp"
-#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER > 1600)
+#if defined(ZMQ_USE_CXX11) || (defined(_MSC_VER) && _MSC_VER > 1600)
#define ZMQ_HAS_EXTERN_TEMPLATE 1
#else
#define ZMQ_HAS_EXTERN_TEMPLATE 0
diff --git a/src/options.hpp b/src/options.hpp
index 556eea4..8803711 100644
--- a/src/options.hpp
+++ b/src/options.hpp
@@ -47,7 +47,7 @@
#include
#endif
-#if __cplusplus >= 201103L || (defined _MSC_VER && _MSC_VER >= 1700)
+#if defined(ZMQ_USE_CXX11) || (defined _MSC_VER && _MSC_VER >= 1700)
#include
#endif
@@ -327,7 +327,7 @@
template
int do_getsockopt (void *const optval_, size_t *const optvallen_, T value_)
{
-#if __cplusplus >= 201103L && (!defined(__GNUC__) || __GNUC__ > 5)
+#if defined(ZMQ_USE_CXX11) && (!defined(__GNUC__) || __GNUC__ > 5)
static_assert (std::is_trivially_copyable::value,
"invalid use of do_getsockopt");
#endif
diff --git a/src/radio.cpp b/src/radio.cpp
index aa9f100..538ad89 100644
--- a/src/radio.cpp
+++ b/src/radio.cpp
@@ -126,7 +126,7 @@
end = _subscriptions.end ();
it != end;) {
if (it->second == pipe_) {
-#if __cplusplus >= 201103L || (defined _MSC_VER && _MSC_VER >= 1700)
+#if defined(ZMQ_USE_CXX11) || (defined _MSC_VER && _MSC_VER >= 1700)
it = _subscriptions.erase (it);
#else
_subscriptions.erase (it++);
diff --git a/src/random.cpp b/src/random.cpp
index 17c3537..8f8cfc0 100644
--- a/src/random.cpp
+++ b/src/random.cpp
@@ -100,7 +100,7 @@
// configurable via config.h
// TODO this should probably be done via config.h
-#if __cplusplus >= 201103L \
+#if defined(ZMQ_USE_CXX11) \
|| (defined(__cpp_threadsafe_static_init) \
&& __cpp_threadsafe_static_init >= 200806) \
|| (defined(_MSC_VER) && _MSC_VER >= 1900)