File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,23 @@ TEST_CASE("message constructor with iterators", "[message]")
4848 CHECK (0 == memcmp (data, hi_msg.data (), 2 ));
4949}
5050
51+ TEST_CASE (" message constructor with ranges" , " [message]" )
52+ {
53+ SECTION (" trivial type" )
54+ {
55+ const std::vector<int > v{1 , 2 , 3 };
56+ const zmq::message_t msg (v);
57+ CHECK (3u * sizeof (int ) == msg.size ());
58+ }
59+ SECTION (" char type" )
60+ {
61+ const std::vector<char > hi{' H' , ' i' };
62+ const zmq::message_t hi_msg (hi);
63+ CHECK (2u == hi_msg.size ());
64+ CHECK (0 == memcmp (data, hi_msg.data (), 2 ));
65+ }
66+ }
67+
5168TEST_CASE (" message constructor with size" , " [message]" )
5269{
5370 const zmq::message_t msg (5 );
Original file line number Diff line number Diff line change @@ -492,8 +492,11 @@ class message_t
492492 typename = typename std::enable_if<
493493 detail::is_range<Range>::value
494494 && ZMQ_IS_TRIVIALLY_COPYABLE(detail::range_value_t <Range>)
495- && !detail::is_char_type<detail::range_value_t<Range>>::value
496- && !std::is_same<Range, message_t>::value>::type>
495+ && !std::is_same<Range, message_t>::value
496+ #if CPPZMQ_HAS_STRING_VIEW
497+ && !std::is_same<Range, std::string_view>::value
498+ #endif
499+ && !std::is_same<Range, std::string>::value>::type>
497500 explicit message_t (const Range &rng) :
498501 message_t(detail::ranges::begin(rng), detail::ranges::end(rng))
499502 {
You can’t perform that action at this time.
0 commit comments