Commit c37e971a authored by Shariar Azad Riday's avatar Shariar Azad Riday

refactor is_convertible<>::value to is_convertible_v<>

parent ba671c7c
...@@ -36,7 +36,7 @@ public: ...@@ -36,7 +36,7 @@ public:
} }
void operator()(Ts... xs) { void operator()(Ts... xs) {
if constexpr (std::is_convertible<R, Bhvr>::value) { if constexpr (std::is_convertible_v<R, Bhvr>) {
auto bhvr = f_(xs...); auto bhvr = f_(xs...);
*bhvr_ = std::move(bhvr.unbox()); *bhvr_ = std::move(bhvr.unbox());
} else { } else {
...@@ -59,7 +59,7 @@ public: ...@@ -59,7 +59,7 @@ public:
} }
void operator()(Ts... xs) { void operator()(Ts... xs) {
if constexpr (std::is_convertible<R, Bhvr>::value) { if constexpr (std::is_convertible_v<R, Bhvr>) {
auto bhvr = f_(ptr_, xs...); auto bhvr = f_(ptr_, xs...);
*bhvr_ = std::move(bhvr.unbox()); *bhvr_ = std::move(bhvr.unbox());
} else { } else {
......
...@@ -16,7 +16,7 @@ template <class F> ...@@ -16,7 +16,7 @@ template <class F>
struct catch_all { struct catch_all {
using fun_type = std::function<skippable_result(message&)>; using fun_type = std::function<skippable_result(message&)>;
static_assert(std::is_convertible<F, fun_type>::value, static_assert(std::is_convertible_v<F, fun_type>,
"catch-all handler must have signature " "catch-all handler must have signature "
"skippable_result (message&)"); "skippable_result (message&)");
......
...@@ -40,7 +40,7 @@ struct implicit_actor_conversions<actor_control_block, false, false> { ...@@ -40,7 +40,7 @@ struct implicit_actor_conversions<actor_control_block, false, false> {
template <class T> template <class T>
struct implicit_conversions { struct implicit_conversions {
using type = std::conditional_t<std::is_convertible<T, error>::value, error, using type = std::conditional_t<std::is_convertible_v<T, error>, error,
squash_if_int_t<T>>; squash_if_int_t<T>>;
}; };
......
...@@ -125,7 +125,7 @@ public: ...@@ -125,7 +125,7 @@ public:
using res_type = typename trait::result_type; using res_type = typename trait::result_type;
using first_arg = typename detail::tl_head<arg_types>::type; using first_arg = typename detail::tl_head<arg_types>::type;
constexpr bool selfptr = std::is_pointer_v<first_arg>; constexpr bool selfptr = std::is_pointer_v<first_arg>;
constexpr bool rets = std::is_convertible<res_type, behavior>::value; constexpr bool rets = std::is_convertible_v<res_type, behavior>;
using tuple_type = decltype(std::make_tuple(detail::spawn_fwd<Ts>(xs)...)); using tuple_type = decltype(std::make_tuple(detail::spawn_fwd<Ts>(xs)...));
using helper = init_fun_factory_helper<Base, F, tuple_type, rets, selfptr>; using helper = init_fun_factory_helper<Base, F, tuple_type, rets, selfptr>;
return ptr_type{new helper{std::move(f), sizeof...(Ts) > 0 return ptr_type{new helper{std::move(f), sizeof...(Ts) > 0
......
...@@ -152,7 +152,7 @@ public: ...@@ -152,7 +152,7 @@ public:
template <class T> template <class T>
std::enable_if_t<has_to_string<T>::value std::enable_if_t<has_to_string<T>::value
&& !std::is_convertible<T, std::string_view>::value, && !std::is_convertible_v<T, std::string_view>,
bool> bool>
builtin_inspect(const T& x) { builtin_inspect(const T& x) {
auto str = to_string(x); auto str = to_string(x);
......
...@@ -88,7 +88,7 @@ private: ...@@ -88,7 +88,7 @@ private:
using result = decltype(sfinae(std::declval<const T&>())); using result = decltype(sfinae(std::declval<const T&>()));
public: public:
static constexpr bool value = std::is_convertible<result, std::string>::value; static constexpr bool value = std::is_convertible_v<result, std::string>;
}; };
template <bool X> template <bool X>
...@@ -136,9 +136,9 @@ struct is_duration<std::chrono::duration<Period, Rep>> : std::true_type {}; ...@@ -136,9 +136,9 @@ struct is_duration<std::chrono::duration<Period, Rep>> : std::true_type {};
/// convertible to one of STL's string types. /// convertible to one of STL's string types.
template <class T> template <class T>
struct is_primitive { struct is_primitive {
static constexpr bool value = std::is_convertible<T, std::string>::value static constexpr bool value = std::is_convertible_v<T, std::string>
|| std::is_convertible<T, std::u16string>::value || std::is_convertible_v<T, std::u16string>
|| std::is_convertible<T, std::u32string>::value || std::is_convertible_v<T, std::u32string>
|| std::is_arithmetic<T>::value; || std::is_arithmetic<T>::value;
}; };
...@@ -449,8 +449,8 @@ CAF_HAS_MEMBER_TRAIT(size); ...@@ -449,8 +449,8 @@ CAF_HAS_MEMBER_TRAIT(size);
template <class F, class T> template <class F, class T>
struct is_handler_for { struct is_handler_for {
static constexpr bool value static constexpr bool value
= std::is_convertible<F, std::function<void(T&)>>::value = std::is_convertible_v<F, std::function<void(T&)>>
|| std::is_convertible<F, std::function<void(const T&)>>::value; || std::is_convertible_v<F, std::function<void(const T&)>>;
}; };
template <class T> template <class T>
...@@ -808,8 +808,9 @@ template <class T, class To> ...@@ -808,8 +808,9 @@ template <class T, class To>
class has_convertible_data_member { class has_convertible_data_member {
private: private:
template <class U> template <class U>
static auto sfinae(U* x) -> std::integral_constant< static auto sfinae(U* x)
bool, std::is_convertible<decltype(x->data()), To*>::value>; -> std::integral_constant<bool,
std::is_convertible_v<decltype(x->data()), To*>>;
template <class U> template <class U>
static auto sfinae(...) -> std::false_type; static auto sfinae(...) -> std::false_type;
...@@ -917,7 +918,7 @@ struct is_trivial_inspector_value<true, T> { ...@@ -917,7 +918,7 @@ struct is_trivial_inspector_value<true, T> {
template <class T> template <class T>
struct is_trivial_inspector_value<false, T> { struct is_trivial_inspector_value<false, T> {
static constexpr bool value = std::is_convertible<T, std::string_view>::value; static constexpr bool value = std::is_convertible_v<T, std::string_view>;
}; };
#define CAF_ADD_TRIVIAL_LOAD_INSPECTOR_VALUE(type) \ #define CAF_ADD_TRIVIAL_LOAD_INSPECTOR_VALUE(type) \
......
...@@ -85,7 +85,7 @@ public: ...@@ -85,7 +85,7 @@ public:
template < template <
class T, class T,
class = typename std::enable_if< class = typename std::enable_if<
!std::is_convertible<T, raw_pointer>::value !std::is_convertible_v<T, raw_pointer>
&& std::is_same<decltype((std::declval<T&>())(std::declval<Ts>()...)), && std::is_same<decltype((std::declval<T&>())(std::declval<Ts>()...)),
R>::value>::type> R>::value>::type>
explicit unique_function(T f) : unique_function(make_wrapper(std::move(f))) { explicit unique_function(T f) : unique_function(make_wrapper(std::move(f))) {
...@@ -129,7 +129,7 @@ public: ...@@ -129,7 +129,7 @@ public:
template <class Fn> template <class Fn>
void emplace(Fn fn) { void emplace(Fn fn) {
destroy(); destroy();
if constexpr (std::is_convertible<Fn, raw_pointer>::value) { if constexpr (std::is_convertible_v<Fn, raw_pointer>) {
holds_wrapper_ = false; holds_wrapper_ = false;
fptr_ = fn; fptr_ = fn;
} else { } else {
......
...@@ -95,7 +95,7 @@ int exec_main(F fun, int argc, char** argv) { ...@@ -95,7 +95,7 @@ int exec_main(F fun, int argc, char** argv) {
} }
helper f; helper f;
using result_type = decltype(f(fun, system, cfg)); using result_type = decltype(f(fun, system, cfg));
if constexpr (std::is_convertible<result_type, int>::value) { if constexpr (std::is_convertible_v<result_type, int>) {
return f(fun, system, cfg); return f(fun, system, cfg);
} else { } else {
f(fun, system, cfg); f(fun, system, cfg);
......
...@@ -155,7 +155,7 @@ public: ...@@ -155,7 +155,7 @@ public:
} }
template <class U> template <class U>
typename std::enable_if<std::is_convertible<U, T>::value, expected&>::type typename std::enable_if<std::is_convertible_v<U, T>, expected&>::type
operator=(U x) { operator=(U x) {
return *this = T{std::move(x)}; return *this = T{std::move(x)};
} }
......
...@@ -87,8 +87,7 @@ public: ...@@ -87,8 +87,7 @@ public:
template <class Y> template <class Y>
intrusive_ptr(intrusive_ptr<Y> other) noexcept : ptr_(other.detach()) { intrusive_ptr(intrusive_ptr<Y> other) noexcept : ptr_(other.detach()) {
static_assert(std::is_convertible<Y*, T*>::value, static_assert(std::is_convertible_v<Y*, T*>, "Y* is not assignable to T*");
"Y* is not assignable to T*");
} }
~intrusive_ptr() { ~intrusive_ptr() {
......
...@@ -134,7 +134,7 @@ public: ...@@ -134,7 +134,7 @@ public:
return false; return false;
} }
} else { } else {
static_assert(std::is_convertible<setter_result, error>::value, static_assert(std::is_convertible_v<setter_result, error>,
"a setter must return caf::error, bool or void"); "a setter must return caf::error, bool or void");
if (dref().apply(tmp)) { if (dref().apply(tmp)) {
if (auto err = set(std::move(tmp)); !err) { if (auto err = set(std::move(tmp)); !err) {
......
...@@ -34,7 +34,7 @@ public: ...@@ -34,7 +34,7 @@ public:
/// Creates an valid instance from `value`. /// Creates an valid instance from `value`.
template <class U, template <class U,
class E class E
= typename std::enable_if<std::is_convertible<U, T>::value>::type> = typename std::enable_if<std::is_convertible_v<U, T>>::type>
optional(U x) : m_valid(false) { optional(U x) : m_valid(false) {
cr(std::move(x)); cr(std::move(x));
} }
......
...@@ -51,8 +51,7 @@ public: ...@@ -51,8 +51,7 @@ public:
template <class Y> template <class Y>
weak_intrusive_ptr(weak_intrusive_ptr<Y> other) noexcept weak_intrusive_ptr(weak_intrusive_ptr<Y> other) noexcept
: ptr_(other.detach()) { : ptr_(other.detach()) {
static_assert(std::is_convertible<Y*, T*>::value, static_assert(std::is_convertible_v<Y*, T*>, "Y* is not assignable to T*");
"Y* is not assignable to T*");
} }
~weak_intrusive_ptr() { ~weak_intrusive_ptr() {
......
...@@ -28,17 +28,17 @@ using dummy1 = typed_actor<result<void>(int, int), result<double>(double)>; ...@@ -28,17 +28,17 @@ using dummy1 = typed_actor<result<void>(int, int), result<double>(double)>;
using dummy2 = dummy1::extend<result<void>(ok_atom)>; using dummy2 = dummy1::extend<result<void>(ok_atom)>;
static_assert(std::is_convertible<dummy2, dummy1>::value, static_assert(std::is_convertible_v<dummy2, dummy1>,
"handle not assignable to narrower definition"); "handle not assignable to narrower definition");
using dummy3 = typed_actor<result<void>(float, int)>; using dummy3 = typed_actor<result<void>(float, int)>;
using dummy4 = typed_actor<result<double>(int)>; using dummy4 = typed_actor<result<double>(int)>;
using dummy5 = dummy4::extend_with<dummy3>; using dummy5 = dummy4::extend_with<dummy3>;
static_assert(std::is_convertible<dummy5, dummy3>::value, static_assert(std::is_convertible_v<dummy5, dummy3>,
"handle not assignable to narrower definition"); "handle not assignable to narrower definition");
static_assert(std::is_convertible<dummy5, dummy4>::value, static_assert(std::is_convertible_v<dummy5, dummy4>,
"handle not assignable to narrower definition"); "handle not assignable to narrower definition");
// -- simple request/response test --------------------------------------------- // -- simple request/response test ---------------------------------------------
......
...@@ -123,13 +123,13 @@ public: ...@@ -123,13 +123,13 @@ public:
expected<connection_handle> add_tcp_scribe(const std::string& host, expected<connection_handle> add_tcp_scribe(const std::string& host,
uint16_t port) { uint16_t port) {
static_assert(std::is_convertible<actor_hdl, connection_handler>::value, static_assert(std::is_convertible_v<actor_hdl, connection_handler>,
"Cannot add scribe: broker misses required handlers"); "Cannot add scribe: broker misses required handlers");
return super::add_tcp_scribe(host, port); return super::add_tcp_scribe(host, port);
} }
connection_handle add_tcp_scribe(network::native_socket fd) { connection_handle add_tcp_scribe(network::native_socket fd) {
static_assert(std::is_convertible<actor_hdl, connection_handler>::value, static_assert(std::is_convertible_v<actor_hdl, connection_handler>,
"Cannot add scribe: broker misses required handlers"); "Cannot add scribe: broker misses required handlers");
return super::add_tcp_scribe(fd); return super::add_tcp_scribe(fd);
} }
...@@ -137,13 +137,13 @@ public: ...@@ -137,13 +137,13 @@ public:
expected<std::pair<accept_handle, uint16_t>> expected<std::pair<accept_handle, uint16_t>>
add_tcp_doorman(uint16_t port = 0, const char* in = nullptr, add_tcp_doorman(uint16_t port = 0, const char* in = nullptr,
bool reuse_addr = false) { bool reuse_addr = false) {
static_assert(std::is_convertible<actor_hdl, accept_handler>::value, static_assert(std::is_convertible_v<actor_hdl, accept_handler>,
"Cannot add doorman: broker misses required handlers"); "Cannot add doorman: broker misses required handlers");
return super::add_tcp_doorman(port, in, reuse_addr); return super::add_tcp_doorman(port, in, reuse_addr);
} }
expected<accept_handle> add_tcp_doorman(network::native_socket fd) { expected<accept_handle> add_tcp_doorman(network::native_socket fd) {
static_assert(std::is_convertible<actor_hdl, accept_handler>::value, static_assert(std::is_convertible_v<actor_hdl, accept_handler>,
"Cannot add doorman: broker misses required handlers"); "Cannot add doorman: broker misses required handlers");
return super::add_tcp_doorman(fd); return super::add_tcp_doorman(fd);
} }
......
...@@ -68,9 +68,9 @@ struct equality_operator { ...@@ -68,9 +68,9 @@ struct equality_operator {
template <class T, class U, template <class T, class U,
detail::enable_if_t<((std::is_floating_point<T>::value detail::enable_if_t<((std::is_floating_point<T>::value
&& std::is_convertible<U, double>::value) && std::is_convertible_v<U, double>)
|| (std::is_floating_point<U>::value || (std::is_floating_point<U>::value
&& std::is_convertible<T, double>::value)) && std::is_convertible_v<T, double>) )
&& detail::is_comparable<T, U>::value, && detail::is_comparable<T, U>::value,
int> int>
= 0> = 0>
...@@ -84,9 +84,9 @@ struct equality_operator { ...@@ -84,9 +84,9 @@ struct equality_operator {
template <class T, class U, template <class T, class U,
detail::enable_if_t<!((std::is_floating_point<T>::value detail::enable_if_t<!((std::is_floating_point<T>::value
&& std::is_convertible<U, double>::value) && std::is_convertible_v<U, double>)
|| (std::is_floating_point<U>::value || (std::is_floating_point<U>::value
&& std::is_convertible<T, double>::value)) && std::is_convertible_v<T, double>) )
&& detail::is_comparable<T, U>::value, && detail::is_comparable<T, U>::value,
int> int>
= 0> = 0>
...@@ -294,7 +294,7 @@ public: ...@@ -294,7 +294,7 @@ public:
}; };
using fwd = using fwd =
typename std::conditional<std::is_same_v<char, T> typename std::conditional<std::is_same_v<char, T>
|| std::is_convertible<T, std::string>::value || std::is_convertible_v<T, std::string>
|| std::is_same_v<caf::term, T>, || std::is_same_v<caf::term, T>,
simple_fwd_t, deep_to_string_t>::type; simple_fwd_t, deep_to_string_t>::type;
fwd f; fwd f;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment