Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ex13.42 #830

Open
Cyitao opened this issue Jul 22, 2023 · 1 comment
Open

Ex13.42 #830

Cyitao opened this issue Jul 22, 2023 · 1 comment

Comments

@Cyitao
Copy link

Cyitao commented Jul 22, 2023

std::allocatorstd::string alloc should be defined as static variable;

@amritpalsingh52
Copy link

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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants