What's the difference between istringstream, ostringstream and stringstream? / Why not use stringstream in every case?

后端 未结 8 1770
春和景丽
春和景丽 2020-12-02 04:48

When would I use std::istringstream, std::ostringstream and std::stringstream and why shouldn\'t I just use std::stringstream

8条回答
  •  情书的邮戳
    2020-12-02 05:08

    istringstream is for input, ostringstream for output. stringstream is input and output. You can use stringstream pretty much everywhere. However, if you give your object to another user, and it uses operator >> whereas you where waiting a write only object, you will not be happy ;-)

    PS: nothing bad about it, just performance issues.

提交回复
热议问题