mongocxx::cursor cursor = coll.find({});for (auto doc : cursor) { std::cout << bsoncxx::to_json(doc) << "\n"; }
Exception thrown at 0x000000007739EEF1 (ntdll.dll) in test.exe: 0xC0000005: Access violation reading location
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <bsoncxx\builder\stream\document.hpp>
#include <bsoncxx\builder\basic\document.hpp>
#include <bsoncxx\json.hpp>
#include <mongocxx\client.hpp>
#include <mongocxx\instance.hpp>
#include <bsoncxx\document\value.hpp>
#include <bsoncxx\document\view.hpp>
#include <cstdint>
#include <mongocxx/stdx.hpp>
#include <mongocxx/uri.hpp>
#include <bson.h>
using bsoncxx::builder::stream::close_array;
using bsoncxx::builder::stream::close_document;
using bsoncxx::builder::stream::document;
using bsoncxx::builder::stream::finalize;
using bsoncxx::builder::stream::open_array;
using bsoncxx::builder::stream::open_document;
using namespace std;
int main() {
mongocxx::instance inst{};
mongocxx::client client{ mongocxx::uri{ "mongodb://ip:27017" } };
mongocxx::database db = client["client"];
mongocxx::collection coll = db["collection"];
mongocxx::cursor cursor = coll.find({});
for (auto doc : cursor) {
std::cout << bsoncxx::to_json(doc) << "\n";
}
return 1;
}