Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: if constexpr warnings on MSVC #460

Merged
merged 1 commit into from
Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions zmq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@
#endif
#if defined(ZMQ_CPP17)
#define ZMQ_INLINE_VAR inline
#define ZMQ_CONSTEXPR_IF constexpr
#else
#define ZMQ_INLINE_VAR
#define ZMQ_CONSTEXPR_IF
#endif

#include <cassert>
Expand Down Expand Up @@ -1769,17 +1771,19 @@ class socket_base
ZMQ_NODISCARD std::string get(sockopt::array_option<Opt, NullTerm>,
size_t init_size = 1024) const
{
if (NullTerm == 2 && init_size == 1024) {
init_size = 41; // get as Z85 string
if ZMQ_CONSTEXPR_IF (NullTerm == 2) {
if (init_size == 1024) {
init_size = 41; // get as Z85 string
}
}
std::string str(init_size, '\0');
size_t size = get(sockopt::array_option<Opt>{}, buffer(str));
if (NullTerm == 1) {
if ZMQ_CONSTEXPR_IF (NullTerm == 1) {
if (size > 0) {
assert(str[size - 1] == '\0');
--size;
}
} else if (NullTerm == 2) {
} else if ZMQ_CONSTEXPR_IF (NullTerm == 2) {
assert(size == 32 || size == 41);
if (size == 41) {
assert(str[size - 1] == '\0');
Expand Down
2 changes: 1 addition & 1 deletion zmq_addon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ recv_multipart_n(socket_ref s, OutputIt out, size_t n, recv_flags flags)
size_t msg_count = 0;
message_t msg;
while (true) {
if (CheckN) {
if ZMQ_CONSTEXPR_IF (CheckN) {
if (msg_count >= n)
throw std::runtime_error(
"Too many message parts in recv_multipart_n");
Expand Down