1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
#include <catch2/catch.hpp>
#include <zmq.hpp>
#if defined(ZMQ_CPP11) && !defined(ZMQ_CPP11_PARTIAL)
namespace test_ns
{
struct T_nr
{
};
struct T_mr
{
void *begin() const noexcept { return nullptr; }
void *end() const noexcept { return nullptr; }
};
struct T_fr
{
};
inline void *begin(const T_fr &) noexcept
{
return nullptr;
}
inline void *end(const T_fr &) noexcept
{
return nullptr;
}
struct T_mfr
{
void *begin() const noexcept { return nullptr; }
void *end() const noexcept { return nullptr; }
};
inline void *begin(const T_mfr &) noexcept
{
return nullptr;
}
inline void *end(const T_mfr &) noexcept
{
return nullptr;
}
// types with associated namespace std
struct T_assoc_ns_nr : std::exception
{
};
struct T_assoc_ns_mr : std::exception
{
void *begin() const noexcept { return nullptr; }
void *end() const noexcept { return nullptr; }
};
struct T_assoc_ns_fr : std::exception
{
};
inline void *begin(const T_assoc_ns_fr &) noexcept
{
return nullptr;
}
inline void *end(const T_assoc_ns_fr &) noexcept
{
return nullptr;
}
struct T_assoc_ns_mfr : std::exception
{
void *begin() const noexcept { return nullptr; }
void *end() const noexcept { return nullptr; }
};
inline void *begin(const T_assoc_ns_mfr &) noexcept
{
return nullptr;
}
inline void *end(const T_assoc_ns_mfr &) noexcept
{
return nullptr;
}
} // namespace test_ns
TEST_CASE("range SFINAE", "[utilities]")
{
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);
CHECK(zmq::detail::is_range<std::initializer_list<int>>::value);
CHECK(!zmq::detail::is_range<test_ns::T_nr>::value);
CHECK(zmq::detail::is_range<test_ns::T_mr>::value);
CHECK(zmq::detail::is_range<test_ns::T_fr>::value);
CHECK(zmq::detail::is_range<test_ns::T_mfr>::value);
CHECK(!zmq::detail::is_range<test_ns::T_assoc_ns_nr>::value);
CHECK(zmq::detail::is_range<test_ns::T_assoc_ns_mr>::value);
CHECK(zmq::detail::is_range<test_ns::T_assoc_ns_fr>::value);
CHECK(zmq::detail::is_range<test_ns::T_assoc_ns_mfr>::value);
}
#endif
|