Commit ee5ce710 authored by Dominik Charousset's avatar Dominik Charousset

Fix build on Clang 7/8

parent 5d25fbf1
...@@ -411,7 +411,7 @@ template <class... Ts> ...@@ -411,7 +411,7 @@ template <class... Ts>
struct inspector_access<variant<Ts...>> { struct inspector_access<variant<Ts...>> {
using value_type = variant<Ts...>; using value_type = variant<Ts...>;
static constexpr type_id_t allowed_types[] = {type_id_v<Ts>...}; static constexpr type_id_t allowed_types_arr[] = {type_id_v<Ts>...};
template <class Inspector> template <class Inspector>
[[nodiscard]] static bool apply_object(Inspector& f, value_type& x) { [[nodiscard]] static bool apply_object(Inspector& f, value_type& x) {
...@@ -428,23 +428,23 @@ struct inspector_access<variant<Ts...>> { ...@@ -428,23 +428,23 @@ struct inspector_access<variant<Ts...>> {
template <class Inspector> template <class Inspector>
static bool save_field(Inspector& f, string_view field_name, value_type& x) { static bool save_field(Inspector& f, string_view field_name, value_type& x) {
auto g = [&f](auto& y) { return inspect_value(f, y); }; auto g = [&f](auto& y) { return inspect_value(f, y); };
return f.begin_field(field_name, make_span(allowed_types), x.index()) // return f.begin_field(field_name, make_span(allowed_types_arr), x.index()) //
&& visit(g, x) // && visit(g, x) //
&& f.end_field(); && f.end_field();
} }
template <class Inspector, class IsPresent, class Get> template <class Inspector, class IsPresent, class Get>
static bool save_field(Inspector& f, string_view field_name, static bool save_field(Inspector& f, string_view field_name,
IsPresent& is_present, Get& get) { IsPresent& is_present, Get& get) {
auto allowed_types = make_span(allowed_types_arr);
if (is_present()) { if (is_present()) {
auto&& x = get(); auto&& x = get();
auto g = [&f](auto& y) { return inspect_value(f, y); }; auto g = [&f](auto& y) { return inspect_value(f, y); };
return f.begin_field(field_name, true, make_span(allowed_types), return f.begin_field(field_name, true, allowed_types, x.index()) //
x.index()) // && visit(g, x) //
&& visit(g, x) //
&& f.end_field(); && f.end_field();
} }
return f.begin_field(field_name, false, make_span(allowed_types), 0) // return f.begin_field(field_name, false, allowed_types, 0) //
&& f.end_field(); && f.end_field();
} }
...@@ -473,9 +473,10 @@ struct inspector_access<variant<Ts...>> { ...@@ -473,9 +473,10 @@ struct inspector_access<variant<Ts...>> {
static bool load_field(Inspector& f, string_view field_name, value_type& x, static bool load_field(Inspector& f, string_view field_name, value_type& x,
IsValid& is_valid, SyncValue& sync_value) { IsValid& is_valid, SyncValue& sync_value) {
size_t type_index = std::numeric_limits<size_t>::max(); size_t type_index = std::numeric_limits<size_t>::max();
if (!f.begin_field(field_name, make_span(allowed_types), type_index)) auto allowed_types = make_span(allowed_types_arr);
if (!f.begin_field(field_name, allowed_types, type_index))
return false; return false;
if (type_index >= std::size(allowed_types)) if (type_index >= allowed_types.size())
return f.load_field_failed(field_name, sec::invalid_field_type); return f.load_field_failed(field_name, sec::invalid_field_type);
auto runtime_type = allowed_types[type_index]; auto runtime_type = allowed_types[type_index];
detail::type_list<Ts...> types; detail::type_list<Ts...> types;
...@@ -494,12 +495,12 @@ struct inspector_access<variant<Ts...>> { ...@@ -494,12 +495,12 @@ struct inspector_access<variant<Ts...>> {
IsValid& is_valid, SyncValue& sync_value, IsValid& is_valid, SyncValue& sync_value,
SetFallback& set_fallback) { SetFallback& set_fallback) {
bool is_present = false; bool is_present = false;
auto allowed_types = make_span(allowed_types_arr);
size_t type_index = std::numeric_limits<size_t>::max(); size_t type_index = std::numeric_limits<size_t>::max();
if (!f.begin_field(field_name, is_present, make_span(allowed_types), if (!f.begin_field(field_name, is_present, allowed_types, type_index))
type_index))
return false; return false;
if (is_present) { if (is_present) {
if (type_index >= std::size(allowed_types)) if (type_index >= allowed_types.size())
return f.load_field_failed(field_name, sec::invalid_field_type); return f.load_field_failed(field_name, sec::invalid_field_type);
auto runtime_type = allowed_types[type_index]; auto runtime_type = allowed_types[type_index];
detail::type_list<Ts...> types; detail::type_list<Ts...> types;
......
...@@ -21,7 +21,7 @@ std::string to_string(weekday x) { ...@@ -21,7 +21,7 @@ std::string to_string(weekday x) {
} }
} }
bool parse(std::string_view input, weekday& dest) { bool parse(caf::string_view input, weekday& dest) {
if (input == "monday") { if (input == "monday") {
dest = weekday::monday; dest = weekday::monday;
return true; return true;
......
...@@ -21,7 +21,7 @@ enum class weekday { ...@@ -21,7 +21,7 @@ enum class weekday {
std::string to_string(weekday x); std::string to_string(weekday x);
bool parse(std::string_view input, weekday& dest); bool parse(caf::string_view input, weekday& dest);
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