Я искал the mongocxx query exemples, и я не понимаю, как использовать auto&&
над auto&
здесь.mongocxx cursor and rvalue ссылки
auto cursor = db["restaurants"].find({}, opts);
for (auto&& doc : cursor) {
std::cout << bsoncxx::to_json(doc) << std::endl;
}
В documentation, они используют это таким образом:
mongocxx::cursor cursor = collection.find(document{} << finalize);
for(auto doc : cursor) {
std::cout << bsoncxx::to_json(doc) << "\n";
}
Я хочу использовать for(auto& doc : cursor)
Что лучшая практика здесь, и почему?