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

Refactor remaining std::$pred<>::value to std::$pred_v<>

parent 8ce060cf
...@@ -142,8 +142,7 @@ actor_factory_result dyn_spawn_class(actor_config& cfg, message& msg) { ...@@ -142,8 +142,7 @@ actor_factory_result dyn_spawn_class(actor_config& cfg, message& msg) {
template <class T, class... Ts> template <class T, class... Ts>
actor_factory make_actor_factory() { actor_factory make_actor_factory() {
static_assert( static_assert(detail::conjunction<std::is_lvalue_reference_v<Ts>...>::value,
detail::conjunction<std::is_lvalue_reference<Ts>::value...>::value,
"all Ts must be lvalue references"); "all Ts must be lvalue references");
static_assert(std::is_base_of_v<local_actor, T>, static_assert(std::is_base_of_v<local_actor, T>,
"T is not derived from local_actor"); "T is not derived from local_actor");
......
...@@ -290,7 +290,7 @@ private: ...@@ -290,7 +290,7 @@ private:
void set(T x) { void set(T x) {
if constexpr (detail::is_config_value_type_v<T>) { if constexpr (detail::is_config_value_type_v<T>) {
data_ = std::move(x); 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); data_ = static_cast<int64_t>(x);
} else if constexpr (std::is_convertible<T, const char*>::value) { } else if constexpr (std::is_convertible<T, const char*>::value) {
data_ = std::string{x}; data_ = std::string{x};
...@@ -365,7 +365,7 @@ expected<T> get_as(const config_value& x, inspector_access_type::builtin) { ...@@ -365,7 +365,7 @@ expected<T> get_as(const config_value& x, inspector_access_type::builtin) {
return to_string(x); return to_string(x);
} else if constexpr (std::is_same_v<T, bool>) { } else if constexpr (std::is_same_v<T, bool>) {
return x.to_boolean(); 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 (auto result = x.to_integer()) {
if (detail::bounds_checker<T>::check(*result)) if (detail::bounds_checker<T>::check(*result))
return static_cast<T>(*result); return static_cast<T>(*result);
...@@ -374,7 +374,7 @@ expected<T> get_as(const config_value& x, inspector_access_type::builtin) { ...@@ -374,7 +374,7 @@ expected<T> get_as(const config_value& x, inspector_access_type::builtin) {
} else { } else {
return std::move(result.error()); 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 (auto result = x.to_real()) {
if constexpr (sizeof(T) >= sizeof(config_value::real)) { if constexpr (sizeof(T) >= sizeof(config_value::real)) {
return *result; return *result;
...@@ -419,10 +419,9 @@ get_as_tuple(const config_value::list& x, std::index_sequence<Is...>) { ...@@ -419,10 +419,9 @@ get_as_tuple(const config_value::list& x, std::index_sequence<Is...>) {
template <class T> template <class T>
expected<T> get_as(const config_value& x, inspector_access_type::tuple) { expected<T> get_as(const config_value& x, inspector_access_type::tuple) {
static_assert(!std::is_array<T>::value, static_assert(!std::is_array_v<T>, "cannot return an array from a function");
"cannot return an array from a function");
if (auto wrapped_values = x.to_list()) { 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) if (wrapped_values->size() == n)
return get_as_tuple<T>(*wrapped_values, std::make_index_sequence<n>{}); return get_as_tuple<T>(*wrapped_values, std::make_index_sequence<n>{});
else else
......
...@@ -406,7 +406,7 @@ bool pull(config_value_reader& reader, T& x) { ...@@ -406,7 +406,7 @@ bool pull(config_value_reader& reader, T& x) {
using internal_type using internal_type
= std::conditional_t<std::is_floating_point_v<T>, config_value::real, T>; = std::conditional_t<std::is_floating_point_v<T>, config_value::real, T>;
auto assign = [&x](auto& result) { 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); x = static_cast<T>(result);
} else { } else {
x = result; x = result;
......
...@@ -42,7 +42,7 @@ struct dmi<typed_response_promise<Out...>(In...)> { ...@@ -42,7 +42,7 @@ struct dmi<typed_response_promise<Out...>(In...)> {
// -- dmfou = deduce_mpi_function_object_unboxing // -- 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; struct dmfou;
// case #1a: const member function pointer // case #1a: const member function pointer
......
...@@ -47,7 +47,7 @@ class init_fun_factory_helper final : public init_fun_factory_helper_base { ...@@ -47,7 +47,7 @@ class init_fun_factory_helper final : public init_fun_factory_helper_base {
public: public:
using args_pointer = std::shared_ptr<Tuple>; 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) init_fun_factory_helper(F fun, args_pointer args)
: fun_(std::move(fun)), args_(std::move(args)) { : fun_(std::move(fun)), args_(std::move(args)) {
......
...@@ -28,8 +28,7 @@ template <class State, class Consumer> ...@@ -28,8 +28,7 @@ template <class State, class Consumer>
void read_signed_integer(State& ps, Consumer&& consumer) { void read_signed_integer(State& ps, Consumer&& consumer) {
using consumer_type = typename std::decay<Consumer>::type; using consumer_type = typename std::decay<Consumer>::type;
using value_type = typename consumer_type::value_type; using value_type = typename consumer_type::value_type;
static_assert(std::is_integral<value_type>::value static_assert(std::is_integral_v<value_type> && std::is_signed_v<value_type>,
&& std::is_signed<value_type>::value,
"expected a signed integer type"); "expected a signed integer type");
value_type result = 0; value_type result = 0;
// Computes the result on success. // Computes the result on success.
......
...@@ -28,8 +28,8 @@ template <class State, class Consumer> ...@@ -28,8 +28,8 @@ template <class State, class Consumer>
void read_unsigned_integer(State& ps, Consumer&& consumer) { void read_unsigned_integer(State& ps, Consumer&& consumer) {
using consumer_type = typename std::decay<Consumer>::type; using consumer_type = typename std::decay<Consumer>::type;
using value_type = typename consumer_type::value_type; using value_type = typename consumer_type::value_type;
static_assert(std::is_integral<value_type>::value static_assert(std::is_integral_v<value_type>
&& std::is_unsigned<value_type>::value, && std::is_unsigned_v<value_type>,
"expected an unsigned integer type"); "expected an unsigned integer type");
value_type result = 0; value_type result = 0;
// Computes the result on success. // Computes the result on success.
......
...@@ -133,7 +133,7 @@ std::enable_if_t<std::is_integral_v<T>> print(Buffer& buf, T x) { ...@@ -133,7 +133,7 @@ std::enable_if_t<std::is_integral_v<T>> print(Buffer& buf, T x) {
char stack_buffer[24]; char stack_buffer[24];
char* p = stack_buffer; char* p = stack_buffer;
// Convert negative values into positives as necessary. // 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()) { if (x == std::numeric_limits<T>::min()) {
using namespace std::literals; using namespace std::literals;
// The code below would fail for the smallest value, because this value // The code below would fail for the smallest value, because this value
......
...@@ -40,7 +40,7 @@ typename std::conditional< ...@@ -40,7 +40,7 @@ typename std::conditional<
spawn_fwd_convert<typename std::remove_reference<T>::type>::value, actor, spawn_fwd_convert<typename std::remove_reference<T>::type>::value, actor,
T&&>::type T&&>::type
spawn_fwd(typename std::remove_reference<T>::type&& arg) noexcept { 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"); "silently converting an lvalue to an rvalue");
return static_cast<T&&>(arg); return static_cast<T&&>(arg);
} }
......
...@@ -50,7 +50,7 @@ struct squashed_int { ...@@ -50,7 +50,7 @@ struct squashed_int {
template <class T> template <class T>
using squashed_int_t = typename squashed_int<T>::type; 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 { struct squash_if_int {
using type = T; using type = T;
}; };
......
...@@ -91,7 +91,7 @@ public: ...@@ -91,7 +91,7 @@ public:
template <class Integral> template <class Integral>
std::enable_if_t<std::is_integral_v<Integral>, bool> value(Integral x) { std::enable_if_t<std::is_integral_v<Integral>, bool> value(Integral x) {
if constexpr (std::is_signed<Integral>::value) if constexpr (std::is_signed_v<Integral>)
return int_value(static_cast<int64_t>(x)); return int_value(static_cast<int64_t>(x));
else else
return int_value(static_cast<uint64_t>(x)); return int_value(static_cast<uint64_t>(x));
......
...@@ -146,7 +146,7 @@ struct is_primitive { ...@@ -146,7 +146,7 @@ struct is_primitive {
static constexpr bool value = std::is_convertible_v<T, std::string> static constexpr bool value = std::is_convertible_v<T, std::string>
|| std::is_convertible_v<T, std::u16string> || std::is_convertible_v<T, std::u16string>
|| std::is_convertible_v<T, std::u32string> || std::is_convertible_v<T, std::u32string>
|| std::is_arithmetic<T>::value; || std::is_arithmetic_v<T>;
}; };
/// Checks whether `T1` is comparable with `T2`. /// Checks whether `T1` is comparable with `T2`.
...@@ -327,9 +327,9 @@ struct has_apply_operator { ...@@ -327,9 +327,9 @@ struct has_apply_operator {
// matches (IsFun || IsMemberFun) // matches (IsFun || IsMemberFun)
template <class T, template <class T,
bool IsFun bool IsFun
= std::is_function<T>::value = std::is_function_v<T>
|| std::is_function<typename std::remove_pointer<T>::type>::value || 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> bool HasApplyOp = has_apply_operator<T>::value>
struct get_callable_trait_helper { struct get_callable_trait_helper {
using type = callable_trait<T>; using type = callable_trait<T>;
...@@ -422,7 +422,7 @@ struct type_at<0, T0, Ts...> { ...@@ -422,7 +422,7 @@ struct type_at<0, T0, Ts...> {
}; };
// Checks whether T has a member variable named `name`. // 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 { class has_name {
private: private:
// a simple struct with a member called `name` // a simple struct with a member called `name`
...@@ -556,15 +556,14 @@ constexpr bool is_expected_v = is_expected<T>::value; ...@@ -556,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. // Checks whether `T` and `U` are integers of the same size and signedness.
// clang-format off // clang-format off
template <class T, class U, template <class T, class U,
bool Enable = std::is_integral<T>::value bool Enable = std::is_integral_v<T>
&& std::is_integral<U>::value && std::is_integral_v<U>
&& !std::is_same_v<T, bool> && !std::is_same_v<T, bool>
&& !std::is_same_v<U, bool>> && !std::is_same_v<U, bool>>
// clang-format on // clang-format on
struct is_equal_int_type { struct is_equal_int_type {
static constexpr bool value = sizeof(T) == sizeof(U) static constexpr bool value = sizeof(T) == sizeof(U)
&& std::is_signed<T>::value && std::is_signed_v<T> == std::is_signed_v<U>;
== std::is_signed<U>::value;
}; };
template <class T, typename U> template <class T, typename U>
...@@ -865,7 +864,7 @@ template <class T> ...@@ -865,7 +864,7 @@ template <class T>
struct is_stl_tuple_type { struct is_stl_tuple_type {
template <class U> template <class U>
static auto sfinae(U*) static auto sfinae(U*)
-> decltype(std::integral_constant<bool, std::tuple_size<U>::value >= 0>{}); -> decltype(std::integral_constant<bool, std::tuple_size<U>::value>{});
template <class U> template <class U>
static auto sfinae(...) -> std::false_type; static auto sfinae(...) -> std::false_type;
...@@ -1003,7 +1002,7 @@ constexpr bool accepts_opaque_value_v ...@@ -1003,7 +1002,7 @@ constexpr bool accepts_opaque_value_v
/// convertible to one of STL's string types. /// convertible to one of STL's string types.
template <class T, bool IsLoading> template <class T, bool IsLoading>
struct is_builtin_inspector_type { 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> template <bool IsLoading>
......
...@@ -125,9 +125,8 @@ struct is_normalized_signature { ...@@ -125,9 +125,8 @@ struct is_normalized_signature {
}; };
template <class T> template <class T>
constexpr bool is_decayed = !std::is_reference<T>::value constexpr bool is_decayed = !std::is_reference_v<T> && !std::is_const_v<T>
&& !std::is_const<T>::value && !std::is_volatile_v<T>;
&& !std::is_volatile<T>::value;
template <class... Out, class... In> template <class... Out, class... In>
struct is_normalized_signature<result<Out...>(In...)> { struct is_normalized_signature<result<Out...>(In...)> {
......
...@@ -53,14 +53,12 @@ public: ...@@ -53,14 +53,12 @@ public:
// -- static member variables ------------------------------------------------ // -- static member variables ------------------------------------------------
/// Stores whether move construct and move assign never throw. /// Stores whether move construct and move assign never throw.
static constexpr bool nothrow_move static constexpr bool nothrow_move = std::is_nothrow_move_constructible_v<T>
= std::is_nothrow_move_constructible<T>::value && std::is_nothrow_move_assignable_v<T>;
&& std::is_nothrow_move_assignable<T>::value;
/// Stores whether copy construct and copy assign never throw. /// Stores whether copy construct and copy assign never throw.
static constexpr bool nothrow_copy static constexpr bool nothrow_copy = std::is_nothrow_copy_constructible_v<T>
= std::is_nothrow_copy_constructible<T>::value && std::is_nothrow_copy_assignable_v<T>;
&& std::is_nothrow_copy_assignable<T>::value;
/// Stores whether swap() never throws. /// Stores whether swap() never throws.
static constexpr bool nothrow_swap = std::is_nothrow_swappable_v<T>; static constexpr bool nothrow_swap = std::is_nothrow_swappable_v<T>;
......
...@@ -240,7 +240,7 @@ bool save(Inspector& f, T& x) { ...@@ -240,7 +240,7 @@ bool save(Inspector& f, T& x) {
template <class Inspector, class T> template <class Inspector, class T>
bool save(Inspector& f, const T& x) { 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>()); return save(f, as_mutable_ref(x), inspect_access_type<Inspector, T>());
} else { } else {
// Only inspector such as the stringification_inspector are going to accept // Only inspector such as the stringification_inspector are going to accept
......
...@@ -343,7 +343,7 @@ public: ...@@ -343,7 +343,7 @@ public:
template <class T> template <class T>
static auto field(std::string_view name, T& x) { 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}; return field_t<T>{name, &x};
} }
......
...@@ -105,7 +105,7 @@ public: ...@@ -105,7 +105,7 @@ public:
template <class T> template <class T>
[[nodiscard]] bool apply(T& x) { [[nodiscard]] bool apply(T& x) {
static_assert(!std::is_const<T>::value); static_assert(!std::is_const_v<T>);
return detail::load(dref(), x); return detail::load(dref(), x);
} }
......
...@@ -21,9 +21,9 @@ class event_based_mtl { ...@@ -21,9 +21,9 @@ class event_based_mtl {
public: public:
// -- sanity checks ---------------------------------------------------------- // -- 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 -------------------- // -- constructors, destructors, and assignment operators --------------------
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#include <random> #include <random>
#include <sstream> #include <sstream>
#include <string_view> #include <string_view>
#include <tuple>
namespace { namespace {
...@@ -181,7 +183,7 @@ node_id make_node_id(uint32_t process_id, ...@@ -181,7 +183,7 @@ node_id make_node_id(uint32_t process_id,
std::optional<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) { std::string_view host_hash) {
using id_type = hashed_node_id::host_id_type; 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; return std::nullopt;
detail::parser::ascii_to_int<16, uint8_t> xvalue; detail::parser::ascii_to_int<16, uint8_t> xvalue;
id_type host_id; id_type host_id;
......
...@@ -45,8 +45,7 @@ public: ...@@ -45,8 +45,7 @@ public:
} }
} }
optional(optional&& other) noexcept( optional(optional&& other) noexcept(std::is_nothrow_move_constructible_v<T>)
std::is_nothrow_move_constructible<T>::value)
: m_valid(false) { : m_valid(false) {
if (other.m_valid) { if (other.m_valid) {
cr(std::move(other.m_value)); cr(std::move(other.m_value));
...@@ -70,8 +69,7 @@ public: ...@@ -70,8 +69,7 @@ public:
} }
optional& operator=(optional&& other) noexcept( optional& operator=(optional&& other) noexcept(
std::is_nothrow_destructible<T>::value&& std::is_nothrow_destructible_v<T>&& std::is_nothrow_move_assignable_v<T>) {
std::is_nothrow_move_assignable<T>::value) {
if (m_valid) { if (m_valid) {
if (other.m_valid) if (other.m_valid)
m_value = std::move(other.m_value); m_value = std::move(other.m_value);
......
...@@ -239,7 +239,7 @@ public: ...@@ -239,7 +239,7 @@ public:
template <class T> template <class T>
static auto field(std::string_view name, T& x) { 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)}; return field_t<T>{name, std::addressof(x)};
} }
......
...@@ -12,8 +12,10 @@ ...@@ -12,8 +12,10 @@
#include "caf/config.hpp" #include "caf/config.hpp"
#include "caf/init_global_meta_objects.hpp" #include "caf/init_global_meta_objects.hpp"
#include <tuple>
#include <type_traits> #include <type_traits>
CAF_PUSH_WARNINGS CAF_PUSH_WARNINGS
/// The type of `_`. /// The type of `_`.
......
...@@ -105,9 +105,9 @@ struct inequality_operator { ...@@ -105,9 +105,9 @@ struct inequality_operator {
static constexpr bool default_value = true; static constexpr bool default_value = true;
template <class T, class U, template <class T, class U,
typename std::enable_if<(std::is_floating_point_v<T> typename std::enable_if<
|| std::is_floating_point<U>::value) (std::is_floating_point_v<T>
&& detail::is_comparable_v<T, U>, || std::is_floating_point_v<U>) &&detail::is_comparable_v<T, U>,
int>::type int>::type
= 0> = 0>
bool operator()(const T& x, const U& y) const { bool operator()(const T& x, const U& y) const {
......
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