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:
}
void operator()(Ts... xs) {
if constexpr (std::is_convertible<R, Bhvr>::value) {
if constexpr (std::is_convertible_v<R, Bhvr>) {
auto bhvr = f_(xs...);
*bhvr_ = std::move(bhvr.unbox());
} else {
......@@ -59,7 +59,7 @@ public:
}
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...);
*bhvr_ = std::move(bhvr.unbox());
} else {
......
......@@ -16,7 +16,7 @@ template <class F>
struct catch_all {
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 "
"skippable_result (message&)");
......
......@@ -40,7 +40,7 @@ struct implicit_actor_conversions<actor_control_block, false, false> {
template <class T>
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>>;
};
......
......@@ -125,7 +125,7 @@ public:
using res_type = typename trait::result_type;
using first_arg = typename detail::tl_head<arg_types>::type;
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 helper = init_fun_factory_helper<Base, F, tuple_type, rets, selfptr>;
return ptr_type{new helper{std::move(f), sizeof...(Ts) > 0
......
......@@ -152,7 +152,7 @@ public:
template <class T>
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>
builtin_inspect(const T& x) {
auto str = to_string(x);
......
......@@ -88,7 +88,7 @@ private:
using result = decltype(sfinae(std::declval<const T&>()));
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>
......@@ -136,9 +136,9 @@ struct is_duration<std::chrono::duration<Period, Rep>> : std::true_type {};
/// convertible to one of STL's string types.
template <class T>
struct is_primitive {
static constexpr bool value = std::is_convertible<T, std::string>::value
|| std::is_convertible<T, std::u16string>::value
|| std::is_convertible<T, std::u32string>::value
static constexpr bool value = std::is_convertible_v<T, std::string>
|| std::is_convertible_v<T, std::u16string>
|| std::is_convertible_v<T, std::u32string>
|| std::is_arithmetic<T>::value;
};
......@@ -449,8 +449,8 @@ CAF_HAS_MEMBER_TRAIT(size);
template <class F, class T>
struct is_handler_for {
static constexpr bool value
= std::is_convertible<F, std::function<void(T&)>>::value
|| std::is_convertible<F, std::function<void(const T&)>>::value;
= std::is_convertible_v<F, std::function<void(T&)>>
|| std::is_convertible_v<F, std::function<void(const T&)>>;
};
template <class T>
......@@ -808,8 +808,9 @@ template <class T, class To>
class has_convertible_data_member {
private:
template <class U>
static auto sfinae(U* x) -> std::integral_constant<
bool, std::is_convertible<decltype(x->data()), To*>::value>;
static auto sfinae(U* x)
-> std::integral_constant<bool,
std::is_convertible_v<decltype(x->data()), To*>>;
template <class U>
static auto sfinae(...) -> std::false_type;
......@@ -917,7 +918,7 @@ struct is_trivial_inspector_value<true, T> {
template <class 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) \
......
......@@ -85,7 +85,7 @@ public:
template <
class T,
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>()...)),
R>::value>::type>
explicit unique_function(T f) : unique_function(make_wrapper(std::move(f))) {
......@@ -129,7 +129,7 @@ public:
template <class Fn>
void emplace(Fn fn) {
destroy();
if constexpr (std::is_convertible<Fn, raw_pointer>::value) {
if constexpr (std::is_convertible_v<Fn, raw_pointer>) {
holds_wrapper_ = false;
fptr_ = fn;
} else {
......
......@@ -95,7 +95,7 @@ int exec_main(F fun, int argc, char** argv) {
}
helper f;
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);
} else {
f(fun, system, cfg);
......
......@@ -155,7 +155,7 @@ public:
}
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) {
return *this = T{std::move(x)};
}
......
......@@ -87,8 +87,7 @@ public:
template <class Y>
intrusive_ptr(intrusive_ptr<Y> other) noexcept : ptr_(other.detach()) {
static_assert(std::is_convertible<Y*, T*>::value,
"Y* is not assignable to T*");
static_assert(std::is_convertible_v<Y*, T*>, "Y* is not assignable to T*");
}
~intrusive_ptr() {
......
......@@ -134,7 +134,7 @@ public:
return false;
}
} 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");
if (dref().apply(tmp)) {
if (auto err = set(std::move(tmp)); !err) {
......
......@@ -34,7 +34,7 @@ public:
/// Creates an valid instance from `value`.
template <class U,
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) {
cr(std::move(x));
}
......
......@@ -51,8 +51,7 @@ public:
template <class Y>
weak_intrusive_ptr(weak_intrusive_ptr<Y> other) noexcept
: ptr_(other.detach()) {
static_assert(std::is_convertible<Y*, T*>::value,
"Y* is not assignable to T*");
static_assert(std::is_convertible_v<Y*, T*>, "Y* is not assignable to T*");
}
~weak_intrusive_ptr() {
......
......@@ -28,17 +28,17 @@ using dummy1 = typed_actor<result<void>(int, int), result<double>(double)>;
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");
using dummy3 = typed_actor<result<void>(float, int)>;
using dummy4 = typed_actor<result<double>(int)>;
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");
static_assert(std::is_convertible<dummy5, dummy4>::value,
static_assert(std::is_convertible_v<dummy5, dummy4>,
"handle not assignable to narrower definition");
// -- simple request/response test ---------------------------------------------
......
......@@ -123,13 +123,13 @@ public:
expected<connection_handle> add_tcp_scribe(const std::string& host,
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");
return super::add_tcp_scribe(host, port);
}
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");
return super::add_tcp_scribe(fd);
}
......@@ -137,13 +137,13 @@ public:
expected<std::pair<accept_handle, uint16_t>>
add_tcp_doorman(uint16_t port = 0, const char* in = nullptr,
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");
return super::add_tcp_doorman(port, in, reuse_addr);
}
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");
return super::add_tcp_doorman(fd);
}
......
......@@ -68,9 +68,9 @@ struct equality_operator {
template <class T, class U,
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_convertible<T, double>::value))
&& std::is_convertible_v<T, double>) )
&& detail::is_comparable<T, U>::value,
int>
= 0>
......@@ -84,9 +84,9 @@ struct equality_operator {
template <class T, class U,
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_convertible<T, double>::value))
&& std::is_convertible_v<T, double>) )
&& detail::is_comparable<T, U>::value,
int>
= 0>
......@@ -294,7 +294,7 @@ public:
};
using fwd =
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>,
simple_fwd_t, deep_to_string_t>::type;
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