私はmongocxx クエリの例auto&&
を探していましたが、ここで使用する意味がわかりませんauto&
。
auto cursor = db["restaurants"].find({}, opts);
for (auto&& doc : cursor) {
std::cout << bsoncxx::to_json(doc) << std::endl;
}
ドキュメントでは、次のように使用しています。
mongocxx::cursor cursor = collection.find(document{} << finalize);
for(auto doc : cursor) {
std::cout << bsoncxx::to_json(doc) << "\n";
}
使いたいfor(auto& doc : cursor)
ここでのベスト プラクティスは何ですか? またその理由は何ですか?