What is faster? stringstream string + String: Revision history

From OPeNDAP Documentation
⧼opendap2-jumptonavigation⧽

Diff selection: Mark the radio buttons of the revisions to compare and hit enter or the button at the bottom.
Legend: (cur) = difference with latest revision, (prev) = difference with preceding revision, m = minor edit.

16 August 2023

  • curprev 14:5714:57, 16 August 2023Jimg talk contribs 1,446 bytes +1,446 Created page with "That is: I have two string objects:string str_1, str_2. I want to concatenate to them. I can use two methods: method 1: <pre> std::stringstream ss; //std::string str_1("hello"); //std::string str_2("world"); ss << "hello"<< "world"; const std::string dst_str = std::move(ss.str()); </pre> method 2: <pre> std::string str_1("hello"); std::string str_2("world"); const std::string dst_str = str_1 + str_2; </pre> Because the string's buffer is read only, when you chan..."