c++ std::ostringstream vs std::string::append

前端 未结 4 1330
难免孤独
难免孤独 2020-12-13 06:16

In all examples that use some kind of buffering I see they use stream instead of string. How is std::ostringstream and << operator different than using string.append.

4条回答
  •  甜味超标
    2020-12-13 06:45

    If you concern about speed you should profile and/or test. In theory std::string::append should be not slower as it is simpler (stream has to deal with locale, different formatting and be more generic). But how faster one solution or another really is you can realize only by testing.

提交回复
热议问题