Return fallback if .as(fallback) called on a node that doesn't exist

Since 1025f76df1 it seems that missing
nodes point to a 'zombie' node, where the m_isValid member is false.
This caused .as(const S& fallback) throw an exception if the node was
missing, instead of returning the provided fallback value (as was the
behaviour previous to the above commit)
This commit is contained in:
Jonathan Hamilton 2015-05-28 20:10:25 -07:00
parent b43db54810
commit 0526d7c299

View File

@ -149,7 +149,7 @@ inline const T Node::as() const {
template <typename T, typename S>
inline const T Node::as(const S& fallback) const {
if (!m_isValid)
throw InvalidNode();
return fallback;
return as_if<T, S>(*this)(fallback);
}