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