From ed7b46b2df7049cb9493b7019763fd664ac2cde4 Mon Sep 17 00:00:00 2001 From: beda Date: Thu, 28 Mar 2019 10:14:04 +0100 Subject: [PATCH] Warnings, better return in stream_to_string --- include/yaml-cpp/node/impl.h | 14 +++++++++----- include/yaml-cpp/traits.h | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/yaml-cpp/node/impl.h b/include/yaml-cpp/node/impl.h index 61e925e..0b0e296 100644 --- a/include/yaml-cpp/node/impl.h +++ b/include/yaml-cpp/node/impl.h @@ -16,10 +16,12 @@ #include namespace YAML { -inline Node::Node() : m_isValid(true), m_pMemory(nullptr), m_pNode(nullptr) {} +inline Node::Node() + : m_isValid(true), m_invalidKey{}, m_pMemory(nullptr), m_pNode(nullptr) {} inline Node::Node(NodeType::value type) : m_isValid(true), + m_invalidKey{}, m_pMemory(new detail::memory_holder), m_pNode(&m_pMemory->create_node()) { m_pNode->set_type(type); @@ -28,6 +30,7 @@ inline Node::Node(NodeType::value type) template inline Node::Node(const T& rhs) : m_isValid(true), + m_invalidKey{}, m_pMemory(new detail::memory_holder), m_pNode(&m_pMemory->create_node()) { Assign(rhs); @@ -45,13 +48,14 @@ inline Node::Node(const Node& rhs) m_pMemory(rhs.m_pMemory), m_pNode(rhs.m_pNode) {} -inline Node::Node(Zombie) : m_isValid(false), m_pMemory{}, m_pNode(nullptr) {} +inline Node::Node(Zombie) + : m_isValid(false), m_invalidKey{}, m_pMemory{}, m_pNode(nullptr) {} inline Node::Node(Zombie, const std::string& key) - : m_isValid(false), m_invalidKey(key), m_pNode(NULL) {} + : m_isValid(false), m_invalidKey(key), m_pMemory{}, m_pNode(NULL) {} inline Node::Node(detail::node& node, detail::shared_memory_holder pMemory) - : m_isValid(true), m_pMemory(pMemory), m_pNode(&node) {} + : m_isValid(true), m_invalidKey{}, m_pMemory(pMemory), m_pNode(&node) {} inline Node::~Node() {} @@ -210,7 +214,7 @@ inline Node& Node::operator=(const T& rhs) { inline Node& Node::operator=(const Node& rhs) { if (!m_isValid || !rhs.m_isValid) - throw InvalidNode(); + throw InvalidNode(m_invalidKey); if (is(rhs)) return *this; AssignNode(rhs); diff --git a/include/yaml-cpp/traits.h b/include/yaml-cpp/traits.h index f3cda64..36d406b 100644 --- a/include/yaml-cpp/traits.h +++ b/include/yaml-cpp/traits.h @@ -129,7 +129,7 @@ struct streamable_to_string { template struct streamable_to_string { static std::string impl(const Key&) { - return std::string(); + return ""; } }; #endif // TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66