diff --git a/tests/message.cpp b/tests/message.cpp index 960e776..f882865 100644 --- a/tests/message.cpp +++ b/tests/message.cpp @@ -48,6 +48,23 @@ TEST_CASE("message constructor with iterators", "[message]") CHECK(0 == memcmp(data, hi_msg.data(), 2)); } +TEST_CASE("message constructor with ranges", "[message]") +{ + SECTION("trivial type") + { + const std::vector v{1, 2, 3}; + const zmq::message_t msg(v); + CHECK(3u * sizeof(int) == msg.size()); + } + SECTION("char type") + { + const std::vector hi{'H', 'i'}; + const zmq::message_t hi_msg(hi); + CHECK(2u == hi_msg.size()); + CHECK(0 == memcmp(data, hi_msg.data(), 2)); + } +} + TEST_CASE("message constructor with size", "[message]") { const zmq::message_t msg(5); diff --git a/zmq.hpp b/zmq.hpp index 3b265bf..2e3fc2f 100644 --- a/zmq.hpp +++ b/zmq.hpp @@ -492,8 +492,11 @@ class message_t typename = typename std::enable_if< detail::is_range::value && ZMQ_IS_TRIVIALLY_COPYABLE(detail::range_value_t) - && !detail::is_char_type>::value - && !std::is_same::value>::type> + && !std::is_same::value +#if CPPZMQ_HAS_STRING_VIEW + && !std::is_same::value +#endif + && !std::is_same::value>::type> explicit message_t(const Range &rng) : message_t(detail::ranges::begin(rng), detail::ranges::end(rng)) {