Remove 'const' modifier on return of Node::as.
This enables the return value to be moved, rather than copied.
This commit is contained in:
parent
320b02b14a
commit
97d56c3f36
@ -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;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user