Commit c7dee447 authored by Dominik Charousset's avatar Dominik Charousset

Fix conversion warnings

parent 12c8a83b
...@@ -227,7 +227,7 @@ public: ...@@ -227,7 +227,7 @@ public:
lhs.resize((rhs.size() - 1) / 8 + 1, 0); lhs.resize((rhs.size() - 1) / 8 + 1, 0);
for (bool b: rhs) { for (bool b: rhs) {
if (b) if (b)
lhs[k / 8] |= (1 << (k % 8)); lhs[k / 8] |= static_cast<uint8_t>(1 << (k % 8));
++k; ++k;
} }
} }
......
...@@ -37,12 +37,12 @@ bool add_ascii(T& x, char c, enable_if_tt<std::is_integral<T>, int> u = 0) { ...@@ -37,12 +37,12 @@ bool add_ascii(T& x, char c, enable_if_tt<std::is_integral<T>, int> u = 0) {
CAF_IGNORE_UNUSED(u); CAF_IGNORE_UNUSED(u);
if (x > (std::numeric_limits<T>::max() / Base)) if (x > (std::numeric_limits<T>::max() / Base))
return false; return false;
x *= Base; x *= static_cast<T>(Base);
ascii_to_int<Base, T> f; ascii_to_int<Base, T> f;
auto y = f(c); auto y = f(c);
if (x > (std::numeric_limits<T>::max() - y)) if (x > (std::numeric_limits<T>::max() - y))
return false; return false;
x += y; x += static_cast<T>(y);
return true; return true;
} }
...@@ -58,4 +58,3 @@ bool add_ascii(T& x, char c, ...@@ -58,4 +58,3 @@ bool add_ascii(T& x, char c,
} // namespace parser } // namespace parser
} // namespace detail } // namespace detail
} // namespace caf } // namespace caf
...@@ -37,12 +37,12 @@ bool sub_ascii(T& x, char c, enable_if_tt<std::is_integral<T>, int> u = 0) { ...@@ -37,12 +37,12 @@ bool sub_ascii(T& x, char c, enable_if_tt<std::is_integral<T>, int> u = 0) {
CAF_IGNORE_UNUSED(u); CAF_IGNORE_UNUSED(u);
if (x < (std::numeric_limits<T>::min() / Base)) if (x < (std::numeric_limits<T>::min() / Base))
return false; return false;
x *= Base; x *= static_cast<T>(Base);
ascii_to_int<Base, T> f; ascii_to_int<Base, T> f;
auto y = f(c); auto y = f(c);
if (x < (std::numeric_limits<T>::min() + y)) if (x < (std::numeric_limits<T>::min() + y))
return false; return false;
x -= y; x -= static_cast<T>(y);
return true; return true;
} }
...@@ -51,12 +51,10 @@ bool sub_ascii(T& x, char c, ...@@ -51,12 +51,10 @@ bool sub_ascii(T& x, char c,
enable_if_tt<std::is_floating_point<T>, int> u = 0) { enable_if_tt<std::is_floating_point<T>, int> u = 0) {
CAF_IGNORE_UNUSED(u); CAF_IGNORE_UNUSED(u);
ascii_to_int<Base, T> f; ascii_to_int<Base, T> f;
x = (x * Base) - f(c); x = static_cast<T>((x * Base) - f(c));
return true; return true;
} }
} // namespace parser } // namespace parser
} // namespace detail } // namespace detail
} // namespace caf } // namespace caf
...@@ -20,9 +20,9 @@ ...@@ -20,9 +20,9 @@
#include "caf/behavior.hpp" #include "caf/behavior.hpp"
#include "caf/deduce_mpi.hpp" #include "caf/deduce_mpi.hpp"
#include "caf/interface_mismatch.hpp"
#include "caf/message_handler.hpp" #include "caf/message_handler.hpp"
#include "caf/system_messages.hpp" #include "caf/system_messages.hpp"
#include "caf/interface_mismatch.hpp"
#include "caf/detail/typed_actor_util.hpp" #include "caf/detail/typed_actor_util.hpp"
...@@ -48,9 +48,11 @@ struct same_input : std::is_same<Input, typename RepliesToWith::input_types> {}; ...@@ -48,9 +48,11 @@ struct same_input : std::is_same<Input, typename RepliesToWith::input_types> {};
template <class Output, class RepliesToWith> template <class Output, class RepliesToWith>
struct same_output_or_skip_t { struct same_output_or_skip_t {
using other = typename RepliesToWith::output_types; using other = typename RepliesToWith::output_types;
static constexpr bool value = static constexpr bool value = std::is_same<
std::is_same<Output, typename RepliesToWith::output_types>::value || Output,
std::is_same<Output, type_list<skip_t>>::value; typename RepliesToWith::output_types>::value
|| std::is_same<Output,
type_list<skip_t>>::value;
}; };
template <class SList> template <class SList>
...@@ -60,35 +62,31 @@ struct valid_input_predicate { ...@@ -60,35 +62,31 @@ struct valid_input_predicate {
using input_types = typename Expr::input_types; using input_types = typename Expr::input_types;
using output_types = typename Expr::output_types; using output_types = typename Expr::output_types;
// get matching elements for input type // get matching elements for input type
using filtered_slist = using filtered_slist = typename tl_filter<
typename tl_filter< SList, tbind<same_input, input_types>::template type>::type;
SList,
tbind<same_input, input_types>::template type
>::type;
static_assert(tl_size<filtered_slist>::value > 0, static_assert(tl_size<filtered_slist>::value > 0,
"cannot assign given match expression to " "cannot assign given match expression to "
"typed behavior, because the expression " "typed behavior, because the expression "
"contains at least one pattern that is " "contains at least one pattern that is "
"not defined in the actor's type"); "not defined in the actor's type");
static constexpr bool value = tl_exists< static constexpr bool value = tl_exists<
filtered_slist, tbind<same_output_or_skip_t, filtered_slist,
output_types>::template type>::value; tbind<same_output_or_skip_t, output_types>::template type>::value;
// check whether given output matches in the filtered list // check whether given output matches in the filtered list
static_assert(value, static_assert(value, "cannot assign given match expression to "
"cannot assign given match expression to "
"typed behavior, because at least one return " "typed behavior, because at least one return "
"type does not match"); "type does not match");
}; };
}; };
template <class T> template <class T>
struct is_system_msg_handler : std::false_type { }; struct is_system_msg_handler : std::false_type {};
template <> template <>
struct is_system_msg_handler<reacts_to<exit_msg>> : std::true_type { }; struct is_system_msg_handler<reacts_to<exit_msg>> : std::true_type {};
template <> template <>
struct is_system_msg_handler<reacts_to<down_msg>> : std::true_type { }; struct is_system_msg_handler<reacts_to<down_msg>> : std::true_type {};
// Tests whether the input list (IList) matches the // Tests whether the input list (IList) matches the
// signature list (SList) for a typed actor behavior // signature list (SList) for a typed actor behavior
...@@ -96,28 +94,22 @@ template <class SList, class IList> ...@@ -96,28 +94,22 @@ template <class SList, class IList>
struct valid_input { struct valid_input {
// strip exit_msg and down_msg from input types, // strip exit_msg and down_msg from input types,
// because they're always allowed // because they're always allowed
using adjusted_slist = using adjusted_slist = typename tl_filter_not<SList,
typename tl_filter_not< is_system_msg_handler>::type;
SList, using adjusted_ilist = typename tl_filter_not<IList,
is_system_msg_handler is_system_msg_handler>::type;
>::type;
using adjusted_ilist =
typename tl_filter_not<
IList,
is_system_msg_handler
>::type;
// check for each element in IList that there's an element in SList that // check for each element in IList that there's an element in SList that
// (1) has an identical input type list // (1) has an identical input type list
// (2) has an identical output type list // (2) has an identical output type list
// OR the output of the element in IList is skip_t // OR the output of the element in IList is skip_t
static_assert(detail::tl_is_distinct<IList>::value, static_assert(detail::tl_is_distinct<IList>::value,
"given pattern is not distinct"); "given pattern is not distinct");
static constexpr bool value = static constexpr bool value = tl_size<adjusted_slist>::value
tl_size<adjusted_slist>::value == tl_size<adjusted_ilist>::value == tl_size<adjusted_ilist>::value
&& tl_forall< && tl_forall<
adjusted_ilist, adjusted_ilist,
valid_input_predicate<adjusted_slist>::template inner valid_input_predicate<
>::value; adjusted_slist>::template inner>::value;
}; };
// this function is called from typed_behavior<...>::set and its whole // this function is called from typed_behavior<...>::set and its whole
...@@ -130,8 +122,7 @@ void static_check_typed_behavior_input() { ...@@ -130,8 +122,7 @@ void static_check_typed_behavior_input() {
// InputList if its return type is identical to all "missing" // InputList if its return type is identical to all "missing"
// input types ... however, it might lead to unexpected results // input types ... however, it might lead to unexpected results
// and would cause a lot of not-so-straightforward code here // and would cause a lot of not-so-straightforward code here
static_assert(is_valid, static_assert(is_valid, "given pattern cannot be used to initialize "
"given pattern cannot be used to initialize "
"typed behavior (exact match needed)"); "typed behavior (exact match needed)");
} }
...@@ -165,7 +156,7 @@ public: ...@@ -165,7 +156,7 @@ public:
using signatures = detail::type_list<Sigs...>; using signatures = detail::type_list<Sigs...>;
/// Empty struct tag for constructing from an untyped behavior. /// Empty struct tag for constructing from an untyped behavior.
struct unsafe_init { }; struct unsafe_init {};
// -- constructors, destructors, and assignment operators -------------------- // -- constructors, destructors, and assignment operators --------------------
...@@ -179,8 +170,9 @@ public: ...@@ -179,8 +170,9 @@ public:
using other_signatures = detail::type_list<Ts...>; using other_signatures = detail::type_list<Ts...>;
using m = interface_mismatch_t<other_signatures, signatures>; using m = interface_mismatch_t<other_signatures, signatures>;
// trigger static assert on mismatch // trigger static assert on mismatch
detail::static_error_printer<sizeof...(Ts), m::value, detail::static_error_printer<static_cast<int>(sizeof...(Ts)), m::value,
typename m::xs, typename m::ys> guard; typename m::xs, typename m::ys>
guard;
CAF_IGNORE_UNUSED(guard); CAF_IGNORE_UNUSED(guard);
} }
...@@ -200,7 +192,7 @@ public: ...@@ -200,7 +192,7 @@ public:
// -- modifiers -------------------------------------------------------------- // -- modifiers --------------------------------------------------------------
/// Exchanges the contents of this and other. /// Exchanges the contents of this and other.
inline void swap(typed_behavior& other) { void swap(typed_behavior& other) {
bhvr_.swap(other.bhvr_); bhvr_.swap(other.bhvr_);
} }
...@@ -242,8 +234,9 @@ private: ...@@ -242,8 +234,9 @@ private:
using found_signatures = detail::type_list<deduce_mpi_t<Ts>...>; using found_signatures = detail::type_list<deduce_mpi_t<Ts>...>;
using m = interface_mismatch_t<found_signatures, signatures>; using m = interface_mismatch_t<found_signatures, signatures>;
// trigger static assert on mismatch // trigger static assert on mismatch
detail::static_error_printer<sizeof...(Ts), m::value, detail::static_error_printer<static_cast<int>(sizeof...(Ts)), m::value,
typename m::xs, typename m::ys> guard; typename m::xs, typename m::ys>
guard;
CAF_IGNORE_UNUSED(guard); CAF_IGNORE_UNUSED(guard);
// final (type-erasure) step // final (type-erasure) step
intrusive_ptr<detail::behavior_impl> ptr = std::move(bp); intrusive_ptr<detail::behavior_impl> ptr = std::move(bp);
...@@ -254,10 +247,9 @@ private: ...@@ -254,10 +247,9 @@ private:
}; };
template <class T> template <class T>
struct is_typed_behavior : std::false_type { }; struct is_typed_behavior : std::false_type {};
template <class... Sigs> template <class... Sigs>
struct is_typed_behavior<typed_behavior<Sigs...>> : std::true_type { }; struct is_typed_behavior<typed_behavior<Sigs...>> : std::true_type {};
} // namespace caf } // namespace caf
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