template <typename T> inline T Node::as() const;
template <typename T> bool convert<T>::decode(const YAML::Node&, T&);
decode() needs a reference for an already constructed object's reference that it can mutate to decode the Node's contents into it. as() returns a brand new T object, it works by default constructing a T object then calling decode() on it. It is problematic if:
- T is not default constructible.
- It is impossible or expensive to mutate T.
I suggest to use the same signature as Node::as(). In case of an error a client can just throw an exception, preferebly TypedBadConversion. It could have the added benefit of marking the error's location more precisely if it happens at a nested subnode.
decode() needs a reference for an already constructed object's reference that it can mutate to decode the Node's contents into it. as() returns a brand new T object, it works by default constructing a T object then calling decode() on it. It is problematic if:
I suggest to use the same signature as Node::as(). In case of an error a client can just throw an exception, preferebly TypedBadConversion. It could have the added benefit of marking the error's location more precisely if it happens at a nested subnode.