From 983a0a6bbb50b54964ee1ea39050cc5a0481e974 Mon Sep 17 00:00:00 2001 From: Vincent Cogne Date: Thu, 9 Jun 2016 16:06:49 +0200 Subject: [PATCH] Improve condition --- include/yaml-cpp/node/convert.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/include/yaml-cpp/node/convert.h b/include/yaml-cpp/node/convert.h index e3547dd..f232de7 100644 --- a/include/yaml-cpp/node/convert.h +++ b/include/yaml-cpp/node/convert.h @@ -254,10 +254,9 @@ struct convert> { } static bool decode(const Node& node, std::array& rhs) { - if (!node.IsSequence()) + if (!isNodeValid(node)) { return false; - if (node.size() != N) - return false; + } for (auto i = 0u; i < node.size(); ++i) { #if defined(__GNUC__) && __GNUC__ < 4 @@ -269,6 +268,12 @@ struct convert> { } return true; } + +private: + + static bool isNodeValid(const Node& node) { + return node.IsSequence() && node.size() == N; + } }; // std::pair