From 6137b485a08661b8e9d785bb049fbc54d7f261ec Mon Sep 17 00:00:00 2001 From: Gudmundur Adalsteinsson Date: Fri, 30 Aug 2019 20:46:32 +0000 Subject: [PATCH] Problem: C++11 partially supported on gcc 4.8 Solution: Use intrinsic instead of std::is_trivially_copyable for gcc versions older than 5. --- README.md | 2 +- zmq.hpp | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0489c65..3d0c04d 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Supported platforms - Additional platforms that are known to work: - We have no current reports on additional platforms that are known to work yet. Please add your platform here. If CI can be provided for them with a cloud-based CI service working with GitHub, you are invited to add CI, and make it possible to be included in the list above. - Additional platforms that probably work: - - Any platform supported by libzmq that provides a sufficiently recent gcc (4.8.1 or newer) or clang (3.3 or newer) + - Any platform supported by libzmq that provides a sufficiently recent gcc (4.8.1 or newer) or clang (3.4.1 or newer) - Visual Studio 2012+ x86/x64 Examples diff --git a/zmq.hpp b/zmq.hpp index 6791682..3b76a78 100644 --- a/zmq.hpp +++ b/zmq.hpp @@ -122,6 +122,14 @@ #define ZMQ_DELETED_FUNCTION #endif +#ifdef ZMQ_CPP11 +#if defined(__GNUC__) && __GNUC__ < 5 +#define ZMQ_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T) +#else +#define ZMQ_IS_TRIVIALLY_COPYABLE(T) std::is_trivially_copyable::value +#endif +#endif + #if ZMQ_VERSION >= ZMQ_MAKE_VERSION(3, 3, 0) #define ZMQ_NEW_MONITOR_EVENT_LAYOUT #endif @@ -331,7 +339,7 @@ class message_t template::value - && std::is_trivially_copyable>::value + && ZMQ_IS_TRIVIALLY_COPYABLE(detail::range_value_t) && !std::is_same::value>::type> explicit message_t(const Range &rng) : message_t(detail::ranges::begin(rng), detail::ranges::end(rng)) @@ -948,7 +956,7 @@ template struct is_pod_like // trivially copyable OR standard layout. // Here we decide to be conservative and require both. static constexpr bool value = - std::is_trivially_copyable::value && std::is_standard_layout::value; + ZMQ_IS_TRIVIALLY_COPYABLE(T) && std::is_standard_layout::value; }; template constexpr auto seq_size(const C &c) noexcept -> decltype(c.size())