How to use a MongoDB C++ Driver instance.
Initialize the C++ Driver
Basic Usage
With Static Lifetime
- Warning
- This pattern depends on an exit-time destructor with indeterminate order relative to other objects with static lifetime being destroyed.
Errors
Instance Recreation
void example() {
{
try {
EXPECT(false && "should not reach this point");
EXPECT(ex.code() == mongocxx::error_code::k_cannot_recreate_instance);
}
}
}
Destroyed Instance
void example() {
{
}
try {
EXPECT(false && "should not reach this point");
EXPECT(ex.code() == mongocxx::error_code::k_cannot_recreate_instance);
}
try {
EXPECT(false && "should not reach this point");
EXPECT(ex.code() == mongocxx::error_code::k_instance_destroyed);
}
}