When we have to work with string manipulation, is there any significants performance difference between std::string and std::stringbuf, and if yes why.
More generally when it is good to use std::stringbuf over std::string ?
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.
A
std::stringbufuses a string internally to buffer data, so it is probably a bit slower. I don’t think the difference would be significant though, because it basically just delegation. To be sure you’d have to run some performance-tests though.std::stringbufis useful when you want an IO-stream to use a string as buffer (likestd::stringstream, which uses astd::stringbufby default).