Overload on dynamic object reference type.
Summary: There are a bunch of methods in `folly::dynamic` that return a
reference to a sub-object, e.g. `getString()`.
These methods are a bit unsafe because it allows you to write code with dangling
references when the `folly::dynamic` object is an rvalue:
auto& obj = parse_json(some_string).at("key");
However, the bigger win is that when we have an rvalue `folly::dynamic`, such as
returned by `getDefault(...)`, we can move the sub-object out:
auto obj = parse_json(some_string).at("key");
auto str = obj.getDefault("another-key", "").getString();
In the first line, the subobject is copied out when it could be safely moved out.
In the second line `getDefault(...)` copies the dynamic sub-object out, and then
`getString()` copies the string out, when the string could be moved.
Also in the case of `getDefault()` being called on a rvalue, we can move the
sub-object out.
Reviewed By: @marcinpe
Differential Revision:
D2267588