Skip to content

Commit c591113

Browse files
authored
Merge pull request #460 from gummif/gfa/if-warn
Problem: if constexpr warnings on MSVC
2 parents d7a9909 + a7889af commit c591113

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

zmq.hpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@
9797
#endif
9898
#if defined(ZMQ_CPP17)
9999
#define ZMQ_INLINE_VAR inline
100+
#define ZMQ_CONSTEXPR_IF constexpr
100101
#else
101102
#define ZMQ_INLINE_VAR
103+
#define ZMQ_CONSTEXPR_IF
102104
#endif
103105

104106
#include <cassert>
@@ -1769,17 +1771,19 @@ class socket_base
17691771
ZMQ_NODISCARD std::string get(sockopt::array_option<Opt, NullTerm>,
17701772
size_t init_size = 1024) const
17711773
{
1772-
if (NullTerm == 2 && init_size == 1024) {
1773-
init_size = 41; // get as Z85 string
1774+
if ZMQ_CONSTEXPR_IF (NullTerm == 2) {
1775+
if (init_size == 1024) {
1776+
init_size = 41; // get as Z85 string
1777+
}
17741778
}
17751779
std::string str(init_size, '\0');
17761780
size_t size = get(sockopt::array_option<Opt>{}, buffer(str));
1777-
if (NullTerm == 1) {
1781+
if ZMQ_CONSTEXPR_IF (NullTerm == 1) {
17781782
if (size > 0) {
17791783
assert(str[size - 1] == '\0');
17801784
--size;
17811785
}
1782-
} else if (NullTerm == 2) {
1786+
} else if ZMQ_CONSTEXPR_IF (NullTerm == 2) {
17831787
assert(size == 32 || size == 41);
17841788
if (size == 41) {
17851789
assert(str[size - 1] == '\0');

zmq_addon.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ recv_multipart_n(socket_ref s, OutputIt out, size_t n, recv_flags flags)
4949
size_t msg_count = 0;
5050
message_t msg;
5151
while (true) {
52-
if (CheckN) {
52+
if ZMQ_CONSTEXPR_IF (CheckN) {
5353
if (msg_count >= n)
5454
throw std::runtime_error(
5555
"Too many message parts in recv_multipart_n");

0 commit comments

Comments
 (0)