Skip to content

Commit 1f66e99

Browse files
authored
Merge pull request #341 from gummif/gfa/cpp11-gcc
Problem: C++11 partially supported on gcc 4.8
2 parents ef2e328 + 4f1ff49 commit 1f66e99

File tree

6 files changed

+39
-15
lines changed

6 files changed

+39
-15
lines changed

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,17 @@ matrix:
6060
env:
6161
- MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
6262

63+
# GCC 4.9, draft disabled (default), latest libzmq (default)
64+
- os: linux
65+
addons:
66+
apt:
67+
sources:
68+
- ubuntu-toolchain-r-test
69+
packages:
70+
- g++-4.9
71+
env:
72+
- MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9" CMAKE_CPP_STD=-DCMAKE_CXX_STANDARD=11
73+
6374
# GCC 7, draft enabled, latest libzmq (default)
6475
- os: linux
6576
addons:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Supported platforms
3636
- Additional platforms that are known to work:
3737
- 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.
3838
- Additional platforms that probably work:
39-
- Any platform supported by libzmq that provides a sufficiently recent gcc (4.8.1 or newer) or clang (3.3 or newer)
39+
- Any platform supported by libzmq that provides a sufficiently recent gcc (4.8.1 or newer) or clang (3.4.1 or newer)
4040
- Visual Studio 2012+ x86/x64
4141

4242
Examples

ci_build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ cppzmq_build() {
3939
pushd .
4040
CMAKE_PREFIX_PATH=${LIBZMQ} \
4141
cmake -H. -B${CPPZMQ} -DENABLE_DRAFTS=${ENABLE_DRAFTS} \
42-
-DCOVERAGE=${COVERAGE}
42+
-DCOVERAGE=${COVERAGE} \
43+
${CMAKE_CPP_STD:-}
4344
cmake --build ${CPPZMQ} -- -j${JOBS}
4445
popd
4546
}

tests/socket_ref.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ static_assert(std::is_nothrow_swappable_v<zmq::socket_ref>);
77
#endif
88
static_assert(sizeof(zmq::socket_ref) == sizeof(void *), "size mismatch");
99
static_assert(alignof(zmq::socket_ref) == alignof(void *), "alignment mismatch");
10-
static_assert(std::is_trivially_copyable<zmq::socket_ref>::value,
10+
static_assert(ZMQ_IS_TRIVIALLY_COPYABLE(zmq::socket_ref),
1111
"needs to be trivially copyable");
1212

1313
TEST_CASE("socket_ref default init", "[socket_ref]")

tests/utilities.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <catch.hpp>
22
#include <zmq.hpp>
33

4-
#ifdef ZMQ_CPP11
4+
#if defined(ZMQ_CPP11) && !defined(ZMQ_CPP11_PARTIAL)
55

66
namespace test_ns
77
{
@@ -16,11 +16,11 @@ struct T_mr
1616
struct T_fr
1717
{
1818
};
19-
void *begin(const T_fr &) noexcept
19+
inline void *begin(const T_fr &) noexcept
2020
{
2121
return nullptr;
2222
}
23-
void *end(const T_fr &) noexcept
23+
inline void *end(const T_fr &) noexcept
2424
{
2525
return nullptr;
2626
}
@@ -29,11 +29,11 @@ struct T_mfr
2929
void *begin() const noexcept { return nullptr; }
3030
void *end() const noexcept { return nullptr; }
3131
};
32-
void *begin(const T_mfr &) noexcept
32+
inline void *begin(const T_mfr &) noexcept
3333
{
3434
return nullptr;
3535
}
36-
void *end(const T_mfr &) noexcept
36+
inline void *end(const T_mfr &) noexcept
3737
{
3838
return nullptr;
3939
}
@@ -50,11 +50,11 @@ struct T_assoc_ns_mr : std::exception
5050
struct T_assoc_ns_fr : std::exception
5151
{
5252
};
53-
void *begin(const T_assoc_ns_fr &) noexcept
53+
inline void *begin(const T_assoc_ns_fr &) noexcept
5454
{
5555
return nullptr;
5656
}
57-
void *end(const T_assoc_ns_fr &) noexcept
57+
inline void *end(const T_assoc_ns_fr &) noexcept
5858
{
5959
return nullptr;
6060
}
@@ -63,11 +63,11 @@ struct T_assoc_ns_mfr : std::exception
6363
void *begin() const noexcept { return nullptr; }
6464
void *end() const noexcept { return nullptr; }
6565
};
66-
void *begin(const T_assoc_ns_mfr &) noexcept
66+
inline void *begin(const T_assoc_ns_mfr &) noexcept
6767
{
6868
return nullptr;
6969
}
70-
void *end(const T_assoc_ns_mfr &) noexcept
70+
inline void *end(const T_assoc_ns_mfr &) noexcept
7171
{
7272
return nullptr;
7373
}

zmq.hpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,18 @@
122122
#define ZMQ_DELETED_FUNCTION
123123
#endif
124124

125+
#if defined(ZMQ_CPP11) && defined(__GNUC__) && __GNUC__ < 5
126+
#define ZMQ_CPP11_PARTIAL
127+
#endif
128+
129+
#ifdef ZMQ_CPP11
130+
#ifdef ZMQ_CPP11_PARTIAL
131+
#define ZMQ_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
132+
#else
133+
#define ZMQ_IS_TRIVIALLY_COPYABLE(T) std::is_trivially_copyable<T>::value
134+
#endif
135+
#endif
136+
125137
#if ZMQ_VERSION >= ZMQ_MAKE_VERSION(3, 3, 0)
126138
#define ZMQ_NEW_MONITOR_EVENT_LAYOUT
127139
#endif
@@ -327,11 +339,11 @@ class message_t
327339
throw error_t();
328340
}
329341

330-
#ifdef ZMQ_CPP11
342+
#if defined(ZMQ_CPP11) && !defined(ZMQ_CPP11_PARTIAL)
331343
template<class Range,
332344
typename = typename std::enable_if<
333345
detail::is_range<Range>::value
334-
&& std::is_trivially_copyable<detail::range_value_t<Range>>::value
346+
&& ZMQ_IS_TRIVIALLY_COPYABLE(detail::range_value_t<Range>)
335347
&& !std::is_same<Range, message_t>::value>::type>
336348
explicit message_t(const Range &rng) :
337349
message_t(detail::ranges::begin(rng), detail::ranges::end(rng))
@@ -948,7 +960,7 @@ template<class T> struct is_pod_like
948960
// trivially copyable OR standard layout.
949961
// Here we decide to be conservative and require both.
950962
static constexpr bool value =
951-
std::is_trivially_copyable<T>::value && std::is_standard_layout<T>::value;
963+
ZMQ_IS_TRIVIALLY_COPYABLE(T) && std::is_standard_layout<T>::value;
952964
};
953965

954966
template<class C> constexpr auto seq_size(const C &c) noexcept -> decltype(c.size())

0 commit comments

Comments
 (0)