To use the C++ driver, you must first create an instance of the mongocxx::instance
class. This instance performs the following functions in your application:
Initializes and shuts down the C++ driver
Initializes driver dependencies
Ensures the driver functions correctly
Manages the lifetimes of resources that are shared among mongocxx::client
objects, such as the connection pool and BSON library
This guide shows you how to create a mongocxx::instance
object.
To create a mongocxx::instance
object, include the mongocxx/instance.hpp
header file in your application. Then, construct an instance of mongocxx::instance
at the start of your application, as shown in the following example:
#include <mongocxx/instance.hpp>int main(){ mongocxx::instance instance;}
Important
You must create a mongocxx::instance
object before you use the C++ driver, and this object must remain alive for as long as any other MongoDB objects are in scope.
To learn more about the mongocxx::instance
class in the C++ driver, see the following API documentation:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4