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

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

parent 8ce060cf
......@@ -142,9 +142,8 @@ 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(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...>;
......
......@@ -290,7 +290,7 @@ 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};
......@@ -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
......
......@@ -406,7 +406,7 @@ bool pull(config_value_reader& reader, T& x) {
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
......
......@@ -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)) {
......
......@@ -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.
......
......@@ -133,7 +133,7 @@ std::enable_if_t<std::is_integral_v<T>> print(Buffer& buf, T x) {
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
......
......@@ -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);
}
......
......@@ -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;
};
......
......@@ -91,7 +91,7 @@ public:
template <class Integral>
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));
else
return int_value(static_cast<uint64_t>(x));
......
......@@ -146,7 +146,7 @@ struct is_primitive {
static constexpr bool value = std::is_convertible_v<T, std::string>
|| std::is_convertible_v<T, std::u16string>
|| std::is_convertible_v<T, std::u32string>
|| std::is_arithmetic<T>::value;
|| std::is_arithmetic_v<T>;
};
/// Checks whether `T1` is comparable with `T2`.
......@@ -327,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>;
......@@ -422,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`
......@@ -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.
// 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>
......@@ -865,7 +864,7 @@ template <class T>
struct is_stl_tuple_type {
template <class 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>
static auto sfinae(...) -> std::false_type;
......@@ -1003,7 +1002,7 @@ constexpr bool accepts_opaque_value_v
/// 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;
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...)> {
......
......@@ -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>;
......
......@@ -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
......
......@@ -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};
}
......
......@@ -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);
}
......
......@@ -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 --------------------
......
......@@ -28,6 +28,8 @@
#include <random>
#include <sstream>
#include <string_view>
#include <tuple>
namespace {
......@@ -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::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;
......
......@@ -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)};
}
......
......@@ -12,8 +12,10 @@
#include "caf/config.hpp"
#include "caf/init_global_meta_objects.hpp"
#include <tuple>
#include <type_traits>
CAF_PUSH_WARNINGS
/// The type of `_`.
......
......@@ -105,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_v<T>
|| std::is_floating_point<U>::value)
&& detail::is_comparable_v<T, U>,
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;
......
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