Idiom #53 Join a list of strings
Concatenate elements of string list x joined by the separator ", " to create a single string y.

std::vector<std::string> x;
std::string y;
const char* const delim = ", ";
switch (x.size())
{
case 0: y = ""; break;
case 1: y = x[0]; break;
default:
std::ostringstream os;
std::copy(x.begin(), x.end() - 1,
std::ostream_iterator<std::string>(os, delim));
os << *x.rbegin();
y = os.str();
}