Given the following code:
int i;
...
ostingstream os;
os<<i;
string s=os.str();
I want to count the number of times of dynamic memory allocation when using ostringstream this way. How can I do that? Maybe through operator new?
Thank you.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, and here is how you could do it:
In my environment (Ubuntu 10.4.3, g++), the answer is “2”.
EDIT: Quoting MSDN
So every new-expression will invoke the global
operator new, unless there is a classoperator new. For the classes you listed, I believe that there is no class-leveloperator new.