feat: adds front and back methods to Value type by jwidauer · Pull Request #1458 · open-source-parsers/jsoncpp (original) (raw)

It should actually still be valid if Value is holding an object, since the iterator returned by Value::begin() is also valid for objects.
But, yes, for scalars it is undefined behavior as to what will happen, since you're trying to dereference a default constructed ValueIterator (or ConstValueIterator).
I didn't add an assertion, since it seemed like this is the preferred style, due to the fact that Value::begin() also just returns a default constructed iterator, which, when dereferenced, will fail.