|
I'm glad you figured it out. FWIW, since the options.sort type is bsoncxx::document::view_or_value, you should be able to std::move the sort document and then the option will own the value.
But I'll go ahead and close the ticket.
|
|
It is my fault, because I putted this code inside a if statement.
if (xxx)
|
{
|
auto v = document{} << "_id" << -1 << finalize;
|
option.sort(v.view());
|
}
|
coll.find(..., option);
|
So I think the BsonValue is invalid outside the if statement instead of be copied to the find option.
So the code below works for me.
auto v = document{} << "_id" << -1 << finalize;
|
if (xxx)
|
option.sort(v.view());
|
coll.find(..., option);
|
Somebody could close this issue.
|