To understand the better about what is best among std::string
or std::stringstream
while is string manipulation involved. The below code can be replaced with std::string
and it's append().
Let's consider the below function.
std::string function(const std::vector<std::string>& param1, const std::string& param2)
{
std::stringstream streamTemp;
if (!param1.empty())
{
for (const auto& item : param1)
{
if (streamTemp.tellp() > 0)
{
streamTemp<<" || ";
}
streamTemp << param2 << " (" << item << ") ";
}
streamTemp<<" (" streamTemp + ") ";
}
return streamTemp.str();
}