diff --git a/include/yaml-cpp/node/convert.h b/include/yaml-cpp/node/convert.h index 34ca898..b2f46f0 100644 --- a/include/yaml-cpp/node/convert.h +++ b/include/yaml-cpp/node/convert.h @@ -74,12 +74,17 @@ struct convert { // C-strings can only be encoded template <> struct convert { - static Node encode(const char*& rhs) { return Node(rhs); } + static Node encode(const char* rhs) { return Node(rhs); } +}; + +template <> +struct convert { + static Node encode(const char* rhs) { return Node(rhs); } }; template -struct convert { - static Node encode(const char(&rhs)[N]) { return Node(rhs); } +struct convert { + static Node encode(const char* rhs) { return Node(rhs); } }; template <> diff --git a/include/yaml-cpp/node/impl.h b/include/yaml-cpp/node/impl.h index 7065404..97dc282 100644 --- a/include/yaml-cpp/node/impl.h +++ b/include/yaml-cpp/node/impl.h @@ -315,51 +315,6 @@ inline void Node::push_back(const Node& rhs) { m_pMemory->merge(*rhs.m_pMemory); } -// helpers for indexing -namespace detail { -template -struct to_value_t { - explicit to_value_t(const T& t_) : t(t_) {} - const T& t; - using return_type = const T &; - - const T& operator()() const { return t; } -}; - -template <> -struct to_value_t { - explicit to_value_t(const char* t_) : t(t_) {} - const char* t; - using return_type = std::string; - - const std::string operator()() const { return t; } -}; - -template <> -struct to_value_t { - explicit to_value_t(char* t_) : t(t_) {} - const char* t; - using return_type = std::string; - - const std::string operator()() const { return t; } -}; - -template -struct to_value_t { - explicit to_value_t(const char* t_) : t(t_) {} - const char* t; - using return_type = std::string; - - const std::string operator()() const { return t; } -}; - -// converts C-strings to std::strings so they can be copied -template -inline typename to_value_t::return_type to_value(const T& t) { - return to_value_t(t)(); -} -} // namespace detail - template std::string key_to_string(const Key& key) { return streamable_to_string::value>().impl(key); @@ -369,8 +324,8 @@ std::string key_to_string(const Key& key) { template inline const Node Node::operator[](const Key& key) const { EnsureNodeExists(); - detail::node* value = static_cast(*m_pNode).get( - detail::to_value(key), m_pMemory); + detail::node* value = + static_cast(*m_pNode).get(key, m_pMemory); if (!value) { return Node(ZombieNode, key_to_string(key)); } @@ -380,14 +335,14 @@ inline const Node Node::operator[](const Key& key) const { template inline Node Node::operator[](const Key& key) { EnsureNodeExists(); - detail::node& value = m_pNode->get(detail::to_value(key), m_pMemory); + detail::node& value = m_pNode->get(key, m_pMemory); return Node(value, m_pMemory); } template inline bool Node::remove(const Key& key) { EnsureNodeExists(); - return m_pNode->remove(detail::to_value(key), m_pMemory); + return m_pNode->remove(key, m_pMemory); } inline const Node Node::operator[](const Node& key) const { @@ -420,8 +375,7 @@ inline bool Node::remove(const Node& key) { template inline void Node::force_insert(const Key& key, const Value& value) { EnsureNodeExists(); - m_pNode->force_insert(detail::to_value(key), detail::to_value(value), - m_pMemory); + m_pNode->force_insert(key, value, m_pMemory); } // free functions