Unverified Commit b3478445 authored by Shariar Azad Riday's avatar Shariar Azad Riday Committed by GitHub

Prefer $pred_t<> over $pred<>::type

parent 77f80967
......@@ -149,8 +149,8 @@ public:
/// handle or raw pointer of type `T`.
template <class T, class U>
T actor_cast(U&& what) {
using from_type =
typename std::remove_const<typename std::remove_reference<U>::type>::type;
// Should use remove_cvref in C++20.
using from_type = std::remove_const_t<std::remove_reference_t<U>>;
// query traits for T
constexpr bool to_raw = std::is_pointer_v<T>;
constexpr bool to_weak = is_weak_ptr_v<T>;
......
......@@ -103,7 +103,7 @@ actor_factory make_actor_factory(F fun) {
return {};
cfg.init_fun = actor_config::init_fun_type{
[=](local_actor* x) mutable -> behavior {
using ctrait = typename detail::get_callable_trait<F>::type;
using ctrait = detail::get_callable_trait_t<F>;
using fd = fun_decorator<F, impl, behavior_t, trait::mode,
typename ctrait::result_type,
typename ctrait::arg_types>;
......@@ -132,7 +132,7 @@ struct dyn_spawn_class_helper {
template <class T, class... Ts>
actor_factory_result dyn_spawn_class(actor_config& cfg, message& msg) {
CAF_ASSERT(cfg.host);
using handle = typename infer_handle_from_class<T>::type;
using handle = infer_handle_from_class_t<T>;
handle hdl;
message_handler factory{dyn_spawn_class_helper<handle, T, Ts...>{hdl, cfg}};
factory(msg);
......@@ -142,7 +142,7 @@ actor_factory_result dyn_spawn_class(actor_config& cfg, message& msg) {
template <class T, class... Ts>
actor_factory make_actor_factory() {
static_assert(detail::conjunction<std::is_lvalue_reference_v<Ts>...>::value,
static_assert(detail::conjunction_v<std::is_lvalue_reference_v<Ts>...>,
"all Ts must be lvalue references");
static_assert(std::is_base_of_v<local_actor, T>,
"T is not derived from local_actor");
......
......@@ -120,7 +120,7 @@ public:
/// @experimental
template <class T, class... Ts>
actor_system_config& add_actor_type(std::string name) {
using handle = typename infer_handle_from_class<T>::type;
using handle = infer_handle_from_class_t<T>;
static_assert(detail::is_complete<type_id<handle>>);
return add_actor_factory(std::move(name), make_actor_factory<T, Ts...>());
}
......@@ -130,7 +130,7 @@ public:
/// @experimental
template <class F>
actor_system_config& add_actor_type(std::string name, F f) {
using handle = typename infer_handle_from_fun<F>::type;
using handle = infer_handle_from_fun_t<F>;
static_assert(detail::is_complete<type_id<handle>>);
return add_actor_factory(std::move(name), make_actor_factory(std::move(f)));
}
......
......@@ -306,9 +306,8 @@ public:
static_assert(sizeof...(Ts), "at least one argument required");
// extract how many arguments are actually the behavior part,
// i.e., neither `after(...) >> ...` nor `others >> ...`.
using filtered =
typename tl_filter_not<type_list<typename std::decay<Ts>::type...>,
is_timeout_or_catch_all>::type;
using filtered = tl_filter_not_t<type_list<std::decay_t<Ts>...>,
is_timeout_or_catch_all>;
filtered tk;
behavior bhvr{apply_moved_args(make_behavior_impl, get_indices(tk), tup)};
using tail_indices =
......
......@@ -11,7 +11,7 @@ namespace caf {
template <class T>
struct signatures_of {
using type = typename std::remove_pointer<T>::type::signatures;
using type = typename std::remove_pointer_t<T>::signatures;
};
template <class T>
......@@ -19,8 +19,7 @@ using signatures_of_t = typename signatures_of<T>::type;
template <class T>
constexpr bool statically_typed() {
return !std::is_same<
none_t, typename std::remove_pointer<T>::type::signatures>::value;
return !std::is_same_v<none_t, typename std::remove_pointer_t<T>::signatures>;
}
template <class T>
......
......@@ -104,8 +104,8 @@ private:
/// Creates a new copy-on-write tuple from given arguments.
/// @relates cow_tuple
template <class... Ts>
cow_tuple<typename std::decay<Ts>::type...> make_cow_tuple(Ts&&... xs) {
return cow_tuple<typename std::decay<Ts>::type...>{std::forward<Ts>(xs)...};
cow_tuple<std::decay_t<Ts>...> make_cow_tuple(Ts&&... xs) {
return cow_tuple<std::decay_t<Ts>...>{std::forward<Ts>(xs)...};
}
/// Convenience function for calling `get<N>(xs.data())`.
......
......@@ -120,10 +120,10 @@ public:
ptr_type make(F f, Ts&&... xs) {
static_assert(std::is_base_of_v<local_actor, Base>,
"Given Base does not extend local_actor");
using trait = typename detail::get_callable_trait<F>::type;
using trait = detail::get_callable_trait_t<F>;
using arg_types = typename trait::arg_types;
using res_type = typename trait::result_type;
using first_arg = typename detail::tl_head<arg_types>::type;
using first_arg = detail::tl_head_t<arg_types>;
constexpr bool selfptr = std::is_pointer_v<first_arg>;
constexpr bool rets = std::is_convertible_v<res_type, behavior>;
using tuple_type = decltype(std::make_tuple(detail::spawn_fwd<Ts>(xs)...));
......
......@@ -171,7 +171,7 @@ void read_floating_point(State& ps, Consumer&& consumer,
template <class State, class Consumer>
void read_floating_point(State& ps, Consumer&& consumer) {
using consumer_type = typename std::decay<Consumer>::type;
using consumer_type = std::decay_t<Consumer>;
using value_type = typename consumer_type::value_type;
return read_floating_point(ps, consumer, std::optional<value_type>{});
}
......
......@@ -26,7 +26,7 @@ namespace caf::detail::parser {
/// `double`.
template <class State, class Consumer>
void read_signed_integer(State& ps, Consumer&& consumer) {
using consumer_type = typename std::decay<Consumer>::type;
using consumer_type = std::decay_t<Consumer>;
using value_type = typename consumer_type::value_type;
static_assert(std::is_integral_v<value_type> && std::is_signed_v<value_type>,
"expected a signed integer type");
......
......@@ -26,7 +26,7 @@ namespace caf::detail::parser {
/// `double`.
template <class State, class Consumer>
void read_unsigned_integer(State& ps, Consumer&& consumer) {
using consumer_type = typename std::decay<Consumer>::type;
using consumer_type = std::decay_t<Consumer>;
using value_type = typename consumer_type::value_type;
static_assert(std::is_integral_v<value_type>
&& std::is_unsigned_v<value_type>,
......
......@@ -26,20 +26,18 @@ struct spawn_fwd_convert<T*> {
/// Converts `scoped_actor` and pointers to actors to handles of type `actor`
/// but simply forwards any other argument in the same way `std::forward` does.
template <class T>
typename std::conditional<
spawn_fwd_convert<typename std::remove_reference<T>::type>::value, actor,
T&&>::type
spawn_fwd(typename std::remove_reference<T>::type& arg) noexcept {
std::conditional_t<spawn_fwd_convert<std::remove_reference_t<T>>::value, actor,
T&&>
spawn_fwd(std::remove_reference_t<T>& arg) noexcept {
return static_cast<T&&>(arg);
}
/// Converts `scoped_actor` and pointers to actors to handles of type `actor`
/// but simply forwards any other argument in the same way `std::forward` does.
template <class T>
typename std::conditional<
spawn_fwd_convert<typename std::remove_reference<T>::type>::value, actor,
T&&>::type
spawn_fwd(typename std::remove_reference<T>::type&& arg) noexcept {
std::conditional_t<spawn_fwd_convert<std::remove_reference_t<T>>::value, actor,
T&&>
spawn_fwd(std::remove_reference_t<T>&& arg) noexcept {
static_assert(!std::is_lvalue_reference_v<T>,
"silently converting an lvalue to an rvalue");
return static_cast<T&&>(arg);
......
......@@ -32,6 +32,10 @@ struct strip_param<param<T>> {
using type = T;
};
/// Convenience alias for `strip_param<T>::type`.
template <class T>
using strip_param_t = typename strip_param<T>::type;
/// Denotes the empty list.
using empty_type_list = type_list<>;
......
......@@ -63,21 +63,21 @@ constexpr T* null_v = nullptr;
// -- backport of C++14 additions ----------------------------------------------
template <class T>
using decay_t = typename std::decay<T>::type;
using decay_t = std::decay_t<T>;
template <bool B, class T, class F>
using conditional_t = typename std::conditional<B, T, F>::type;
template <bool V, class T = void>
using enable_if_t = typename std::enable_if<V, T>::type;
using enable_if_t = std::enable_if_t<V, T>;
// -- custom traits ------------------------------------------------------------
template <class Trait, class T = void>
using enable_if_tt = typename std::enable_if<Trait::value, T>::type;
using enable_if_tt = std::enable_if_t<Trait::value, T>;
template <class T>
using remove_reference_t = typename std::remove_reference<T>::type;
using remove_reference_t = std::remove_reference_t<T>;
/// Checks whether `T` defines a free function `to_string`.
template <class T>
......@@ -119,6 +119,10 @@ struct conjunction<X, Xs...> {
static constexpr bool value = X && conjunction<Xs...>::value;
};
/// Convenience alias for `conjunction<BoolConstants...>::value`.
template <bool... BoolConstants>
bool constexpr conjunction_v = conjunction<BoolConstants...>::value;
/// Joins all bool constants using operator ||.
template <bool... BoolConstants>
struct disjunction;
......@@ -133,6 +137,10 @@ struct disjunction<X, Xs...> {
static constexpr bool value = X || disjunction<Xs...>::value;
};
/// Convenience alias for `disjunction<BoolConstants...>::value`.
template <bool... BoolConstants>
bool constexpr disjunction_v = disjunction<BoolConstants...>::value;
/// Checks whether `T` is a `std::chrono::duration`.
template <class T>
struct is_duration : std::false_type {};
......@@ -327,9 +335,8 @@ struct has_apply_operator {
// matches (IsFun || IsMemberFun)
template <class T,
bool IsFun
= std::is_function_v<T>
|| std::is_function<typename std::remove_pointer<T>::type>::value
bool IsFun = std::is_function_v<T>
|| std::is_function_v<std::remove_pointer_t<T>>
|| std::is_member_function_pointer_v<T>,
bool HasApplyOp = has_apply_operator<T>::value>
struct get_callable_trait_helper {
......@@ -368,7 +375,7 @@ using get_callable_trait_t = typename get_callable_trait<T>::type;
template <class T>
struct is_callable {
template <class C>
static bool _fun(C*, typename get_callable_trait<C>::type* = nullptr);
static bool _fun(C*, get_callable_trait_t<C>* = nullptr);
static void _fun(void*);
......
......@@ -30,8 +30,13 @@ struct make_response_promise_helper<response_promise> {
using type = response_promise;
};
/// Convenience alias for `make_response_promise_helper<Ts...>::type`.
template <class... Ts>
using response_promise_t = typename make_response_promise_helper<Ts...>::type;
using make_response_promise_helper_t =
typename make_response_promise_helper<Ts...>::type;
template <class... Ts>
using response_promise_t = make_response_promise_helper_t<Ts...>;
template <class Output, class F>
struct type_checker {
......
......@@ -56,13 +56,12 @@ void exec_main_load_module(actor_system_config& cfg) {
template <class... Ts, class F = void (*)(actor_system&)>
int exec_main(F fun, int argc, char** argv) {
using trait = typename detail::get_callable_trait<F>::type;
using trait = detail::get_callable_trait_t<F>;
using arg_types = typename trait::arg_types;
static_assert(detail::tl_size<arg_types>::value == 1
|| detail::tl_size<arg_types>::value == 2,
"main function must have one or two arguments");
static_assert(std::is_same<typename detail::tl_head<arg_types>::type,
actor_system&>::value,
static_assert(std::is_same_v<detail::tl_head_t<arg_types>, actor_system&>,
"main function must take actor_system& as first parameter");
using arg2 = typename detail::tl_at<arg_types, 1>::type;
using decayed_arg2 = typename std::decay<arg2>::type;
......
......@@ -52,6 +52,10 @@ private:
std::tuple<Ts...>* storage_;
};
/// Convenience alias for `function_view_storage<T>::type`.
template <class T>
using function_view_storage_t = typename function_view_storage<T>::type;
struct CAF_CORE_EXPORT function_view_storage_catch_all {
message* storage_;
......@@ -166,8 +170,7 @@ public:
function_view_result<value_type> result;
self_->request(impl_, timeout, std::forward<Ts>(xs)...)
.receive([&](error& x) { err = std::move(x); },
typename function_view_storage<value_type>::type{
result.value});
function_view_storage_t<value_type>{result.value});
if (err)
return result_type{err};
else
......
......@@ -283,12 +283,16 @@ struct gauge_oracle<int64_t> {
using type = telemetry::int_gauge;
};
/// Convenience alias for `detail::gauge_oracle<ValueType>::type`.
template <class ValueType>
using gauge_oracle_t = typename gauge_oracle<ValueType>::type;
} // namespace detail
namespace telemetry {
template <class ValueType>
using gauge = typename detail::gauge_oracle<ValueType>::type;
using gauge = detail::gauge_oracle_t<ValueType>;
} // namespace telemetry
......
......@@ -27,8 +27,8 @@ using spawn_mode_token = std::integral_constant<spawn_mode, X>;
// default: dynamically typed actor without self pointer
template <class Result, class FirstArg,
bool FirstArgValid = std::is_base_of<
local_actor, typename std::remove_pointer<FirstArg>::type>::value>
bool FirstArgValid
= std::is_base_of_v<local_actor, std::remove_pointer_t<FirstArg>>>
struct infer_handle_from_fun_impl {
using type = actor;
using impl = event_based_actor;
......@@ -76,11 +76,11 @@ struct infer_handle_from_fun_impl<typed_behavior<Sigs...>, Impl*, true> {
};
/// Deduces an actor handle type from a function or function object.
template <class F, class Trait = typename detail::get_callable_trait<F>::type>
template <class F, class Trait = detail::get_callable_trait_t<F>>
struct infer_handle_from_fun {
using result_type = typename Trait::result_type;
using arg_types = typename Trait::arg_types;
using first_arg = typename detail::tl_head<arg_types>::type;
using first_arg = detail::tl_head_t<arg_types>;
using delegate = infer_handle_from_fun_impl<result_type, first_arg>;
using type = typename delegate::type;
using impl = typename delegate::impl;
......
......@@ -35,9 +35,15 @@ struct type_id_sequence_helper<type_id_pair<Begin, End>, Is...> {
Is..., Begin>::type;
};
/// Convenience alias for `type_id_sequence_helper<class Range,
/// uint16_t...>::type`.
template <class Range, uint16_t... Is>
using type_id_sequence_helper_t =
typename type_id_sequence_helper<Range, Is...>::type;
template <class Range>
using make_type_id_sequence = typename type_id_sequence_helper<
type_id_pair<Range::begin, Range::end>>::type;
using make_type_id_sequence
= type_id_sequence_helper_t<type_id_pair<Range::begin, Range::end>>;
} // namespace caf::detail
......
......@@ -407,9 +407,9 @@ public:
template <message_priority P = message_priority::normal, class Handle = actor,
class... Ts>
typename response_type<typename Handle::signatures,
detail::implicit_conversions_t<
typename std::decay<Ts>::type>...>::delegated_type
typename response_type<
typename Handle::signatures,
detail::implicit_conversions_t<std::decay_t<Ts>>...>::delegated_type
delegate(const Handle& dest, Ts&&... xs) {
auto rp = make_response_promise();
return rp.template delegate<P>(dest, std::forward<Ts>(xs)...);
......
......@@ -109,7 +109,7 @@ make_mailbox_element(strong_actor_ptr sender, message_id id,
/// @relates mailbox_element
template <class T, class... Ts>
std::enable_if_t<!std::is_same_v<typename std::decay<T>::type, message>
std::enable_if_t<!std::is_same_v<std::decay_t<T>, message>
|| (sizeof...(Ts) > 0),
mailbox_element_ptr>
make_mailbox_element(strong_actor_ptr sender, message_id id,
......
......@@ -62,8 +62,7 @@ public:
void assign(Ts... xs) {
static_assert(sizeof...(Ts) > 0, "assign without arguments called");
static_assert(
!detail::disjunction<
may_have_timeout<typename std::decay<Ts>::type>::value...>::value,
!detail::disjunction<may_have_timeout<std::decay_t<Ts>>::value...>::value,
"Timeouts are only allowed in behaviors");
impl_ = detail::make_behavior(xs...);
}
......@@ -84,9 +83,9 @@ public:
/// Returns a new handler that concatenates this handler
/// with a new handler from `xs...`.
template <class... Ts>
typename std::conditional<detail::disjunction<may_have_timeout<
typename std::decay<Ts>::type>::value...>::value,
behavior, message_handler>::type
std::conditional_t<
detail::disjunction_v<may_have_timeout<std::decay_t<Ts>>::value...>,
behavior, message_handler>
or_else(Ts&&... xs) const {
// using a behavior is safe here, because we "cast"
// it back to a message_handler when appropriate
......
......@@ -134,13 +134,12 @@ public:
/// @post `pending() == false`
template <message_priority P = message_priority::normal, class Handle = actor,
class... Ts>
delegated_response_type_t<
typename Handle::signatures,
detail::implicit_conversions_t<typename std::decay<Ts>::type>...>
delegated_response_type_t<typename Handle::signatures,
detail::implicit_conversions_t<std::decay_t<Ts>>...>
delegate(const Handle& dest, Ts&&... xs) {
static_assert(sizeof...(Ts) > 0, "nothing to delegate");
using token = detail::type_list<typename detail::implicit_conversions<
typename std::decay<Ts>::type>::type...>;
using token
= detail::type_list<detail::implicit_conversions_t<std::decay_t<Ts>>...>;
static_assert(response_type_unbox<signatures_of_t<Handle>, token>::valid,
"receiver does not accept given message");
if (pending()) {
......
......@@ -21,7 +21,7 @@ public:
using element_type = T;
using value_type = typename std::remove_cv<T>::type;
using value_type = std::remove_cv_t<T>;
using index_type = size_t;
......
......@@ -42,8 +42,7 @@ struct is_string_like {
static void sfinae(void*);
// Result of SFINAE test.
using result_type
= decltype(sfinae(static_cast<typename std::decay<T>::type*>(nullptr)));
using result_type = decltype(sfinae(static_cast<std::decay_t<T>*>(nullptr)));
// Trait result.
static constexpr bool value = std::is_same_v<bool, result_type>;
......
......@@ -146,7 +146,7 @@ struct to_type_id_list_helper;
template <class... Ts>
struct to_type_id_list_helper<type_list<Ts...>> {
static constexpr type_id_list get() {
return make_type_id_list<typename strip_param<Ts>::type...>();
return make_type_id_list<strip_param_t<Ts>...>();
}
};
......
......@@ -46,13 +46,13 @@ public:
/// @copydoc local_actor::spawn
template <class T, spawn_options Os = no_spawn_options, class... Ts>
typename infer_handle_from_class<T>::type spawn(Ts&&... xs) {
infer_handle_from_class_t<T> spawn(Ts&&... xs) {
return self_->spawn<T, Os>(std::forward<Ts>(xs)...);
}
/// @copydoc local_actor::spawn
template <spawn_options Os = no_spawn_options, class F, class... Ts>
typename infer_handle_from_fun<F>::type spawn(F fun, Ts&&... xs) {
infer_handle_from_fun_t<F> spawn(F fun, Ts&&... xs) {
return self_->spawn<Os>(std::move(fun), std::forward<Ts>(xs)...);
}
......@@ -252,8 +252,7 @@ public:
}
template <class... Ts>
typename detail::make_response_promise_helper<Ts...>::type
make_response_promise() {
detail::make_response_promise_helper_t<Ts...> make_response_promise() {
return self_->make_response_promise<Ts...>();
}
......
......@@ -105,12 +105,12 @@ struct range_parser {
};
template <class T>
typename std::enable_if<std::is_integral_v<T>, res_t>::type res(T x) {
std::enable_if_t<std::is_integral_v<T>, res_t> res(T x) {
return {static_cast<int64_t>(x)};
}
template <class T>
typename std::enable_if<std::is_floating_point_v<T>, res_t>::type res(T x) {
std::enable_if_t<std::is_floating_point_v<T>, res_t> res(T x) {
return {static_cast<double>(x)};
}
......
......@@ -72,12 +72,12 @@ struct fixture {
};
template <class T>
typename std::enable_if<std::is_integral_v<T>, res_t>::type res(T x) {
std::enable_if_t<std::is_integral_v<T>, res_t> res(T x) {
return res_t{static_cast<int64_t>(x)};
}
template <class T>
typename std::enable_if<std::is_floating_point_v<T>, res_t>::type res(T x) {
std::enable_if_t<std::is_floating_point_v<T>, res_t> res(T x) {
return res_t{static_cast<double>(x)};
}
......
......@@ -49,8 +49,7 @@ public:
using signatures = none_t;
template <class F, class... Ts>
typename infer_handle_from_fun<F>::type
fork(F fun, connection_handle hdl, Ts&&... xs) {
infer_handle_from_fun_t<F> fork(F fun, connection_handle hdl, Ts&&... xs) {
CAF_ASSERT(context() != nullptr);
auto sptr = this->take(hdl);
CAF_ASSERT(sptr->hdl() == hdl);
......
......@@ -83,7 +83,7 @@ public:
template <class Handle>
expected<uint16_t> publish(Handle&& whom, uint16_t port,
const char* in = nullptr, bool reuse = false) {
detail::type_list<typename std::decay<Handle>::type> tk;
detail::type_list<std::decay_t<Handle>> tk;
return publish(actor_cast<strong_actor_ptr>(std::forward<Handle>(whom)),
system().message_types(tk), port, in, reuse);
}
......@@ -224,7 +224,7 @@ public:
/// Spawns a new functor-based broker.
template <spawn_options Os = no_spawn_options,
class F = std::function<void(broker*)>, class... Ts>
typename infer_handle_from_fun<F>::type spawn_broker(F fun, Ts&&... xs) {
infer_handle_from_fun_t<F> spawn_broker(F fun, Ts&&... xs) {
using impl = infer_impl_from_fun_t<F>;
static constexpr bool spawnable = detail::spawnable<F, impl, Ts...>();
static_assert(spawnable,
......@@ -240,7 +240,7 @@ public:
/// @warning Blocks the caller for the timespan of the connection process.
template <spawn_options Os = no_spawn_options,
class F = std::function<void(broker*)>, class... Ts>
expected<typename infer_handle_from_fun<F>::type>
expected<infer_handle_from_fun_t<F>>
spawn_client(F fun, const std::string& host, uint16_t port, Ts&&... xs) {
using impl = typename infer_handle_from_fun<F>::impl;
return spawn_client_impl<Os, impl>(std::move(fun), host, port,
......@@ -251,7 +251,7 @@ public:
/// @warning Blocks the caller until the server socket is initialized.
template <spawn_options Os = no_spawn_options,
class F = std::function<void(broker*)>, class... Ts>
expected<typename infer_handle_from_fun<F>::type>
expected<infer_handle_from_fun_t<F>>
spawn_server(F fun, uint16_t& port, Ts&&... xs) {
using impl = typename infer_handle_from_fun<F>::impl;
return spawn_server_impl<Os, impl>(std::move(fun), port,
......@@ -262,7 +262,7 @@ public:
/// @warning Blocks the caller until the server socket is initialized.
template <spawn_options Os = no_spawn_options,
class F = std::function<void(broker*)>, class... Ts>
expected<typename infer_handle_from_fun<F>::type>
expected<infer_handle_from_fun_t<F>>
spawn_server(F fun, const uint16_t& port, Ts&&... xs) {
uint16_t dummy = port;
using impl = typename infer_handle_from_fun<F>::impl;
......@@ -315,7 +315,7 @@ protected:
private:
template <spawn_options Os, class Impl, class F, class... Ts>
expected<typename infer_handle_from_class<Impl>::type>
expected<infer_handle_from_class_t<Impl>>
spawn_client_impl(F fun, const std::string& host, uint16_t port, Ts&&... xs) {
auto eptr = backend().new_tcp_scribe(host, port);
if (!eptr)
......@@ -333,7 +333,7 @@ private:
}
template <spawn_options Os, class Impl, class F, class... Ts>
expected<typename infer_handle_from_class<Impl>::type>
expected<infer_handle_from_class_t<Impl>>
spawn_server_impl(F fun, uint16_t& port, Ts&&... xs) {
auto eptr = backend().new_tcp_doorman(port);
if (!eptr)
......
......@@ -735,9 +735,8 @@ bool ip_connect(native_socket fd, const std::string& host, uint16_t port) {
CAF_LOG_TRACE("Family =" << (Family == AF_INET ? "AF_INET" : "AF_INET6")
<< CAF_ARG(fd) << CAF_ARG(host));
static_assert(Family == AF_INET || Family == AF_INET6, "invalid family");
using sockaddr_type =
typename std::conditional<Family == AF_INET, sockaddr_in,
sockaddr_in6>::type;
using sockaddr_type
= std::conditional_t<Family == AF_INET, sockaddr_in, sockaddr_in6>;
sockaddr_type sa;
memset(&sa, 0, sizeof(sockaddr_type));
inet_pton(Family, host.c_str(), &addr_of(sa));
......@@ -830,9 +829,8 @@ expected<native_socket> new_ip_acceptor_impl(uint16_t port, const char* addr,
reinterpret_cast<setsockopt_ptr>(&on),
static_cast<socket_size_type>(sizeof(on))));
}
using sockaddr_type =
typename std::conditional<Family == AF_INET, sockaddr_in,
sockaddr_in6>::type;
using sockaddr_type
= std::conditional_t<Family == AF_INET, sockaddr_in, sockaddr_in6>;
sockaddr_type sa;
memset(&sa, 0, sizeof(sockaddr_type));
family_of(sa) = Family;
......
......@@ -28,7 +28,7 @@ using socket_recv_ptr = void*;
using socket_size_type = unsigned;
#endif
using signed_size_type = std::make_signed<size_t>::type;
using signed_size_type = std::make_signed_t<size_t>;
// More bootstrapping.
CAF_IO_EXPORT extern const int ec_out_of_memory;
......
......@@ -96,8 +96,7 @@ public:
}
template <class F, class... Ts>
typename infer_handle_from_fun<F>::type
fork(F fun, connection_handle hdl, Ts&&... xs) {
infer_handle_from_fun_t<F> fork(F fun, connection_handle hdl, Ts&&... xs) {
CAF_ASSERT(this->context() != nullptr);
auto sptr = this->take(hdl);
CAF_ASSERT(sptr->hdl() == hdl);
......
......@@ -36,7 +36,7 @@ error allow_connreset(datagram_socket x, bool) {
#endif // CAF_WINDOWS
std::variant<size_t, sec>
check_datagram_socket_io_res(std::make_signed<size_t>::type res) {
check_datagram_socket_io_res(std::make_signed_t<size_t> res) {
if (res < 0) {
auto code = last_socket_error();
if (code == std::errc::operation_would_block
......
......@@ -27,7 +27,7 @@ error CAF_NET_EXPORT allow_connreset(datagram_socket x, bool new_value);
/// Converts the result from I/O operation on a ::datagram_socket to either an
/// error code or a integer greater or equal to zero.
/// @relates datagram_socket
std::variant<size_t, sec> CAF_NET_EXPORT
check_datagram_socket_io_res(std::make_signed<size_t>::type res);
std::variant<size_t, sec>
CAF_NET_EXPORT check_datagram_socket_io_res(std::make_signed_t<size_t> res);
} // namespace caf::net
......@@ -34,6 +34,6 @@ constexpr socket_id invalid_socket_id = -1;
/// Signed counterpart of `socket_id`.
/// @relates socket
using signed_socket_id = std::make_signed<socket_id>::type;
using signed_socket_id = std::make_signed_t<socket_id>;
} // namespace caf::net
......@@ -61,9 +61,8 @@ expected<tcp_accept_socket> new_tcp_acceptor_impl(uint16_t port,
reinterpret_cast<setsockopt_ptr>(&on),
static_cast<socket_size_type>(sizeof(on))));
}
using sockaddr_type =
typename std::conditional<Family == AF_INET, sockaddr_in,
sockaddr_in6>::type;
using sockaddr_type
= std::conditional_t<Family == AF_INET, sockaddr_in, sockaddr_in6>;
sockaddr_type sa;
memset(&sa, 0, sizeof(sockaddr_type));
detail::family_of(sa) = Family;
......
......@@ -93,9 +93,8 @@ bool ip_connect(stream_socket fd, std::string host, uint16_t port,
<< CAF_ARG(fd.id) << CAF_ARG(host) << CAF_ARG(port)
<< CAF_ARG(timeout));
static_assert(Family == AF_INET || Family == AF_INET6, "invalid family");
using sockaddr_type =
typename std::conditional<Family == AF_INET, sockaddr_in,
sockaddr_in6>::type;
using sockaddr_type
= std::conditional_t<Family == AF_INET, sockaddr_in, sockaddr_in6>;
sockaddr_type sa;
memset(&sa, 0, sizeof(sockaddr_type));
if (inet_pton(Family, host.c_str(), &detail::addr_of(sa)) == 1) {
......
......@@ -37,13 +37,13 @@ bool cmp_one(const caf::message& x, const T& y) {
}
template <size_t I, class... Ts>
typename std::enable_if<(I == sizeof...(Ts)), bool>::type
std::enable_if_t<(I == sizeof...(Ts)), bool>
msg_cmp_rec(const caf::message&, const std::tuple<Ts...>&) {
return true;
}
template <size_t I, class... Ts>
typename std::enable_if<(I < sizeof...(Ts)), bool>::type
std::enable_if_t<(I < sizeof...(Ts)), bool>
msg_cmp_rec(const caf::message& x, const std::tuple<Ts...>& ys) {
return cmp_one<I>(x, std::get<I>(ys)) && msg_cmp_rec<I + 1>(x, ys);
}
......@@ -840,7 +840,7 @@ public:
/// Sends a request to `hdl`, then calls `run()`, and finally fetches and
/// returns the result.
template <class T, class... Ts, class Handle, class... Us>
typename std::conditional<sizeof...(Ts) == 0, T, std::tuple<T, Ts...>>::type
std::conditional_t<sizeof...(Ts) == 0, T, std::tuple<T, Ts...>>
request(Handle hdl, Us... args) {
auto res_hdl = self->request(hdl, caf::infinite, std::move(args)...);
run();
......
......@@ -95,7 +95,7 @@ struct equality_operator {
}
template <class T, class U,
typename std::enable_if<!detail::is_comparable_v<T, U>>::type = 0>
std::enable_if_t<!detail::is_comparable_v<T, U>> = 0>
bool operator()(const T&, const U&) const {
return default_value;
}
......@@ -105,10 +105,10 @@ struct inequality_operator {
static constexpr bool default_value = true;
template <class T, class U,
typename std::enable_if<
std::enable_if_t<
(std::is_floating_point_v<T>
|| std::is_floating_point_v<U>) &&detail::is_comparable_v<T, U>,
int>::type
int>
= 0>
bool operator()(const T& x, const U& y) const {
equality_operator f;
......@@ -116,17 +116,17 @@ struct inequality_operator {
}
template <class T, class U,
typename std::enable_if<!std::is_floating_point_v<T>
std::enable_if_t<!std::is_floating_point_v<T>
&& !std::is_floating_point_v<U>
&& detail::is_comparable_v<T, U>,
int>::type
int>
= 0>
bool operator()(const T& x, const U& y) const {
return x != y;
}
template <class T, class U,
typename std::enable_if<!detail::is_comparable_v<T, U>>::type = 0>
std::enable_if_t<!detail::is_comparable_v<T, U>> = 0>
bool operator()(const T&, const U&) const {
return default_value;
}
......@@ -290,11 +290,10 @@ public:
return y;
}
};
using fwd =
typename std::conditional<std::is_same_v<char, T>
using fwd = std::conditional_t<std::is_same_v<char, T>
|| std::is_convertible_v<T, std::string>
|| std::is_same_v<caf::term, T>,
simple_fwd_t, deep_to_string_t>::type;
simple_fwd_t, deep_to_string_t>;
fwd f;
auto y = f(x);
if (lvl <= level_console_)
......
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