Commit 2994355f authored by Shariar Azad Riday's avatar Shariar Azad Riday

Refactor all calls to is_same::value to is_same_v

parent f42cf82d
......@@ -173,7 +173,7 @@ struct variant_inspector_traits<shape_ptr> {
// Assigns a value to x.
template <class U>
static void assign(value_type& x, U value) {
if constexpr (std::is_same<U, none_t>::value)
if constexpr (std::is_same_v<U, none_t>)
x.reset();
else
x = std::make_shared<U>(std::move(value));
......
......@@ -155,7 +155,7 @@ behavior running(stateful_actor<state>* self, const actor& calculator) {
.then(
[=](int result) {
const char* op_str;
if constexpr (std::is_same<add_atom, decltype(op)>::value)
if constexpr (std::is_same_v<add_atom, decltype(op)>)
op_str = " + ";
else
op_str = " - ";
......
......@@ -465,7 +465,7 @@ public:
template <class T, spawn_options Os, class Iter, class... Ts>
infer_handle_from_class_t<T>
spawn_class_in_groups(actor_config& cfg, Iter first, Iter last, Ts&&... xs) {
static_assert(std::is_same<infer_handle_from_class_t<T>, actor>::value,
static_assert(std::is_same_v<infer_handle_from_class_t<T>, actor>,
"only dynamically-typed actors can be spawned in a group");
check_invariants<T>();
auto irange = make_input_range(first, last);
......
......@@ -98,7 +98,7 @@ public:
config_value(const config_value& other) = default;
template <class T, class E = detail::enable_if_t<
!std::is_same<detail::decay_t<T>, config_value>::value>>
!std::is_same_v<detail::decay_t<T>, config_value>>>
explicit config_value(T&& x) {
set(std::forward<T>(x));
}
......@@ -108,7 +108,7 @@ public:
config_value& operator=(const config_value& other) = default;
template <class T, class E = detail::enable_if_t<
!std::is_same<detail::decay_t<T>, config_value>::value>>
!std::is_same_v<detail::decay_t<T>, config_value>>>
config_value& operator=(T&& x) {
set(std::forward<T>(x));
return *this;
......@@ -361,9 +361,9 @@ get_as(const config_value& x, inspector_access_type::builtin_inspect token) {
template <class T>
expected<T> get_as(const config_value& x, inspector_access_type::builtin) {
if constexpr (std::is_same<T, std::string>::value) {
if constexpr (std::is_same_v<T, std::string>) {
return to_string(x);
} else if constexpr (std::is_same<T, bool>::value) {
} else if constexpr (std::is_same_v<T, bool>) {
return x.to_boolean();
} else if constexpr (std::is_integral<T>::value) {
if (auto result = x.to_integer()) {
......@@ -488,13 +488,13 @@ expected<T> get_as(const config_value& x, inspector_access_type::list) {
/// @relates config_value
template <class T>
expected<T> get_as(const config_value& value) {
if constexpr (std::is_same<T, timespan>::value) {
if constexpr (std::is_same_v<T, timespan>) {
return value.to_timespan();
} else if constexpr (std::is_same<T, config_value::list>::value) {
} else if constexpr (std::is_same_v<T, config_value::list>) {
return value.to_list();
} else if constexpr (std::is_same<T, config_value::dictionary>::value) {
} else if constexpr (std::is_same_v<T, config_value::dictionary>) {
return value.to_dictionary();
} else if constexpr (std::is_same<T, uri>::value) {
} else if constexpr (std::is_same_v<T, uri>) {
return value.to_uri();
} else {
auto token = inspect_access_type<config_value_reader, T>();
......@@ -550,7 +550,7 @@ struct get_or_auto_deduce {};
/// @relates config_value
template <class To = get_or_auto_deduce, class Fallback>
auto get_or(const config_value& x, Fallback&& fallback) {
if constexpr (std::is_same<To, get_or_auto_deduce>::value) {
if constexpr (std::is_same_v<To, get_or_auto_deduce>) {
using guide = get_or_deduction_guide<std::decay_t<Fallback>>;
using value_type = typename guide::value_type;
if (auto val = get_as<value_type>(x))
......
......@@ -440,7 +440,7 @@ bool pull(config_value_reader& reader, T& x) {
}
} else if (holds_alternative<config_value_reader::key_ptr>(top)) {
auto ptr = get<config_value_reader::key_ptr>(top);
if constexpr (std::is_same<std::string, T>::value) {
if constexpr (std::is_same_v<std::string, T>) {
x = *ptr;
reader.pop();
return true;
......
......@@ -20,7 +20,7 @@
#define SCOPE(top_type) \
CHECK_NOT_EMPTY(); \
if (!holds_alternative<top_type>(st_.top())) { \
if constexpr (std::is_same<top_type, settings*>::value) { \
if constexpr (std::is_same_v<top_type, settings*>) { \
emplace_error(sec::runtime_error, \
"attempted to add list items before calling " \
"begin_sequence or begin_tuple"); \
......
......@@ -119,7 +119,7 @@ public:
if (arg_types == msg.types()) {
typename trait::message_view_type xs{msg};
using fun_result = decltype(detail::apply_args(fun, xs));
if constexpr (std::is_same<void, fun_result>::value) {
if constexpr (std::is_same_v<void, fun_result>) {
detail::apply_args(fun, xs);
f(unit);
} else {
......
......@@ -106,7 +106,7 @@ void config_consumer::destroy() {
void config_consumer::end_map() {
auto f = [this](auto ptr) {
if constexpr (std::is_same<none_t, decltype(ptr)>::value) {
if constexpr (std::is_same_v<none_t, decltype(ptr)>) {
// nop
} else {
ptr->value(std::move(*cfg_));
......
......@@ -42,7 +42,7 @@ struct mtl_util<result<Rs...>(Ts...)> {
OnError& on_error, Ts... xs) {
f.revert();
if (adapter.read(f, xs...)) {
if constexpr (std::is_same<type_list<Rs...>, type_list<void>>::value)
if constexpr (std::is_same_v<type_list<Rs...>, type_list<void>>)
self->request(dst, timeout, std::move(xs)...)
.then([f{std::move(on_result)}]() mutable { f(); },
std::move(on_error));
......
......@@ -12,7 +12,7 @@
#define CAF_FSM_EVAL_ACTION(action) \
auto action_impl = [&]() -> decltype(auto) { return action; }; \
if constexpr (std::is_same<pec, decltype(action_impl())>::value) { \
if constexpr (std::is_same_v<pec, decltype(action_impl())>) { \
if (auto code = action_impl(); code != pec::success) { \
ps.code = code; \
return; \
......
......@@ -24,11 +24,10 @@ template <class State, class Consumer>
void read_string(State& ps, Consumer&& consumer) {
// Allow Consumer to be a string&, in which case we simply store the result
// directly in the reference.
using res_type
= std::conditional_t<std::is_same<Consumer, std::string&>::value,
using res_type = std::conditional_t<std::is_same_v<Consumer, std::string&>,
std::string&, std::string>;
auto init_res = [](auto& c) -> res_type {
if constexpr (std::is_same<res_type, std::string&>::value) {
if constexpr (std::is_same_v<res_type, std::string&>) {
c.clear();
return c;
} else {
......@@ -37,7 +36,7 @@ void read_string(State& ps, Consumer&& consumer) {
};
res_type res = init_res(consumer);
auto g = caf::detail::make_scope_guard([&] {
if constexpr (std::is_same<res_type, std::string>::value)
if constexpr (std::is_same_v<res_type, std::string>)
if (ps.code <= pec::trailing_character)
consumer.value(std::move(res));
});
......
......@@ -38,7 +38,7 @@ disposable profiled_send(Self* self, SelfHandle&& src, const Handle& dst,
actor_clock& clock, actor_clock::time_point timeout,
[[maybe_unused]] message_id msg_id, Ts&&... xs) {
if (dst) {
if constexpr (std::is_same<Handle, group>::value) {
if constexpr (std::is_same_v<Handle, group>) {
return clock.schedule_message(timeout, dst, std::forward<SelfHandle>(src),
make_message(std::forward<Ts>(xs)...));
} else {
......
......@@ -26,7 +26,7 @@ void set_thread_name(const char* name) {
#ifdef CAF_WINDOWS
// nop
#else // CAF_WINDOWS
static_assert(std::is_same<std::thread::native_handle_type, pthread_t>::value,
static_assert(std::is_same_v<std::thread::native_handle_type, pthread_t>,
"std::thread not based on pthread_t");
# if defined(CAF_MACOS)
pthread_setname_np(name);
......
......@@ -172,9 +172,9 @@ public:
sep();
result_ += "null";
return true;
} else if constexpr (std::is_same<T, char>::value) {
} else if constexpr (std::is_same_v<T, char>) {
return value(std::string_view{x, strlen(x)});
} else if constexpr (std::is_same<T, void>::value) {
} else if constexpr (std::is_same_v<T, void>) {
sep();
result_ += "*<";
auto addr = reinterpret_cast<intptr_t>(x);
......@@ -218,7 +218,7 @@ public:
template <class T>
static std::string render(const T& x) {
if constexpr (std::is_same<std::nullptr_t, T>::value) {
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) {
......
......@@ -386,8 +386,7 @@ constexpr size_t tl_count<List, Pred>::value;
/// Counts the number of elements in the list which are equal to `T`.
template <class List, class T>
struct tl_count_type {
static constexpr size_t value = (std::is_same<tl_head_t<List>, T>::value ? 1
: 0)
static constexpr size_t value = (std::is_same_v<tl_head_t<List>, T> ? 1 : 0)
+ tl_count_type<tl_tail_t<List>, T>::value;
};
......@@ -676,8 +675,8 @@ struct tl_filter_type;
template <class Type, class... T>
struct tl_filter_type<type_list<T...>, Type> {
using type = typename tl_filter_impl<type_list<T...>,
!std::is_same<T, Type>::value...>::type;
using type =
typename tl_filter_impl<type_list<T...>, !std::is_same_v<T, Type>...>::type;
};
template <class List, class T>
......@@ -690,9 +689,8 @@ struct tl_filter_not_type;
template <class Type, class... T>
struct tl_filter_not_type<type_list<T...>, Type> {
using type =
typename tl_filter_impl<type_list<T...>,
(!std::is_same<T, Type>::value)...>::type;
using type = typename tl_filter_impl<type_list<T...>,
(!std::is_same_v<T, Type>) ...>::type;
};
template <class List, class T>
......
......@@ -172,7 +172,7 @@ class is_comparable {
&& std::is_arithmetic<T2>::value>{}));
public:
static constexpr bool value = std::is_same<bool, result_type>::value;
static constexpr bool value = std::is_same_v<bool, result_type>;
};
/// Checks whether `T` behaves like a forward iterator.
......@@ -194,7 +194,7 @@ class is_forward_iterator {
using result_type = decltype(sfinae(std::declval<T&>(), std::declval<T&>()));
public:
static constexpr bool value = std::is_same<bool, result_type>::value;
static constexpr bool value = std::is_same_v<bool, result_type>;
};
/// Checks whether `T` has `begin()` and `end()` member
......@@ -217,7 +217,7 @@ class is_iterable {
public:
static constexpr bool value = is_primitive<T>::value == false
&& std::is_same<bool, result_type>::value;
&& std::is_same_v<bool, result_type>;
};
template <class T>
......@@ -363,7 +363,7 @@ struct is_callable {
using result_type = decltype(_fun(static_cast<decay_t<T>*>(nullptr)));
public:
static constexpr bool value = std::is_same<bool, result_type>::value;
static constexpr bool value = std::is_same_v<bool, result_type>;
};
/// Checks whether `F` is callable with arguments of types `Ts...`.
......@@ -552,8 +552,8 @@ constexpr bool is_expected_v = is_expected<T>::value;
template <class T, class U,
bool Enable = std::is_integral<T>::value
&& std::is_integral<U>::value
&& !std::is_same<T, bool>::value
&& !std::is_same<U, bool>::value>
&& !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)
......@@ -569,7 +569,7 @@ struct is_equal_int_type<T, U, false> : std::false_type {};
/// same size and signedness. This works around the issue that
/// `uint8_t != unsigned char on some compilers.
template <class T, typename U>
struct is_same_ish : std::conditional<std::is_same<T, U>::value, std::true_type,
struct is_same_ish : std::conditional<std::is_same_v<T, U>, std::true_type,
is_equal_int_type<T, U>>::type {};
/// Utility for fallbacks calling `static_assert`.
......@@ -878,8 +878,7 @@ private:
using result_type = decltype(sfinae(std::declval<Inspector&>()));
public:
static constexpr bool value
= std::is_same<result_type, execution_unit*>::value;
static constexpr bool value = std::is_same_v<result_type, execution_unit*>;
};
/// Checks whether `T` provides an `inspect` overload for `Inspector`.
......
......@@ -39,9 +39,9 @@ struct type_checker {
static void check() {
using arg_types = typename tl_map<typename get_callable_trait<F>::arg_types,
std::decay>::type;
static_assert(std::is_same<Output, arg_types>::value
|| (std::is_same<Output, type_list<void>>::value
&& std::is_same<arg_types, type_list<>>::value),
static_assert(std::is_same_v<Output, arg_types>
|| (std::is_same_v<Output, type_list<void>>
&& std::is_same_v<arg_types, type_list<>>),
"wrong functor signature");
}
};
......
......@@ -23,7 +23,7 @@ public:
static_assert(is_error_code_enum_v<Enum>);
static_assert(std::is_same<underlying_type, uint8_t>::value);
static_assert(std::is_same_v<underlying_type, uint8_t>);
constexpr error_code() noexcept : value_(static_cast<Enum>(0)) {
// nop
......
......@@ -66,7 +66,7 @@ int exec_main(F fun, int argc, char** argv) {
"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;
static_assert(std::is_same<arg2, unit_t>::value
static_assert(std::is_same_v<arg2, unit_t>
|| (std::is_base_of<actor_system_config, decayed_arg2>::value
&& std::is_same<arg2, const decayed_arg2&>::value),
"second parameter of main function must take a subtype of "
......
......@@ -53,9 +53,9 @@ constexpr bool assertion_failed_v = false;
template <class Inspector, class Set, class ValueType>
auto bind_setter(Inspector& f, Set& set, ValueType& tmp) {
using set_result_type = decltype(set(std::move(tmp)));
if constexpr (std::is_same<set_result_type, bool>::value) {
if constexpr (std::is_same_v<set_result_type, bool>) {
return [&] { return set(std::move(tmp)); };
} else if constexpr (std::is_same<set_result_type, error>::value) {
} else if constexpr (std::is_same_v<set_result_type, error>) {
return [&] {
if (auto err = set(std::move(tmp)); !err) {
return true;
......@@ -65,7 +65,7 @@ auto bind_setter(Inspector& f, Set& set, ValueType& tmp) {
}
};
} else {
static_assert(std::is_same<set_result_type, void>::value,
static_assert(std::is_same_v<set_result_type, void>,
"a setter must return caf::error, bool or void");
return [&] {
set(std::move(tmp));
......
......@@ -282,7 +282,7 @@ public:
using load_callback_result = decltype(load_callback());
if (!(f->begin_object(object_type, object_name) && (fs(*f) && ...)))
return false;
if constexpr (std::is_same<load_callback_result, bool>::value) {
if constexpr (std::is_same_v<load_callback_result, bool>) {
if (!load_callback()) {
f->set_error(sec::load_callback_failed);
return false;
......@@ -351,11 +351,11 @@ public:
static auto field(std::string_view name, Get get, Set set) {
using field_type = std::decay_t<decltype(get())>;
using setter_result = decltype(set(std::declval<field_type&&>()));
if constexpr (std::is_same<setter_result, error>::value
|| std::is_same<setter_result, bool>::value) {
if constexpr (std::is_same_v<setter_result, error>
|| std::is_same_v<setter_result, bool>) {
return virt_field_t<field_type, Set>{name, std::move(set)};
} else {
static_assert(std::is_same<setter_result, void>::value,
static_assert(std::is_same_v<setter_result, void>,
"a setter must return caf::error, bool or void");
auto set_fun = [f{std::move(set)}](field_type&& val) {
f(std::move(val));
......@@ -371,13 +371,13 @@ public:
field(std::string_view name, IsPresent&&, Get&& get, Reset reset, Set set) {
using field_type = std::decay_t<decltype(get())>;
using setter_result = decltype(set(std::declval<field_type&&>()));
if constexpr (std::is_same<setter_result, error>::value
|| std::is_same<setter_result, bool>::value) {
if constexpr (std::is_same_v<setter_result, error>
|| std::is_same_v<setter_result, bool>) {
return optional_virt_field_t<field_type, Reset, Set>{name,
std::move(reset),
std::move(set)};
} else {
static_assert(std::is_same<setter_result, void>::value,
static_assert(std::is_same_v<setter_result, void>,
"a setter must return caf::error, bool or void");
auto set_fun = [f{std::move(set)}](field_type&& val) {
f(std::move(val));
......
......@@ -115,7 +115,7 @@ public:
using value_type = std::decay_t<decltype(get())>;
auto tmp = value_type{};
using setter_result = decltype(set(std::move(tmp)));
if constexpr (std::is_same<setter_result, bool>::value) {
if constexpr (std::is_same_v<setter_result, bool>) {
if (dref().apply(tmp)) {
if (set(std::move(tmp))) {
return true;
......@@ -126,7 +126,7 @@ public:
} else {
return false;
}
} else if constexpr (std::is_same<setter_result, void>::value) {
} else if constexpr (std::is_same_v<setter_result, void>) {
if (dref().apply(tmp)) {
set(std::move(tmp));
return true;
......
......@@ -181,7 +181,7 @@ public:
private:
template <size_t Pos, class T>
bool matches_at(const T& value) const {
if constexpr (std::is_same<T, decltype(std::ignore)>::value)
if constexpr (std::is_same_v<T, decltype(std::ignore)>)
return true;
else
return match_element<T>(Pos) && get_as<T>(Pos) == value;
......
......@@ -67,7 +67,7 @@ public:
/// Sends `{xs...}` as an asynchronous message to `dest` with priority `mp`.
template <message_priority P = message_priority::normal, class Dest,
class... Ts>
detail::enable_if_t<!std::is_same<group, Dest>::value>
detail::enable_if_t<!std::is_same_v<group, Dest>>
send(const Dest& dest, Ts&&... xs) {
static_assert(sizeof...(Ts) > 0, "no message to send");
static_assert((detail::sendable<Ts> && ...),
......@@ -99,7 +99,7 @@ public:
/// passed already).
template <message_priority P = message_priority::normal, class Dest = actor,
class... Ts>
detail::enable_if_t<!std::is_same<Dest, group>::value, disposable>
detail::enable_if_t<!std::is_same_v<Dest, group>, disposable>
scheduled_send(const Dest& dest, actor_clock::time_point timeout,
Ts&&... xs) {
static_assert(sizeof...(Ts) > 0, "no message to send");
......@@ -139,7 +139,7 @@ public:
/// Sends a message after a relative timeout.
template <message_priority P = message_priority::normal, class Rep = int,
class Period = std::ratio<1>, class Dest = actor, class... Ts>
detail::enable_if_t<!std::is_same<Dest, group>::value, disposable>
detail::enable_if_t<!std::is_same_v<Dest, group>, disposable>
delayed_send(const Dest& dest, std::chrono::duration<Rep, Period> rel_timeout,
Ts&&... xs) {
static_assert(sizeof...(Ts) > 0, "no message to send");
......
......@@ -80,7 +80,7 @@ public:
bool try_request(const typed_actor<Fs...>& dst, Timeout timeout,
OnResult on_result, OnError on_error) {
using on_error_result = decltype(on_error(std::declval<error&>()));
static_assert(std::is_same<void, on_error_result>::value);
static_assert(std::is_same_v<void, on_error_result>);
auto dst_hdl = actor_cast<actor>(dst);
return (detail::mtl_util<Fs>::request(self_, dst_hdl, timeout, adapter_,
*reader_, on_result, on_error)
......
......@@ -165,7 +165,7 @@ bool node_id::can_parse(std::string_view str) noexcept {
void append_to_string(std::string& str, const node_id& x) {
auto f = [&str](auto& x) {
if constexpr (std::is_same<std::decay_t<decltype(x)>, uri>::value)
if constexpr (std::is_same_v<std::decay_t<decltype(x)>, uri>)
str.insert(str.end(), x.str().begin(), x.str().end());
else
x.print(str);
......
......@@ -65,7 +65,7 @@ public:
static_assert(detail::is_callable_with<OnError, error&>::value,
"OnError must provide an operator() that takes a caf::error");
using result_type = typename detail::get_callable_trait<F>::result_type;
static_assert(std::is_same<void, result_type>::value,
static_assert(std::is_same_v<void, result_type>,
"response handlers are not allowed to have a return "
"type other than void");
policy_type::template type_checker<F>::check();
......@@ -90,7 +90,7 @@ public:
static_assert(detail::is_callable_with<OnError, error&>::value,
"OnError must provide an operator() that takes a caf::error");
using result_type = typename detail::get_callable_trait<F>::result_type;
static_assert(std::is_same<void, result_type>::value,
static_assert(std::is_same_v<void, result_type>,
"response handlers are not allowed to have a return "
"type other than void");
policy_type::template type_checker<F>::check();
......@@ -129,7 +129,7 @@ public:
static_assert(detail::is_callable_with<OnError, error&>::value,
"OnError must provide an operator() that takes a caf::error");
using result_type = typename detail::get_callable_trait<F>::result_type;
static_assert(std::is_same<void, result_type>::value,
static_assert(std::is_same_v<void, result_type>,
"response handlers are not allowed to have a return "
"type other than void");
policy_type::template type_checker<F>::check();
......
......@@ -117,8 +117,7 @@ public:
void deliver(expected<T> x) {
if (pending()) {
if (x) {
if constexpr (std::is_same<T, void>::value
|| std::is_same<T, unit_t>::value)
if constexpr (std::is_same_v<T, void> || std::is_same_v<T, unit_t>)
state_->deliver_impl(make_message());
else
state_->deliver_impl(make_message(std::move(*x)));
......
......@@ -61,14 +61,14 @@ public:
// enables intrusive_ptr<resumable> without introducing ambiguity
template <class T>
typename std::enable_if<std::is_same<T*, resumable*>::value>::type
typename std::enable_if<std::is_same_v<T*, resumable*>>::type
intrusive_ptr_add_ref(T* ptr) {
ptr->intrusive_ptr_add_ref_impl();
}
// enables intrusive_ptr<resumable> without introducing ambiguity
template <class T>
typename std::enable_if<std::is_same<T*, resumable*>::value>::type
typename std::enable_if<std::is_same_v<T*, resumable*>>::type
intrusive_ptr_release(T* ptr) {
ptr->intrusive_ptr_release_impl();
}
......
......@@ -178,7 +178,7 @@ public:
using save_callback_result = decltype(save_callback());
if (!(f->begin_object(object_type, object_name) && (fs(*f) && ...)))
return false;
if constexpr (std::is_same<save_callback_result, bool>::value) {
if constexpr (std::is_same_v<save_callback_result, bool>) {
if (!save_callback()) {
f->set_error(sec::save_callback_failed);
return false;
......
......@@ -44,7 +44,7 @@ public:
return false;
for (auto&& val : xs) {
using found_type = std::decay_t<decltype(val)>;
if constexpr (std::is_same<found_type, value_type>::value) {
if constexpr (std::is_same_v<found_type, value_type>) {
if (!detail::save(dref(), val))
return false;
} else {
......
......@@ -592,7 +592,7 @@ public:
/// and restoring `f` only if it has not been replaced by the user.
template <class F, class... Ts>
auto call_handler(F& f, Ts&&... xs) -> typename std::enable_if<
!std::is_same<decltype(f(std::forward<Ts>(xs)...)), void>::value,
!std::is_same_v<decltype(f(std::forward<Ts>(xs)...)), void>,
decltype(f(std::forward<Ts>(xs)...))>::type {
using std::swap;
F g;
......@@ -605,7 +605,7 @@ public:
template <class F, class... Ts>
auto call_handler(F& f, Ts&&... xs) -> typename std::enable_if<
std::is_same<decltype(f(std::forward<Ts>(xs)...)), void>::value>::type {
std::is_same_v<decltype(f(std::forward<Ts>(xs)...)), void>>::type {
using std::swap;
F g;
swap(f, g);
......
......@@ -90,7 +90,7 @@ void anon_send(const Dest& dest, Ts&&... xs) {
template <message_priority P = message_priority::normal, class Dest = actor,
class Rep = int, class Period = std::ratio<1>, class... Ts>
detail::enable_if_t<!std::is_same<Dest, group>::value>
detail::enable_if_t<!std::is_same_v<Dest, group>>
delayed_anon_send(const Dest& dest, std::chrono::duration<Rep, Period> rtime,
Ts&&... xs) {
static_assert(sizeof...(Ts) > 0, "no message to send");
......
......@@ -63,7 +63,7 @@ template <class To = get_or_auto_deduce, class Fallback>
auto get_or(const settings& xs, std::string_view name, Fallback&& fallback) {
if (auto ptr = get_if(&xs, name)) {
return get_or<To>(*ptr, std::forward<Fallback>(fallback));
} else if constexpr (std::is_same<To, get_or_auto_deduce>::value) {
} else if constexpr (std::is_same_v<To, get_or_auto_deduce>) {
using guide = get_or_deduction_guide<std::decay_t<Fallback>>;
return guide::convert(std::forward<Fallback>(fallback));
} else {
......
......@@ -47,7 +47,7 @@ struct is_string_like {
= decltype(sfinae(static_cast<typename std::decay<T>::type*>(nullptr)));
// Trait result.
static constexpr bool value = std::is_same<bool, result_type>::value;
static constexpr bool value = std::is_same_v<bool, result_type>;
};
} // namespace detail
......
......@@ -26,8 +26,8 @@ public:
// -- constants --------------------------------------------------------------
static constexpr metric_type runtime_type
= std::is_same<value_type, double>::value ? metric_type::dbl_counter
static constexpr metric_type runtime_type = std::is_same_v<value_type, double>
? metric_type::dbl_counter
: metric_type::int_counter;
// -- constructors, destructors, and assignment operators --------------------
......@@ -59,7 +59,7 @@ public:
/// Increments the counter by 1.
/// @returns The new value of the counter.
template <class T = ValueType>
std::enable_if_t<std::is_same<T, int64_t>::value, T> operator++() noexcept {
std::enable_if_t<std::is_same_v<T, int64_t>, T> operator++() noexcept {
return ++gauge_;
}
......
......@@ -37,8 +37,8 @@ public:
// -- constants --------------------------------------------------------------
static constexpr metric_type runtime_type
= std::is_same<value_type, double>::value ? metric_type::dbl_histogram
static constexpr metric_type runtime_type = std::is_same_v<value_type, double>
? metric_type::dbl_histogram
: metric_type::int_histogram;
// -- constructors, destructors, and assignment operators --------------------
......
......@@ -64,7 +64,7 @@ public:
std::vector<label> cpy{labels.begin(), labels.end()};
std::sort(cpy.begin(), cpy.end());
std::unique_ptr<impl_type> ptr;
if constexpr (std::is_same<extra_setting_type, unit_t>::value)
if constexpr (std::is_same_v<extra_setting_type, unit_t>)
ptr.reset(new impl_type(std::move(cpy)));
else
ptr.reset(new impl_type(std::move(cpy), config_, extra_setting_));
......
......@@ -44,7 +44,7 @@ struct same_output_or_skip_t {
using other = typename RepliesToWith::output_types;
static constexpr bool value
= std::is_same<Output, typename RepliesToWith::output_types>::value
|| std::is_same<Output, type_list<skip_t>>::value;
|| std::is_same_v<Output, type_list<skip_t>>;
};
template <class SList>
......
......@@ -82,7 +82,7 @@ public:
/// Satisfies the promise by sending an empty response message.
template <class L = detail::type_list<Ts...>>
std::enable_if_t<std::is_same<L, detail::type_list<void>>::value> deliver() {
std::enable_if_t<std::is_same_v<L, detail::type_list<void>>> deliver() {
promise_.deliver();
}
......@@ -96,7 +96,7 @@ public:
/// message.
template <class T>
std::enable_if_t<
std::is_same<detail::type_list<T>, detail::type_list<Ts...>>::value>
std::is_same_v<detail::type_list<T>, detail::type_list<Ts...>>>
deliver(expected<T> x) {
promise_.deliver(std::move(x));
}
......
......@@ -52,7 +52,7 @@ public:
template <class ExitMsgType>
behavior tester(event_based_actor* self, const actor& aut) {
if (std::is_same<ExitMsgType, exit_msg>::value) {
if (std::is_same_v<ExitMsgType, exit_msg>) {
self->set_exit_handler([self](exit_msg& msg) {
// must be still alive at this point
CHECK_EQ(s_testees.load(), 1);
......
......@@ -636,7 +636,7 @@ SCENARIO("get_or converts or returns a fallback value") {
auto fallback = make_span(fallback_arr);
THEN("CAF returns the default value after converting it to vector<int>") {
auto result = get_or(x, fallback);
static_assert(std::is_same<decltype(result), std::vector<int>>::value);
static_assert(std::is_same_v<decltype(result), std::vector<int>>);
CHECK_EQ(result, std::vector<int>({10, 20, 30}));
}
}
......@@ -738,7 +738,7 @@ SCENARIO("config values can default-construct all registered types") {
auto parsed = config_value::parse(str); \
using init_val_type = decltype(init_val); \
if (CHECK(parsed)) { \
if constexpr (!std::is_same<init_val_type, message>::value) \
if constexpr (!std::is_same_v<init_val_type, message>) \
CHECK_EQ(get_as<init_val_type>(*parsed), init_val); \
else \
CHECK_EQ(to_string(*parsed), str); \
......
......@@ -25,7 +25,7 @@ struct fixture {
auto res = CHECK(reader.load(input)) // parse JSON
&& CHECK(reader.apply(tmp)); // deserialize object
if (res) {
if constexpr (std::is_same<T, message>::value)
if constexpr (std::is_same_v<T, message>)
res = CHECK_EQ(to_string(tmp), to_string(obj));
else
res = CHECK_EQ(tmp, obj);
......
......@@ -72,7 +72,7 @@ std::ostream& operator<<(std::ostream& out, token<T>) {
template <class T, class U>
constexpr bool operator==(token<T>, token<U>) {
return std::is_same<T, U>::value;
return std::is_same_v<T, U>;
}
template <class T>
......
......@@ -21,5 +21,5 @@ CAF_TEST(make_typed_behavior automatically deduces its types) {
auto bhvr = make_typed_behavior([](const std::string&) {},
[](int32_t x) { return x; },
[](double x) { return x; });
static_assert(std::is_same<handle::behavior_type, decltype(bhvr)>::value);
static_assert(std::is_same_v<handle::behavior_type, decltype(bhvr)>);
}
......@@ -84,10 +84,9 @@ protected:
// tell broker it entered passive mode, this can result in
// producing, why we check the condition again afterwards
using passive_t = typename std::conditional<
std::is_same<handle_type, connection_handle>::value,
std::is_same_v<handle_type, connection_handle>,
connection_passivated_msg,
typename std::conditional<
std::is_same<handle_type, accept_handle>::value,
typename std::conditional<std::is_same_v<handle_type, accept_handle>,
acceptor_passivated_msg,
datagram_servant_passivated_msg>::type>::type;
mailbox_element tmp{strong_actor_ptr{}, make_message_id(),
......
......@@ -29,7 +29,7 @@ constexpr bool operator==(const wildcard&, const wildcard&) {
template <size_t I, class T>
bool cmp_one(const caf::message& x, const T& y) {
if (std::is_same<T, wildcard>::value)
if (std::is_same_v<T, wildcard>)
return true;
return x.match_element<T>(I) && x.get_as<T>(I) == y;
}
......@@ -74,7 +74,7 @@ struct has_outer_type {
static auto sfinae(...) -> std::false_type;
using type = decltype(sfinae<T>(nullptr));
static constexpr bool value = !std::is_same<type, std::false_type>::value;
static constexpr bool value = !std::is_same_v<type, std::false_type>;
};
// enables ADL in `with_content`
......
......@@ -294,9 +294,9 @@ public:
}
};
using fwd =
typename std::conditional<std::is_same<char, T>::value
typename std::conditional<std::is_same_v<char, T>
|| std::is_convertible<T, std::string>::value
|| std::is_same<caf::term, T>::value,
|| std::is_same_v<caf::term, T>,
simple_fwd_t, deep_to_string_t>::type;
fwd f;
auto y = f(x);
......
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