bsoncxx::document::value filter_document = document{}
<< "_id" << bsoncxx::oid { strJobID }
<< finalize;
auto retVal = collTasks.find_one(
filter_document, mongocxx::options::find {});
结果:
../src/CMongo.cpp:371:73:
error: cannot bind
‘bsoncxx::v_noabi::document::value’ lvalue to
‘bsoncxx::v_noabi::document::value&&’
auto retVal = collTasks.find_one(filter_document, MyFindOptions);
它看起来非常像例子。参数的类型是viwe_or_value ...
答案 0 :(得分:0)
有代表数据的拥有和非拥有类型。
值是拥有类型
查看 非拥有类型
如果拥有类型使其范围{...}的范围大于破坏底层数据缓冲区的范围。从值生成的视图不能破坏数据库。但它取决于它。视图引用值的数据缓冲区。因此,如果视图有效,但值不是,则会导致SIGSEG出现分段错误。因为您正在尝试访问不再存在的数据。
您不希望fint_one()函数破坏生成的ID。这就是为什么这个函数不接受值。 顺便说一句:那些&amp;&amp;是移动运营商。不复制对象,它是剪切和粘贴的。之后来源没有这个。
所以尝试一下,它应该有用;)。
docJobReturned = collTasks.find_one(
filter_document.view(), mongocxx::options::find {})
;