bsoncxx::builder::stream::single_context is written to accept a single value to be appended to the stream, but it is currently possible to append multiple values through use of open_document and open_array:
The above code currently compiles, and throws an exception with a confusing message "expected a key but found none" at runtime. Instead, this code should not compile.
The code erroneously compiles due to the fact that the following functions have the wrong return type. The return type of these functions are currently key_context<single_context> and array_context<single_context>, respectively, but they should be key_context<closed_context> and array_context<closed_context> instead.