Skip to content

Commit

Permalink
Move new constructors into standard version guard
Browse files Browse the repository at this point in the history
  • Loading branch information
gummif committed Apr 3, 2020
1 parent 6139c1e commit ca19cf3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
7 changes: 4 additions & 3 deletions tests/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ TEST_CASE("message constructor with container - deprecated", "[message]")
REQUIRE(3u == hi_msg.size());
CHECK(0 == memcmp(data, hi_msg.data(), 3));
}
#endif

TEST_CASE("message constructor with strings/buffers", "[message]")
{
Expand All @@ -98,7 +97,6 @@ TEST_CASE("message constructor with strings/buffers", "[message]")
}
#endif

#ifdef ZMQ_CPP11
SECTION("buffer")
{
zmq::message_t hi_msg(zmq::buffer(data, 2));
Expand All @@ -112,8 +110,8 @@ TEST_CASE("message constructor with strings/buffers", "[message]")
CHECK(2u == hi_msg.size());
CHECK(0 == memcmp(data, hi_msg.data(), 2));
}
#endif
}
#endif

#ifdef ZMQ_HAS_RVALUE_REFS
TEST_CASE("message move constructor", "[message]")
Expand Down Expand Up @@ -197,9 +195,12 @@ TEST_CASE("message to string", "[message]")
CHECK(a.to_string_view() == "");
CHECK(b.to_string_view() == "Foo");
#endif

#if defined(ZMQ_CPP11) && !defined(ZMQ_CPP11_PARTIAL)
const zmq::message_t depr("Foo"); // deprecated functionality
CHECK(depr.to_string() != "Foo");
CHECK(depr.to_string() == std::string("Foo", 4));
#endif
}

#if defined(ZMQ_BUILD_DRAFT_API) && ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 2, 0)
Expand Down
15 changes: 7 additions & 8 deletions zmq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ class message_t
throw error_t();
}

// overload set of string-like types, buffers and generic containers
#if defined(ZMQ_CPP11) && !defined(ZMQ_CPP11_PARTIAL)
// NOTE this constructor will include the null terminator
// when called with a string literal.
Expand All @@ -698,14 +699,6 @@ class message_t
message_t(detail::ranges::begin(rng), detail::ranges::end(rng))
{
}
#endif

#ifdef ZMQ_CPP11
explicit message_t(const_buffer buf) :
message_t(buf.data(), buf.size())
{
}
#endif

explicit message_t(const std::string &str) :
message_t(str.data(), str.size())
Expand All @@ -719,6 +712,12 @@ class message_t
}
#endif

explicit message_t(const_buffer buf) :
message_t(buf.data(), buf.size())
{
}
#endif

#ifdef ZMQ_HAS_RVALUE_REFS
message_t(message_t &&rhs) ZMQ_NOTHROW : msg(rhs.msg)
{
Expand Down

0 comments on commit ca19cf3

Please sign in to comment.