Problem: message_t ctor for ranges too greedy

Solution: Detect ranges with enable_if idiom
This commit is contained in:
Gudmundur Adalsteinsson
2019-05-15 16:49:22 +00:00
parent d25c58a05d
commit 09ab20801a
3 changed files with 57 additions and 5 deletions

View File

@@ -13,6 +13,17 @@ static_assert(std::is_nothrow_swappable<zmq::message_t>::value,
"message_t should be nothrow swappable");
#endif
#ifdef ZMQ_CPP11
TEST_CASE("range SFINAE", "[message]")
{
CHECK(!zmq::detail::is_range<int>::value);
CHECK(zmq::detail::is_range<std::string>::value);
CHECK(zmq::detail::is_range<std::string&>::value);
CHECK(zmq::detail::is_range<const std::string&>::value);
CHECK(zmq::detail::is_range<decltype("hello")>::value);
}
#endif
TEST_CASE("message default constructed", "[message]")
{
const zmq::message_t message;
@@ -48,6 +59,12 @@ TEST_CASE("message constructor with iterators", "[message]")
CHECK(0 == memcmp(data, hi_msg.data(), 2));
}
TEST_CASE("message constructor with size", "[message]")
{
const zmq::message_t msg(5);
CHECK(msg.size() == 5);
}
TEST_CASE("message constructor with buffer and size", "[message]")
{
const std::string hi(data);