Open Cyitao opened 1 year ago
The std::allocator is used as a temporary object in this example to allocate memory for a single std::string object. It is instantiated within the main function and goes out of scope when the function returns.
If you want to use the std::allocator in a global context and keep it alive throughout the program's lifetime, you can define it as a static variable inside a class or a global variable:
std::allocator alloc should be defined as static variable;