Unverified Commit 8f94dc06 authored by Dominik Charousset's avatar Dominik Charousset Committed by GitHub

Merge pull request #1521

refactor $pred::value to $pred_v
parents 428eaaa7 cf5d947b
......@@ -48,6 +48,10 @@ struct is_weak_ptr {
static constexpr bool value = T::has_weak_ptr_semantics;
};
/// Convenience alias for `is_weak_ptr<T>::value`.
template <class T>
inline constexpr bool is_weak_ptr_v = is_weak_ptr<T>::value;
template <class T>
struct is_weak_ptr<T*> : std::false_type {};
......@@ -71,7 +75,7 @@ public:
}
template <class T,
class = typename std::enable_if<!std::is_pointer<T>::value>::type>
class = typename std::enable_if<!std::is_pointer_v<T>>::type>
To operator()(const T& x) const {
return x.get();
}
......@@ -89,7 +93,7 @@ public:
}
template <class T,
class = typename std::enable_if<!std::is_pointer<T>::value>::type>
class = typename std::enable_if<!std::is_pointer_v<T>>::type>
To* operator()(const T& x) const {
return (*this)(x.get());
}
......@@ -107,7 +111,7 @@ public:
}
template <class T,
class = typename std::enable_if<!std::is_pointer<T>::value>::type>
class = typename std::enable_if<!std::is_pointer_v<T>>::type>
actor_control_block* operator()(const T& x) const {
return x.get();
}
......@@ -148,11 +152,11 @@ T actor_cast(U&& what) {
using from_type =
typename std::remove_const<typename std::remove_reference<U>::type>::type;
// query traits for T
constexpr bool to_raw = std::is_pointer<T>::value;
constexpr bool to_weak = is_weak_ptr<T>::value;
constexpr bool to_raw = std::is_pointer_v<T>;
constexpr bool to_weak = is_weak_ptr_v<T>;
// query traits for U
constexpr bool from_raw = std::is_pointer<from_type>::value;
constexpr bool from_weak = is_weak_ptr<from_type>::value;
constexpr bool from_raw = std::is_pointer_v<from_type>;
constexpr bool from_weak = is_weak_ptr_v<from_type>;
// calculate x and y
constexpr int x = to_raw ? 0 : (to_weak ? 2 : 1);
constexpr int y = from_raw ? 0 : (from_weak ? 3 : 6);
......
......@@ -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 {
......@@ -142,10 +142,9 @@ 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<Ts>::value...>::value,
"all Ts must be lvalue references");
static_assert(std::is_base_of<local_actor, T>::value,
static_assert(detail::conjunction<std::is_lvalue_reference_v<Ts>...>::value,
"all Ts must be lvalue references");
static_assert(std::is_base_of_v<local_actor, T>,
"T is not derived from local_actor");
return &dyn_spawn_class<T, Ts...>;
}
......
......@@ -446,7 +446,7 @@ public:
/// with the arguments stored in `args`.
/// @experimental
template <class Handle,
class E = typename std::enable_if<is_handle<Handle>::value>::type>
class E = typename std::enable_if<is_handle_v<Handle>>::type>
expected<Handle>
spawn(const std::string& name, message args, execution_unit* ctx = nullptr,
bool check_interface = true, const mpi* expected_ifs = nullptr) {
......@@ -778,7 +778,7 @@ public:
private:
template <class T>
void check_invariants() {
static_assert(!std::is_base_of<prohibit_top_level_spawn_marker, T>::value,
static_assert(!std::is_base_of_v<prohibit_top_level_spawn_marker, T>,
"This actor type cannot be spawned through an actor system. "
"Probably you have tried to spawn a broker.");
}
......
......@@ -60,20 +60,19 @@ template <class T>
struct default_actor_traits<T, true> {
/// Denotes whether `T` is dynamically typed.
static constexpr bool is_dynamically_typed
= std::is_base_of<dynamically_typed_actor_base, T>::value;
= std::is_base_of_v<dynamically_typed_actor_base, T>;
/// Denotes whether `T` is statically typed.
static constexpr bool is_statically_typed
= std::is_base_of<statically_typed_actor_base, T>::value;
= std::is_base_of_v<statically_typed_actor_base, T>;
/// Denotes whether `T` is a blocking actor type.
static constexpr bool is_blocking
= std::is_base_of<blocking_actor_base, T>::value
|| mixin::is_blocking_requester<T>::value;
static constexpr bool is_blocking = std::is_base_of_v<blocking_actor_base, T>
|| mixin::is_blocking_requester<T>::value;
/// Denotes whether `T` is a non-blocking actor type.
static constexpr bool is_non_blocking
= std::is_base_of<non_blocking_actor_base, T>::value;
= std::is_base_of_v<non_blocking_actor_base, T>;
/// Denotes whether `T` is an incomplete actor type that misses one or more
/// markers.
......@@ -91,6 +90,6 @@ struct default_actor_traits<T, true> {
/// Provides uniform access to properties of actor types.
template <class T>
struct actor_traits
: default_actor_traits<T, std::is_base_of<abstract_actor, T>::value> {};
: default_actor_traits<T, std::is_base_of_v<abstract_actor, T>> {};
} // namespace caf
......@@ -174,7 +174,7 @@ public:
bool value(uint64_t& x) noexcept;
template <class T>
std::enable_if_t<std::is_integral<T>::value, bool> value(T& x) noexcept {
std::enable_if_t<std::is_integral_v<T>, bool> value(T& x) noexcept {
auto tmp = detail::squashed_int_t<T>{0};
if (value(tmp)) {
x = static_cast<T>(tmp);
......
......@@ -157,7 +157,7 @@ public:
bool value(uint64_t x);
template <class T>
std::enable_if_t<std::is_integral<T>::value, bool> value(T x) {
std::enable_if_t<std::is_integral_v<T>, bool> value(T x) {
return value(static_cast<detail::squashed_int_t<T>>(x));
}
......
......@@ -312,7 +312,7 @@ public:
filtered tk;
behavior bhvr{apply_moved_args(make_behavior_impl, get_indices(tk), tup)};
using tail_indices =
typename il_range<tl_size<filtered>::value, sizeof...(Ts)>::type;
typename il_range<tl_size_v<filtered>, sizeof...(Ts)>::type;
make_blocking_behavior_t factory;
auto fun = apply_moved_args_prefixed(factory, tail_indices{}, tup, &bhvr);
receive_impl(rcc, mid, fun);
......
......@@ -8,7 +8,7 @@
namespace caf {
template <class IntegerType,
class = std::enable_if_t<std::is_integral<IntegerType>::value>>
class = std::enable_if_t<std::is_integral_v<IntegerType>>>
[[deprecated("use std::to_integer instead")]] constexpr IntegerType
to_integer(std::byte x) noexcept {
return static_cast<IntegerType>(x);
......
......@@ -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&)");
......
......@@ -290,14 +290,14 @@ private:
void set(T x) {
if constexpr (detail::is_config_value_type_v<T>) {
data_ = std::move(x);
} else if constexpr (std::is_integral<T>::value) {
} else if constexpr (std::is_integral_v<T>) {
data_ = static_cast<int64_t>(x);
} else if constexpr (std::is_convertible<T, const char*>::value) {
data_ = std::string{x};
} else {
static_assert(detail::is_iterable<T>::value);
using value_type = typename T::value_type;
detail::bool_token<detail::is_pair<value_type>::value> is_map_type;
detail::bool_token<detail::is_pair_v<value_type>> is_map_type;
set_range(x, is_map_type);
}
}
......@@ -365,7 +365,7 @@ expected<T> get_as(const config_value& x, inspector_access_type::builtin) {
return to_string(x);
} else if constexpr (std::is_same_v<T, bool>) {
return x.to_boolean();
} else if constexpr (std::is_integral<T>::value) {
} else if constexpr (std::is_integral_v<T>) {
if (auto result = x.to_integer()) {
if (detail::bounds_checker<T>::check(*result))
return static_cast<T>(*result);
......@@ -374,7 +374,7 @@ expected<T> get_as(const config_value& x, inspector_access_type::builtin) {
} else {
return std::move(result.error());
}
} else if constexpr (std::is_floating_point<T>::value) {
} else if constexpr (std::is_floating_point_v<T>) {
if (auto result = x.to_real()) {
if constexpr (sizeof(T) >= sizeof(config_value::real)) {
return *result;
......@@ -419,10 +419,9 @@ get_as_tuple(const config_value::list& x, std::index_sequence<Is...>) {
template <class T>
expected<T> get_as(const config_value& x, inspector_access_type::tuple) {
static_assert(!std::is_array<T>::value,
"cannot return an array from a function");
static_assert(!std::is_array_v<T>, "cannot return an array from a function");
if (auto wrapped_values = x.to_list()) {
static constexpr size_t n = std::tuple_size<T>::value;
static constexpr size_t n = std::tuple_size_v<T>;
if (wrapped_values->size() == n)
return get_as_tuple<T>(*wrapped_values, std::make_index_sequence<n>{});
else
......
......@@ -403,10 +403,10 @@ namespace {
template <class T>
bool pull(config_value_reader& reader, T& x) {
using internal_type = std::conditional_t<std::is_floating_point<T>::value,
config_value::real, T>;
using internal_type
= std::conditional_t<std::is_floating_point_v<T>, config_value::real, T>;
auto assign = [&x](auto& result) {
if constexpr (std::is_floating_point<T>::value) {
if constexpr (std::is_floating_point_v<T>) {
x = static_cast<T>(result);
} else {
x = result;
......
......@@ -42,7 +42,7 @@ struct dmi<typed_response_promise<Out...>(In...)> {
// -- dmfou = deduce_mpi_function_object_unboxing
template <class T, bool isClass = std::is_class<T>::value>
template <class T, bool isClass = std::is_class_v<T>>
struct dmfou;
// case #1a: const member function pointer
......
......@@ -158,7 +158,7 @@ public:
/// @copydoc value
template <class T>
std::enable_if_t<std::is_integral<T>::value, bool> value(T& x) noexcept {
std::enable_if_t<std::is_integral_v<T>, bool> value(T& x) noexcept {
auto tmp = detail::squashed_int_t<T>{0};
if (value(tmp)) {
x = static_cast<T>(tmp);
......
......@@ -16,8 +16,8 @@
namespace caf::detail {
template <class T,
bool IsDyn = std::is_base_of<dynamically_typed_actor_base, T>::value,
bool IsStat = std::is_base_of<statically_typed_actor_base, T>::value>
bool IsDyn = std::is_base_of_v<dynamically_typed_actor_base, T>,
bool IsStat = std::is_base_of_v<statically_typed_actor_base, T>>
struct implicit_actor_conversions {
using type = T;
};
......@@ -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>>;
};
......
......@@ -47,7 +47,7 @@ class init_fun_factory_helper final : public init_fun_factory_helper_base {
public:
using args_pointer = std::shared_ptr<Tuple>;
static constexpr bool args_empty = std::tuple_size<Tuple>::value == 0;
static constexpr bool args_empty = std::tuple_size_v<Tuple> == 0;
init_fun_factory_helper(F fun, args_pointer args)
: fun_(std::move(fun)), args_(std::move(args)) {
......@@ -118,14 +118,14 @@ public:
template <class... Ts>
ptr_type make(F f, Ts&&... xs) {
static_assert(std::is_base_of<local_actor, Base>::value,
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 arg_types = typename trait::arg_types;
using res_type = typename trait::result_type;
using first_arg = typename detail::tl_head<arg_types>::type;
constexpr bool selfptr = std::is_pointer<first_arg>::value;
constexpr bool rets = std::is_convertible<res_type, behavior>::value;
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)...));
using helper = init_fun_factory_helper<Base, F, tuple_type, rets, selfptr>;
return ptr_type{new helper{std::move(f), sizeof...(Ts) > 0
......
......@@ -72,7 +72,7 @@ CAF_CORE_EXPORT void parse(string_parser_state& ps, uint64_t& x);
// -- non-fixed size integer types ---------------------------------------------
template <class T>
detail::enable_if_t<std::is_integral<T>::value>
detail::enable_if_t<std::is_integral_v<T>>
parse(string_parser_state& ps, T& x) {
using squashed_type = squashed_int_t<T>;
return parse(ps, reinterpret_cast<squashed_type&>(x));
......
......@@ -28,8 +28,7 @@ template <class State, class Consumer>
void read_signed_integer(State& ps, Consumer&& consumer) {
using consumer_type = typename std::decay<Consumer>::type;
using value_type = typename consumer_type::value_type;
static_assert(std::is_integral<value_type>::value
&& std::is_signed<value_type>::value,
static_assert(std::is_integral_v<value_type> && std::is_signed_v<value_type>,
"expected a signed integer type");
value_type result = 0;
// Computes the result on success.
......
......@@ -28,8 +28,8 @@ template <class State, class Consumer>
void read_unsigned_integer(State& ps, Consumer&& consumer) {
using consumer_type = typename std::decay<Consumer>::type;
using value_type = typename consumer_type::value_type;
static_assert(std::is_integral<value_type>::value
&& std::is_unsigned<value_type>::value,
static_assert(std::is_integral_v<value_type>
&& std::is_unsigned_v<value_type>,
"expected an unsigned integer type");
value_type result = 0;
// Computes the result on success.
......
......@@ -128,12 +128,12 @@ void print(Buffer& buf, bool x) {
}
template <class Buffer, class T>
std::enable_if_t<std::is_integral<T>::value> print(Buffer& buf, T x) {
std::enable_if_t<std::is_integral_v<T>> print(Buffer& buf, T x) {
// An integer can at most have 20 digits (UINT64_MAX).
char stack_buffer[24];
char* p = stack_buffer;
// Convert negative values into positives as necessary.
if constexpr (std::is_signed<T>::value) {
if constexpr (std::is_signed_v<T>) {
if (x == std::numeric_limits<T>::min()) {
using namespace std::literals;
// The code below would fail for the smallest value, because this value
......@@ -172,7 +172,7 @@ std::enable_if_t<std::is_integral<T>::value> print(Buffer& buf, T x) {
}
template <class Buffer, class T>
std::enable_if_t<std::is_floating_point<T>::value> print(Buffer& buf, T x) {
std::enable_if_t<std::is_floating_point_v<T>> print(Buffer& buf, T x) {
// TODO: Check whether to_chars is available on supported compilers and
// re-implement using the new API as soon as possible.
auto str = std::to_string(x);
......
......@@ -40,7 +40,7 @@ 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 {
static_assert(!std::is_lvalue_reference<T>::value,
static_assert(!std::is_lvalue_reference_v<T>,
"silently converting an lvalue to an rvalue");
return static_cast<T&&>(arg);
}
......
......@@ -42,7 +42,7 @@ struct int_types_by_size<8> {
template <class T>
struct squashed_int {
using tpair = int_types_by_size<sizeof(T)>;
using type = std::conditional_t<std::is_signed<T>::value, //
using type = std::conditional_t<std::is_signed_v<T>, //
typename tpair::signed_type, //
typename tpair::unsigned_type>;
};
......@@ -50,7 +50,7 @@ struct squashed_int {
template <class T>
using squashed_int_t = typename squashed_int<T>::type;
template <class T, bool = std::is_integral<T>::value>
template <class T, bool = std::is_integral_v<T>>
struct squash_if_int {
using type = T;
};
......
......@@ -90,8 +90,8 @@ public:
bool value(bool x);
template <class Integral>
std::enable_if_t<std::is_integral<Integral>::value, bool> value(Integral x) {
if constexpr (std::is_signed<Integral>::value)
std::enable_if_t<std::is_integral_v<Integral>, bool> value(Integral x) {
if constexpr (std::is_signed_v<Integral>)
return int_value(static_cast<int64_t>(x));
else
return int_value(static_cast<uint64_t>(x));
......@@ -151,9 +151,8 @@ public:
}
template <class T>
std::enable_if_t<has_to_string<T>::value
&& !std::is_convertible<T, std::string_view>::value,
bool>
std::enable_if_t<
has_to_string_v<T> && !std::is_convertible_v<T, std::string_view>, bool>
builtin_inspect(const T& x) {
auto str = to_string(x);
if constexpr (std::is_convertible<decltype(str), const char*>::value) {
......@@ -220,8 +219,8 @@ public:
static std::string render(const T& x) {
if constexpr (std::is_same_v<std::nullptr_t, T>) {
return "null";
} else if constexpr (std::is_constructible<std::string_view, T>::value) {
if constexpr (std::is_pointer<T>::value) {
} else if constexpr (std::is_constructible_v<std::string_view, T>) {
if constexpr (std::is_pointer_v<T>) {
if (x == nullptr)
return "null";
}
......
......@@ -45,9 +45,9 @@ struct is_type_list<type_list<Ts...>> {
static constexpr bool value = true;
};
// Uncomment after having switched to C++14
// template <class T>
// inline constexpr bool is_type_list_v = is_type_list<T>::value;
/// Convenience alias for `is_type_list<T>::value`.
template <class T>
inline constexpr bool is_type_list_v = is_type_list<T>::value;
// T head(type_list)
......@@ -101,9 +101,9 @@ struct tl_size<type_list<Ts...>> {
template <class... Ts>
constexpr size_t tl_size<type_list<Ts...>>::value;
// Uncomment after having switched to C++14
// template <class List>
// inline constexpr size_t tl_size_v = tl_size<List>::value;
/// Convenience alias for `tl_size<List>::value`.
template <class List>
inline constexpr size_t tl_size_v = tl_size<List>::value;
// T back(type_list)
......
......@@ -34,7 +34,9 @@
\
public: \
static constexpr bool value = sfinae_type::value; \
}
}; \
template <class T> \
constexpr bool has_##name##_member_v = has_##name##_member<T>::value
#define CAF_HAS_ALIAS_TRAIT(name) \
template <class T> \
......@@ -88,9 +90,14 @@ 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>;
};
/// Convenience alias for `has_to_string<T>::value`.
/// @relates has_to_string
template <class T>
inline constexpr bool has_to_string_v = has_to_string<T>::value;
template <bool X>
using bool_token = std::integral_constant<bool, X>;
......@@ -136,10 +143,10 @@ 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
|| std::is_arithmetic<T>::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_v<T>;
};
/// Checks whether `T1` is comparable with `T2`.
......@@ -168,15 +175,16 @@ class is_comparable {
using result_type = decltype(cmp_help_fun(
static_cast<T1*>(nullptr), static_cast<T2*>(nullptr),
static_cast<bool*>(nullptr),
std::integral_constant<bool, std::is_arithmetic<T1>::value
&& std::is_arithmetic<T2>::value>{}));
std::integral_constant<bool, std::is_arithmetic_v<T1>
&& std::is_arithmetic_v<T2>>{}));
public:
static constexpr bool value = std::is_same_v<bool, result_type>;
};
/// Convenience alias for `is_comparable<T1, T2>::value`.
template <class T1, class T2>
constexpr bool is_comparable_v = is_comparable<T1, T2>::value;
inline constexpr bool is_comparable_v = is_comparable<T1, T2>::value;
/// Checks whether `T` behaves like a forward iterator.
template <class T>
......@@ -319,9 +327,9 @@ struct has_apply_operator {
// matches (IsFun || IsMemberFun)
template <class T,
bool IsFun
= std::is_function<T>::value
= std::is_function_v<T>
|| std::is_function<typename std::remove_pointer<T>::type>::value
|| std::is_member_function_pointer<T>::value,
|| std::is_member_function_pointer_v<T>,
bool HasApplyOp = has_apply_operator<T>::value>
struct get_callable_trait_helper {
using type = callable_trait<T>;
......@@ -369,6 +377,11 @@ public:
static constexpr bool value = std::is_same_v<bool, result_type>;
};
/// Convenience alias for `is_callable<T>::value`.
/// @relates is_callable
template <class T>
inline constexpr bool is_callable_v = is_callable<T>::value;
/// Checks whether `F` is callable with arguments of types `Ts...`.
template <class F, class... Ts>
struct is_callable_with {
......@@ -409,7 +422,7 @@ struct type_at<0, T0, Ts...> {
};
// Checks whether T has a member variable named `name`.
template <class T, bool IsScalar = std::is_scalar<T>::value>
template <class T, bool IsScalar = std::is_scalar_v<T>>
class has_name {
private:
// a simple struct with a member called `name`
......@@ -449,10 +462,14 @@ 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&)>>;
};
/// Convenience alias for `is_handler_for<F, T>::value`.
template <class F, class T>
inline constexpr bool is_handler_for_v = is_handler_for<F, T>::value;
template <class T>
struct value_type_of {
using type = typename T::value_type;
......@@ -467,11 +484,10 @@ template <class T>
using value_type_of_t = typename value_type_of<T>::type;
template <class T>
using is_callable_t = typename std::enable_if<is_callable<T>::value>::type;
using is_callable_t = typename std::enable_if<is_callable_v<T>>::type;
template <class F, class T>
using is_handler_for_ef =
typename std::enable_if<is_handler_for<F, T>::value>::type;
using is_handler_for_ef = typename std::enable_if<is_handler_for_v<F, T>>::type;
template <class T>
struct strip_reference_wrapper {
......@@ -540,15 +556,14 @@ constexpr bool is_expected_v = is_expected<T>::value;
// Checks whether `T` and `U` are integers of the same size and signedness.
// clang-format off
template <class T, class U,
bool Enable = std::is_integral<T>::value
&& std::is_integral<U>::value
bool Enable = std::is_integral_v<T>
&& std::is_integral_v<U>
&& !std::is_same_v<T, bool>
&& !std::is_same_v<U, bool>>
// clang-format on
struct is_equal_int_type {
static constexpr bool value = sizeof(T) == sizeof(U)
&& std::is_signed<T>::value
== std::is_signed<U>::value;
&& std::is_signed_v<T> == std::is_signed_v<U>;
};
template <class T, typename U>
......@@ -612,10 +627,14 @@ struct all_constructible<type_list<>, type_list<>> : std::true_type {};
template <class T, class... Ts, class U, class... Us>
struct all_constructible<type_list<T, Ts...>, type_list<U, Us...>> {
static constexpr bool value
= std::is_constructible<T, U>::value
= std::is_constructible_v<T, U>
&& all_constructible<type_list<Ts...>, type_list<Us...>>::value;
};
/// Convenience alias for `all_constructible<Ts, Us>::value`.
template <class Ts, class Us>
inline constexpr bool all_constructible_v = all_constructible<Ts, Us>::value;
/// Checks whether T behaves like `std::map`.
template <class T>
struct is_map_like {
......@@ -808,8 +827,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 +937,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) \
......@@ -973,11 +993,16 @@ public:
static constexpr bool value = sfinae_result::value;
};
/// Convenience alias for `accepts_opaque_value<Inspector, T>::value`.
template <class Inspector, class T>
inline constexpr bool accepts_opaque_value_v
= accepts_opaque_value<Inspector, T>::value;
/// Checks whether `T` is primitive, i.e., either an arithmetic type or
/// convertible to one of STL's string types.
template <class T, bool IsLoading>
struct is_builtin_inspector_type {
static constexpr bool value = std::is_arithmetic<T>::value;
static constexpr bool value = std::is_arithmetic_v<T>;
};
template <bool IsLoading>
......
......@@ -125,9 +125,8 @@ struct is_normalized_signature {
};
template <class T>
constexpr bool is_decayed = !std::is_reference<T>::value
&& !std::is_const<T>::value
&& !std::is_volatile<T>::value;
inline constexpr bool is_decayed
= !std::is_reference_v<T> && !std::is_const_v<T> && !std::is_volatile_v<T>;
template <class... Out, class... In>
struct is_normalized_signature<result<Out...>(In...)> {
......
......@@ -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 {
......
......@@ -37,7 +37,7 @@ struct exec_main_helper<detail::type_list<actor_system&, const T&>> {
template <class T>
void exec_main_init_meta_objects_single() {
if constexpr (std::is_base_of<actor_system::module, T>::value)
if constexpr (std::is_base_of_v<actor_system::module, T>)
T::init_global_meta_objects();
else
init_global_meta_objects<T>();
......@@ -50,7 +50,7 @@ void exec_main_init_meta_objects() {
template <class T>
void exec_main_load_module(actor_system_config& cfg) {
if constexpr (std::is_base_of<actor_system::module, T>::value)
if constexpr (std::is_base_of_v<actor_system::module, T>)
cfg.template load<T>();
}
......@@ -67,7 +67,7 @@ int exec_main(F fun, int argc, char** argv) {
using arg2 = typename detail::tl_at<arg_types, 1>::type;
using decayed_arg2 = typename std::decay<arg2>::type;
static_assert(std::is_same_v<arg2, unit_t>
|| (std::is_base_of<actor_system_config, decayed_arg2>::value
|| (std::is_base_of_v<actor_system_config, decayed_arg2>
&& std::is_same<arg2, const decayed_arg2&>::value),
"second parameter of main function must take a subtype of "
"actor_system_config as const reference");
......@@ -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);
......
......@@ -53,14 +53,12 @@ public:
// -- static member variables ------------------------------------------------
/// Stores whether move construct and move assign never throw.
static constexpr bool nothrow_move
= std::is_nothrow_move_constructible<T>::value
&& std::is_nothrow_move_assignable<T>::value;
static constexpr bool nothrow_move = std::is_nothrow_move_constructible_v<T>
&& std::is_nothrow_move_assignable_v<T>;
/// Stores whether copy construct and copy assign never throw.
static constexpr bool nothrow_copy
= std::is_nothrow_copy_constructible<T>::value
&& std::is_nothrow_copy_assignable<T>::value;
static constexpr bool nothrow_copy = std::is_nothrow_copy_constructible_v<T>
&& std::is_nothrow_copy_assignable_v<T>;
/// Stores whether swap() never throws.
static constexpr bool nothrow_swap = std::is_nothrow_swappable_v<T>;
......@@ -155,7 +153,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)};
}
......
......@@ -105,7 +105,7 @@ public:
}
template <class Integral>
std::enable_if_t<std::is_integral<Integral>::value, bool>
std::enable_if_t<std::is_integral_v<Integral>, bool>
value(Integral x) noexcept {
auto begin = reinterpret_cast<const uint8_t*>(&x);
append(begin, begin + sizeof(Integral));
......
......@@ -100,7 +100,7 @@ public:
}
template <class Integral>
std::enable_if_t<std::is_integral<Integral>::value, bool>
std::enable_if_t<std::is_integral_v<Integral>, bool>
value(Integral x) noexcept {
auto begin = reinterpret_cast<const uint8_t*>(&x);
append(begin, begin + sizeof(Integral));
......
......@@ -66,8 +66,8 @@ struct infer_handle_from_fun_impl<typed_behavior<Sigs...>, Impl, false> {
// statically typed actor with self pointer
template <class... Sigs, class Impl>
struct infer_handle_from_fun_impl<typed_behavior<Sigs...>, Impl*, true> {
static_assert(std::is_base_of<typed_event_based_actor<Sigs...>, Impl>::value
|| std::is_base_of<io::typed_broker<Sigs...>, Impl>::value,
static_assert(std::is_base_of_v<typed_event_based_actor<Sigs...>, Impl>
|| std::is_base_of_v<io::typed_broker<Sigs...>, Impl>,
"Self pointer does not match the returned behavior type.");
using type = typed_actor<Sigs...>;
using impl = Impl;
......@@ -109,7 +109,7 @@ struct infer_handle_from_behavior<typed_behavior<Sigs...>> {
/// Deduces `actor` for dynamically typed actors, otherwise `typed_actor<...>`
/// is deduced.
template <class T, bool = std::is_base_of<abstract_actor, T>::value>
template <class T, bool = std::is_base_of_v<abstract_actor, T>>
struct infer_handle_from_class {
using type =
typename infer_handle_from_behavior<typename T::behavior_type>::type;
......@@ -137,4 +137,8 @@ struct is_handle<strong_actor_ptr> : std::true_type {};
template <class... Ts>
struct is_handle<typed_actor<Ts...>> : std::true_type {};
/// Convenience alias for `is_handle<T>::value`.
template <class T>
inline constexpr bool is_handle_v = is_handle<T>::value;
} // namespace caf
......@@ -126,13 +126,13 @@ bool load(Inspector& f, T& x, inspector_access_type::list) {
}
template <class Inspector, class T>
std::enable_if_t<accepts_opaque_value<Inspector, T>::value, bool>
std::enable_if_t<accepts_opaque_value_v<Inspector, T>, bool>
load(Inspector& f, T& x, inspector_access_type::none) {
return f.opaque_value(x);
}
template <class Inspector, class T>
std::enable_if_t<!accepts_opaque_value<Inspector, T>::value, bool>
std::enable_if_t<!accepts_opaque_value_v<Inspector, T>, bool>
load(Inspector&, T&, inspector_access_type::none) {
static_assert(
detail::assertion_failed_v<T>,
......@@ -219,13 +219,13 @@ bool save(Inspector& f, T& x, inspector_access_type::list) {
}
template <class Inspector, class T>
std::enable_if_t<accepts_opaque_value<Inspector, T>::value, bool>
std::enable_if_t<accepts_opaque_value_v<Inspector, T>, bool>
save(Inspector& f, T& x, inspector_access_type::none) {
return f.opaque_value(x);
}
template <class Inspector, class T>
std::enable_if_t<!accepts_opaque_value<Inspector, T>::value, bool>
std::enable_if_t<!accepts_opaque_value_v<Inspector, T>, bool>
save(Inspector&, T&, inspector_access_type::none) {
static_assert(
detail::assertion_failed_v<T>,
......@@ -240,7 +240,7 @@ bool save(Inspector& f, T& x) {
template <class Inspector, class T>
bool save(Inspector& f, const T& x) {
if constexpr (!std::is_function<T>::value) {
if constexpr (!std::is_function_v<T>) {
return save(f, as_mutable_ref(x), inspect_access_type<Inspector, T>());
} else {
// Only inspector such as the stringification_inspector are going to accept
......
......@@ -28,9 +28,9 @@ public:
using const_reference = const value_type&;
using node_type = typename std::conditional<std::is_const<T>::value,
const typename T::node_type,
typename T::node_type>::type;
using node_type =
typename std::conditional_t<std::is_const_v<T>, const typename T::node_type,
typename T::node_type>;
using node_pointer = node_type*;
......
......@@ -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() {
......@@ -262,14 +261,14 @@ operator!=(const T* lhs, const intrusive_ptr<U>& rhs) {
/// @relates intrusive_ptr
template <class T, class U>
detail::enable_if_t<detail::is_comparable<T*, U*>::value, bool>
detail::enable_if_t<detail::is_comparable_v<T*, U*>, bool>
operator==(const intrusive_ptr<T>& x, const intrusive_ptr<U>& y) {
return x.get() == y.get();
}
/// @relates intrusive_ptr
template <class T, class U>
detail::enable_if_t<detail::is_comparable<T*, U*>::value, bool>
detail::enable_if_t<detail::is_comparable_v<T*, U*>, bool>
operator!=(const intrusive_ptr<T>& x, const intrusive_ptr<U>& y) {
return x.get() != y.get();
}
......
......@@ -343,7 +343,7 @@ public:
template <class T>
static auto field(std::string_view name, T& x) {
static_assert(!std::is_const<T>::value);
static_assert(!std::is_const_v<T>);
return field_t<T>{name, &x};
}
......
......@@ -88,7 +88,7 @@ public:
template <class T>
bool tuple(T& xs) {
return tuple(xs, std::make_index_sequence<std::tuple_size<T>::value>{});
return tuple(xs, std::make_index_sequence<std::tuple_size_v<T>>{});
}
template <class T, size_t N>
......@@ -105,7 +105,7 @@ public:
template <class T>
[[nodiscard]] bool apply(T& x) {
static_assert(!std::is_const<T>::value);
static_assert(!std::is_const_v<T>);
return detail::load(dref(), x);
}
......@@ -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) {
......
......@@ -165,7 +165,7 @@ public:
line_builder();
template <class T>
detail::enable_if_t<!std::is_pointer<T>::value, line_builder&>
detail::enable_if_t<!std::is_pointer_v<T>, line_builder&>
operator<<(const T& x) {
if (!str_.empty())
str_ += " ";
......
......@@ -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<typename std::decay<T>::type, message>::value
std::enable_if_t<!std::is_same_v<typename std::decay<T>::type, message>
|| (sizeof...(Ts) > 0),
mailbox_element_ptr>
make_mailbox_element(strong_actor_ptr sender, message_id id,
......
......@@ -206,7 +206,7 @@ inline message make_message() {
template <class... Ts>
message make_message(Ts&&... xs) {
using namespace detail;
static_assert((!std::is_pointer<strip_and_convert_t<Ts>>::value && ...));
static_assert((!std::is_pointer_v<strip_and_convert_t<Ts>> && ...));
static_assert((is_complete<type_id<strip_and_convert_t<Ts>>> && ...));
static constexpr size_t data_size
= sizeof(message_data) + (padded_size_v<strip_and_convert_t<Ts>> + ...);
......@@ -230,7 +230,7 @@ message make_message_from_tuple(Tuple&& xs, std::index_sequence<Is...>) {
template <class Tuple>
message make_message_from_tuple(Tuple&& xs) {
using tuple_type = std::decay_t<Tuple>;
std::make_index_sequence<std::tuple_size<tuple_type>::value> seq;
std::make_index_sequence<std::tuple_size_v<tuple_type>> seq;
return make_message_from_tuple(std::forward<Tuple>(xs), seq);
}
......
......@@ -230,8 +230,7 @@ private:
}
template <class T = Base>
detail::enable_if_t<std::is_base_of<abstract_actor, T>::value, Subtype*>
dptr() {
detail::enable_if_t<std::is_base_of_v<abstract_actor, T>, Subtype*> dptr() {
return static_cast<Subtype*>(this);
}
......
......@@ -21,9 +21,9 @@ class event_based_mtl {
public:
// -- sanity checks ----------------------------------------------------------
static_assert(std::is_nothrow_copy_assignable<Adapter>::value);
static_assert(std::is_nothrow_copy_assignable_v<Adapter>);
static_assert(std::is_nothrow_move_assignable<Adapter>::value);
static_assert(std::is_nothrow_move_assignable_v<Adapter>);
// -- constructors, destructors, and assignment operators --------------------
......@@ -102,7 +102,7 @@ private:
/// @ref deserializer directly or that provides a compatible API.
template <class Self, class Adapter, class Reader>
auto make_mtl(Self* self, Adapter adapter, Reader* reader) {
if constexpr (std::is_base_of<non_blocking_actor_base, Self>::value) {
if constexpr (std::is_base_of_v<non_blocking_actor_base, Self>) {
return event_based_mtl{self, adapter, reader};
} else {
static_assert(detail::always_false_v<Self>,
......
......@@ -28,6 +28,7 @@
#include <random>
#include <sstream>
#include <string_view>
#include <tuple>
namespace {
......@@ -181,7 +182,7 @@ node_id make_node_id(uint32_t process_id,
std::optional<node_id> make_node_id(uint32_t process_id,
std::string_view host_hash) {
using id_type = hashed_node_id::host_id_type;
if (host_hash.size() != std::tuple_size<id_type>::value * 2)
if (host_hash.size() != std::tuple_size_v<id_type> * 2)
return std::nullopt;
detail::parser::ascii_to_int<16, uint8_t> xvalue;
id_type host_id;
......
......@@ -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));
}
......@@ -45,8 +45,7 @@ public:
}
}
optional(optional&& other) noexcept(
std::is_nothrow_move_constructible<T>::value)
optional(optional&& other) noexcept(std::is_nothrow_move_constructible_v<T>)
: m_valid(false) {
if (other.m_valid) {
cr(std::move(other.m_value));
......@@ -70,8 +69,7 @@ public:
}
optional& operator=(optional&& other) noexcept(
std::is_nothrow_destructible<T>::value&&
std::is_nothrow_move_assignable<T>::value) {
std::is_nothrow_destructible_v<T>&& std::is_nothrow_move_assignable_v<T>) {
if (m_valid) {
if (other.m_valid)
m_value = std::move(other.m_value);
......
......@@ -239,7 +239,7 @@ public:
template <class T>
static auto field(std::string_view name, T& x) {
static_assert(!std::is_const<T>::value);
static_assert(!std::is_const_v<T>);
return field_t<T>{name, std::addressof(x)};
}
......
......@@ -81,7 +81,7 @@ public:
template <class T>
bool tuple(const T& xs) {
return tuple(xs, std::make_index_sequence<std::tuple_size<T>::value>{});
return tuple(xs, std::make_index_sequence<std::tuple_size_v<T>>{});
}
template <class T, size_t N>
......
......@@ -134,7 +134,7 @@ public:
/// @copydoc value
template <class T>
std::enable_if_t<std::is_integral<T>::value, bool> value(T x) {
std::enable_if_t<std::is_integral_v<T>, bool> value(T x) {
return value(static_cast<detail::squashed_int_t<T>>(x));
}
......
......@@ -28,7 +28,7 @@ public:
/// on whether `State::make_behavior()` exists.
template <class State, class Base>
using stateful_actor_base_t
= std::conditional_t<has_make_behavior_member<State>::value,
= std::conditional_t<has_make_behavior_member_v<State>,
stateful_actor_base<State, Base>, Base>;
} // namespace caf::detail
......@@ -46,7 +46,7 @@ public:
template <class... Ts>
explicit stateful_actor(actor_config& cfg, Ts&&... xs) : super(cfg) {
if constexpr (std::is_constructible<State, Ts&&...>::value)
if constexpr (std::is_constructible_v<State, Ts&&...>)
new (&state) State(std::forward<Ts>(xs)...);
else
new (&state) State(this, std::forward<Ts>(xs)...);
......
......@@ -31,13 +31,12 @@ struct is_string_like {
const U* x,
// check if `x->data()` returns const char*
std::enable_if_t<
std::is_same<const char*, decltype(x->data())>::value>* = nullptr,
std::is_same_v<const char*, decltype(x->data())>>* = nullptr,
// check if `x->size()` returns an integer
std::enable_if_t<std::is_integral<decltype(x->size())>::value>* = nullptr,
std::enable_if_t<std::is_integral_v<decltype(x->size())>>* = nullptr,
// check if `x->find('?', 0)` is well-formed and returns an integer
// (distinguishes vectors from strings)
std::enable_if_t<
std::is_integral<decltype(x->find('?', 0))>::value>* = nullptr);
std::enable_if_t<std::is_integral_v<decltype(x->find('?', 0))>>* = nullptr);
// SFINAE fallback.
static void sfinae(void*);
......
......@@ -58,7 +58,7 @@ template <class... Ts>
void append(prometheus::char_buffer&, double, Ts&&...);
template <class T, class... Ts>
std::enable_if_t<std::is_integral<T>::value>
std::enable_if_t<std::is_integral_v<T>>
append(prometheus::char_buffer& buf, T val, Ts&&... xs);
template <class... Ts>
......@@ -120,7 +120,7 @@ void append(prometheus::char_buffer& buf, double val, Ts&&... xs) {
}
template <class T, class... Ts>
std::enable_if_t<std::is_integral<T>::value>
std::enable_if_t<std::is_integral_v<T>>
append(prometheus::char_buffer& buf, T val, Ts&&... xs) {
append(buf, std::to_string(val));
append(buf, std::forward<Ts>(xs)...);
......
......@@ -131,7 +131,7 @@ public:
// Enable `handle_type{self}` for typed actor views.
template <class T, class = std::enable_if_t<
std::is_base_of<typed_actor_view_base, T>::value>>
std::is_base_of_v<typed_actor_view_base, T>>>
explicit typed_actor(T ptr) : ptr_(ptr.ctrl()) {
static_assert(
detail::tl_subset_of<signatures, typename T::signatures>::value,
......
......@@ -75,8 +75,7 @@ public:
/// Satisfies the promise by sending a non-error response message.
template <class... Us>
std::enable_if_t<(std::is_constructible<Ts, Us>::value && ...)>
deliver(Us... xs) {
std::enable_if_t<(std::is_constructible_v<Ts, Us> && ...)> deliver(Us... xs) {
promise_.deliver(Ts{std::forward<Us>(xs)}...);
}
......
......@@ -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() {
......
......@@ -223,7 +223,7 @@ void check_integer_options(std::false_type) {
// only works with an integral types and double
template <class T>
void check_integer_options() {
std::integral_constant<bool, std::is_unsigned<T>::value> tk;
std::integral_constant<bool, std::is_unsigned_v<T>> tk;
check_integer_options<T>(tk);
}
......
......@@ -105,13 +105,12 @@ struct range_parser {
};
template <class T>
typename std::enable_if<std::is_integral<T>::value, res_t>::type res(T x) {
typename std::enable_if<std::is_integral_v<T>, res_t>::type res(T x) {
return {static_cast<int64_t>(x)};
}
template <class T>
typename std::enable_if<std::is_floating_point<T>::value, res_t>::type
res(T x) {
typename std::enable_if<std::is_floating_point_v<T>, res_t>::type res(T x) {
return {static_cast<double>(x)};
}
......
......@@ -72,13 +72,12 @@ struct fixture {
};
template <class T>
typename std::enable_if<std::is_integral<T>::value, res_t>::type res(T x) {
typename std::enable_if<std::is_integral_v<T>, res_t>::type res(T x) {
return res_t{static_cast<int64_t>(x)};
}
template <class T>
typename std::enable_if<std::is_floating_point<T>::value, res_t>::type
res(T x) {
typename std::enable_if<std::is_floating_point_v<T>, res_t>::type res(T x) {
return res_t{static_cast<double>(x)};
}
......
......@@ -231,14 +231,14 @@ private:
};
CAF_TEST(is_comparable) {
CHECK((is_comparable<double, std::string>::value) == false);
CHECK((is_comparable<foo, foo>::value) == false);
CHECK((is_comparable<bar, bar>::value) == true);
CHECK((is_comparable<double, bar>::value) == false);
CHECK((is_comparable<bar, double>::value) == false);
CHECK((is_comparable<baz, baz>::value) == true);
CHECK((is_comparable<double, baz>::value) == false);
CHECK((is_comparable<baz, double>::value) == false);
CHECK((is_comparable<std::string, baz>::value) == false);
CHECK((is_comparable<baz, std::string>::value) == false);
CHECK((is_comparable_v<double, std::string>) == false);
CHECK((is_comparable_v<foo, foo>) == false);
CHECK((is_comparable_v<bar, bar>) == true);
CHECK((is_comparable_v<double, bar>) == false);
CHECK((is_comparable_v<bar, double>) == false);
CHECK((is_comparable_v<baz, baz>) == true);
CHECK((is_comparable_v<double, baz>) == false);
CHECK((is_comparable_v<baz, double>) == false);
CHECK((is_comparable_v<std::string, baz>) == false);
CHECK((is_comparable_v<baz, std::string>) == false);
}
......@@ -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);
}
......
......@@ -12,6 +12,7 @@
#include "caf/config.hpp"
#include "caf/init_global_meta_objects.hpp"
#include <tuple>
#include <type_traits>
CAF_PUSH_WARNINGS
......@@ -164,8 +165,7 @@ public:
return *this;
}
template <class T,
class E = caf::detail::enable_if_t<!std::is_pointer<T>::value>>
template <class T, class E = caf::detail::enable_if_t<!std::is_pointer_v<T>>>
caf_handle& operator=(const T& x) {
set(x);
return *this;
......
......@@ -66,14 +66,14 @@ struct compare_visitor {
struct equality_operator {
static constexpr bool default_value = false;
template <class T, class U,
detail::enable_if_t<((std::is_floating_point<T>::value
&& std::is_convertible<U, double>::value)
|| (std::is_floating_point<U>::value
&& std::is_convertible<T, double>::value))
&& detail::is_comparable<T, U>::value,
int>
= 0>
template <
class T, class U,
detail::enable_if_t<
((std::is_floating_point_v<T> && std::is_convertible_v<U, double>)
|| (std::is_floating_point_v<U> && std::is_convertible_v<T, double>) )
&& detail::is_comparable_v<T, U>,
int>
= 0>
bool operator()(const T& t, const U& u) const {
auto x = static_cast<long double>(t);
auto y = static_cast<long double>(u);
......@@ -82,21 +82,20 @@ struct equality_operator {
return dif <= max * 1e-5l;
}
template <class T, class U,
detail::enable_if_t<!((std::is_floating_point<T>::value
&& std::is_convertible<U, double>::value)
|| (std::is_floating_point<U>::value
&& std::is_convertible<T, double>::value))
&& detail::is_comparable<T, U>::value,
int>
= 0>
template <
class T, class U,
detail::enable_if_t<
!((std::is_floating_point_v<T> && std::is_convertible_v<U, double>)
|| (std::is_floating_point_v<U> && std::is_convertible_v<T, double>) )
&& detail::is_comparable_v<T, U>,
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<T, U>::value, int>::type = 0>
template <class T, class U,
typename std::enable_if<!detail::is_comparable_v<T, U>>::type = 0>
bool operator()(const T&, const U&) const {
return default_value;
}
......@@ -106,10 +105,10 @@ struct inequality_operator {
static constexpr bool default_value = true;
template <class T, class U,
typename std::enable_if<(std::is_floating_point<T>::value
|| std::is_floating_point<U>::value)
&& detail::is_comparable<T, U>::value,
int>::type
typename std::enable_if<
(std::is_floating_point_v<T>
|| std::is_floating_point_v<U>) &&detail::is_comparable_v<T, U>,
int>::type
= 0>
bool operator()(const T& x, const U& y) const {
equality_operator f;
......@@ -117,18 +116,17 @@ struct inequality_operator {
}
template <class T, class U,
typename std::enable_if<!std::is_floating_point<T>::value
&& !std::is_floating_point<U>::value
&& detail::is_comparable<T, U>::value,
typename std::enable_if<!std::is_floating_point_v<T>
&& !std::is_floating_point_v<U>
&& detail::is_comparable_v<T, U>,
int>::type
= 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<T, U>::value, int>::type = 0>
template <class T, class U,
typename std::enable_if<!detail::is_comparable_v<T, U>>::type = 0>
bool operator()(const T&, const U&) const {
return default_value;
}
......@@ -294,7 +292,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