mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 04:41:16 +00:00
Remove 'const' modifier on return of Node::as.
This enables the return value to be moved, rather than copied.
This commit is contained in:
@@ -87,7 +87,7 @@ struct as_if {
|
|||||||
explicit as_if(const Node& node_) : node(node_) {}
|
explicit as_if(const Node& node_) : node(node_) {}
|
||||||
const Node& node;
|
const Node& node;
|
||||||
|
|
||||||
const T operator()(const S& fallback) const {
|
T operator()(const S& fallback) const {
|
||||||
if (!node.m_pNode)
|
if (!node.m_pNode)
|
||||||
return fallback;
|
return fallback;
|
||||||
|
|
||||||
@@ -140,14 +140,14 @@ struct as_if<std::string, void> {
|
|||||||
|
|
||||||
// access functions
|
// access functions
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline const T Node::as() const {
|
inline T Node::as() const {
|
||||||
if (!m_isValid)
|
if (!m_isValid)
|
||||||
throw InvalidNode();
|
throw InvalidNode();
|
||||||
return as_if<T, void>(*this)();
|
return as_if<T, void>(*this)();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename S>
|
template <typename T, typename S>
|
||||||
inline const T Node::as(const S& fallback) const {
|
inline T Node::as(const S& fallback) const {
|
||||||
if (!m_isValid)
|
if (!m_isValid)
|
||||||
return fallback;
|
return fallback;
|
||||||
return as_if<T, S>(*this)(fallback);
|
return as_if<T, S>(*this)(fallback);
|
||||||
|
@@ -63,9 +63,9 @@ class YAML_CPP_API Node {
|
|||||||
|
|
||||||
// access
|
// access
|
||||||
template <typename T>
|
template <typename T>
|
||||||
const T as() const;
|
T as() const;
|
||||||
template <typename T, typename S>
|
template <typename T, typename S>
|
||||||
const T as(const S& fallback) const;
|
T as(const S& fallback) const;
|
||||||
const std::string& Scalar() const;
|
const std::string& Scalar() const;
|
||||||
|
|
||||||
const std::string& Tag() const;
|
const std::string& Tag() const;
|
||||||
|
Reference in New Issue
Block a user