Many times when creating a grammatical list (with comas), I use similar code to the following:
std::stringstream list;
int i = 0;
for (auto itemListIt = itemList.begin(); itemListIt != itemList.end(); itemListIt++)
{
list << *itemListIt;
if (i < itemList.size() - 1) list << ", ";
i++;
}
Is there some more concise way do this, perhaps without the extra variable - 'i'?