diff --git a/include/yaml-cpp/node/detail/node_data.h b/include/yaml-cpp/node/detail/node_data.h index 07cf81a..18810a1 100644 --- a/include/yaml-cpp/node/detail/node_data.h +++ b/include/yaml-cpp/node/detail/node_data.h @@ -81,7 +81,7 @@ class YAML_CPP_API node_data { shared_memory_holder pMemory); public: - static const std::string& empty_scalar(); + static std::string empty_scalar; private: void compute_seq_size() const; diff --git a/include/yaml-cpp/node/impl.h b/include/yaml-cpp/node/impl.h index 312281f..3a97b0c 100644 --- a/include/yaml-cpp/node/impl.h +++ b/include/yaml-cpp/node/impl.h @@ -166,13 +166,13 @@ inline T Node::as(const S& fallback) const { inline const std::string& Node::Scalar() const { if (!m_isValid) throw InvalidNode(m_invalidKey); - return m_pNode ? m_pNode->scalar() : detail::node_data::empty_scalar(); + return m_pNode ? m_pNode->scalar() : detail::node_data::empty_scalar; } inline const std::string& Node::Tag() const { if (!m_isValid) throw InvalidNode(m_invalidKey); - return m_pNode ? m_pNode->tag() : detail::node_data::empty_scalar(); + return m_pNode ? m_pNode->tag() : detail::node_data::empty_scalar; } inline void Node::SetTag(const std::string& tag) { diff --git a/src/node_data.cpp b/src/node_data.cpp index 8f5422a..a88c879 100644 --- a/src/node_data.cpp +++ b/src/node_data.cpp @@ -15,10 +15,8 @@ namespace YAML { namespace detail { YAML_CPP_API std::atomic node::m_amount{0}; -const std::string& node_data::empty_scalar() { - static const std::string svalue; - return svalue; -} +std::string node_data::empty_scalar; + node_data::node_data() : m_isDefined(false),