Reputation: 5203
STL optimizes memory allocation for string objects by providing memory for string objects from a memory pool kept by the standard library. Is it possible to disable this optimization?
I am using VS 2008
Upvotes: 1
Views: 561
Reputation: 803
The following question will help you in understanding how the std::basic_string
can be manipulated to be used with various allocators
How do I allocate a std::string on the stack using glibc's string implementation?
Upvotes: 1
Reputation: 17938
No, you can't. From the C++ reference on string::string:
Except for the copy constructor, an optional final parameter exists for all basic_string constructors, whose type is its Allocator template argument. This parameter influences the memory allocation model to be used for the object. To provide a better readability, and because under no known compiler implementation the memory allocation model for strings (allocator) is affected by its value, it has not been included in the declarations above, but see the basic template member declaration ahead for a more complete declaration.
Upvotes: 3