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