Commit 24ca2859 authored by Samir Halilcevic's avatar Samir Halilcevic

Fix fallback when inspecting optional types

parent de03ad86
...@@ -396,7 +396,10 @@ struct optional_inspector_access { ...@@ -396,7 +396,10 @@ struct optional_inspector_access {
template <class Inspector, class IsPresent, class Get> template <class Inspector, class IsPresent, class Get>
static bool save_field(Inspector& f, std::string_view field_name, static bool save_field(Inspector& f, std::string_view field_name,
IsPresent& is_present, Get& get) { IsPresent& is_present, Get& get) {
return detail::save_field(f, field_name, is_present, get); auto deref_get = [&get]() -> decltype(auto) {
return traits::deref_save(get());
};
return detail::save_field(f, field_name, is_present, deref_get);
} }
template <class Inspector, class IsValid, class SyncValue> template <class Inspector, class IsValid, class SyncValue>
......
...@@ -75,7 +75,7 @@ public: ...@@ -75,7 +75,7 @@ public:
template <class Inspector> template <class Inspector>
bool operator()(Inspector& f) { bool operator()(Inspector& f) {
auto is_present = [this] { return *val != fallback; }; auto is_present = [this] { return *val != fallback; };
auto get = [this] { return *val; }; auto get = [this]() -> decltype(auto) { return *val; };
return detail::save_field(f, field_name, is_present, get); return detail::save_field(f, field_name, is_present, get);
} }
......
...@@ -808,6 +808,7 @@ end object)_"; ...@@ -808,6 +808,7 @@ end object)_";
} }
} }
} }
TEST_CASE("GH-1427 regression") { TEST_CASE("GH-1427 regression") {
struct opt_test { struct opt_test {
std::optional<int> val; std::optional<int> val;
......
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