I\'m trying to build a string using data elements stored in a std::list, where I want commas placed only between the elements (ie, if elements are {A,B,C,D} in list, result stri
Another solution is to have the first entry be the special case, instead of the last entry:
std::string Compose(DataItemList& dilList)
{
std::stringstream ssDataSegment;
for(iterItems = dilList.begin();
iterItems != dilList.end();
++iterItems)
{
// See if current element is the first
if(iterItems == dilList.begin())
{
ssDataSegment << (*iterItems)->ToString();
}
else
{
ssDataSegment << "," << (*iterItems)->ToString();
}
}
return ssDataSegment.str();
}