Commit 03c6347a authored by Dominik Charousset's avatar Dominik Charousset

Fix warnings on GCC 13

parent 1d0bed3a
......@@ -167,12 +167,12 @@ type_id_t config_value::type_id() const noexcept {
error_code<sec> config_value::default_construct(type_id_t id) {
switch (id) {
case type_id_v<bool>:
set(false);
data_ = false;
return sec::none;
case type_id_v<double>:
case type_id_v<float>:
case type_id_v<long double>:
set(0.0);
data_ = 0.0;
return sec::none;
case type_id_v<int16_t>:
case type_id_v<int32_t>:
......@@ -182,16 +182,16 @@ error_code<sec> config_value::default_construct(type_id_t id) {
case type_id_v<uint32_t>:
case type_id_v<uint64_t>:
case type_id_v<uint8_t>:
set(0);
data_ = int64_t{0};
return sec::none;
case type_id_v<std::string>:
set(std::string{});
data_ = std::string{};
return sec::none;
case type_id_v<timespan>:
set(timespan{});
data_ = timespan{};
return sec::none;
case type_id_v<uri>:
set(uri{});
data_ = uri{};
return sec::none;
default:
if (auto meta = detail::global_meta_object_or_null(id)) {
......
......@@ -99,8 +99,8 @@ public:
template <class T, class E = detail::enable_if_t<
!std::is_same_v<detail::decay_t<T>, config_value>>>
explicit config_value(T&& x) {
set(std::forward<T>(x));
explicit config_value(T&& x) : data_(lift(std::forward<T>(x))) {
// nop
}
config_value& operator=(config_value&& other) = default;
......@@ -110,7 +110,7 @@ public:
template <class T, class E = detail::enable_if_t<
!std::is_same_v<detail::decay_t<T>, config_value>>>
config_value& operator=(T&& x) {
set(std::forward<T>(x));
data_ = lift(std::forward<T>(x));
return *this;
}
......@@ -271,47 +271,33 @@ private:
// -- auto conversion of related types ---------------------------------------
template <class T>
void set_range(T& xs, std::true_type) {
auto& dict = as_dictionary();
dict.clear();
for (auto& [key, val] : xs)
dict.emplace(key, std::move(val));
}
template <class T>
void set_range(T& xs, std::false_type) {
auto& ls = as_list();
ls.clear();
ls.insert(ls.end(), std::make_move_iterator(xs.begin()),
std::make_move_iterator(xs.end()));
}
template <class T>
void set(T x) {
auto lift(T x) {
if constexpr (detail::is_config_value_type_v<T>) {
data_ = std::move(x);
return x;
} else if constexpr (std::is_integral<T>::value) {
data_ = static_cast<int64_t>(x);
} else if constexpr (std::is_convertible<T, const char*>::value) {
data_ = std::string{x};
return static_cast<int64_t>(x);
} else if constexpr (std::is_same<T, float>::value) {
return static_cast<double>(x);
} else if constexpr (std::is_convertible_v<T, const char*>) {
return std::string{x};
} else if constexpr (std::is_same_v<T, std::string_view>) {
return std::string{x};
} else {
static_assert(detail::is_iterable<T>::value);
static_assert(detail::is_iterable_v<T>);
using value_type = typename T::value_type;
detail::bool_token<detail::is_pair<value_type>::value> is_map_type;
set_range(x, is_map_type);
}
if constexpr (detail::is_pair<value_type>::value) {
dictionary result;
for (auto& [key, val] : x)
result.emplace(std::move(key), std::move(val));
return result;
} else {
list result;
result.reserve(x.size());
for (auto& val : x)
result.emplace_back(std::move(val));
return result;
}
void set(float x) {
data_ = static_cast<double>(x);
}
void set(const char* x) {
data_ = std::string{x};
}
void set(std::string_view x) {
data_ = std::string{x.begin(), x.end()};
}
// -- member variables -------------------------------------------------------
......
......@@ -140,7 +140,7 @@ public:
template <class T>
void value(T&& x) {
result = config_value{std::forward<T>(x)};
result = std::forward<T>(x);
}
config_list_consumer begin_list();
......
......@@ -28,7 +28,7 @@ public:
take_last& operator=(const take_last&) = default;
template <class Next, class... Steps>
bool on_next(const input_type& item, Next& next, Steps&... steps) {
bool on_next(const input_type& item, Next&, Steps&...) {
elements_.push_back(item);
return true;
}
......
......@@ -229,14 +229,14 @@ public:
/// Adds a predicate for the sender of the next message that matches only if
/// the sender is `src`.
evaluator&& from(const strong_actor_ptr& src) && {
from_ = value_predicate<strong_actor_ptr>{std::move(src)};
from_ = value_predicate<strong_actor_ptr>{src};
return std::move(*this);
}
/// Adds a predicate for the sender of the next message that matches only if
/// the sender is `src`.
evaluator&& from(const actor& src) && {
from_ = value_predicate<strong_actor_ptr>{std::move(src)};
from_ = value_predicate<strong_actor_ptr>{src};
return std::move(*this);
}
......@@ -244,7 +244,7 @@ public:
/// the sender is `src`.
template <class... Us>
evaluator&& from(const typed_actor<Us...>& src) && {
from_ = value_predicate<strong_actor_ptr>{std::move(src)};
from_ = value_predicate<strong_actor_ptr>{src};
return std::move(*this);
}
......
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