Skip to content

Commit

Permalink
Add check nodes exist
Browse files Browse the repository at this point in the history
  • Loading branch information
fantasy-peak committed Apr 29, 2024
1 parent 9724ab3 commit 23a9a32
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions include/yaml_cpp_struct.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ struct convert<std::variant<T...>> {
using ToType = std::remove_reference_t<std::decay_t<decltype(value)>>; \
if constexpr (yaml_cpp_struct::is_optional<ToType>()) { \
try { \
value = yaml_cpp_struct::node_as<ToType>(node[name]); \
if (node[name]) \
value = yaml_cpp_struct::node_as<ToType>(node[name]); \
} catch (const std::runtime_error&) { \
} \
} \
Expand Down Expand Up @@ -339,7 +340,8 @@ struct convert<std::variant<T...>> {
visit_struct::for_each(rhs, [&](const char* name, auto& value) { \
using ToType = std::remove_reference_t<std::decay_t<decltype(value)>>; \
try { \
value = yaml_cpp_struct::node_as<ToType>(node[name]); \
if (node[name]) \
value = yaml_cpp_struct::node_as<ToType>(node[name]); \
} catch (const std::runtime_error&) { \
} \
}); \
Expand Down

0 comments on commit 23a9a32

Please sign in to comment.