I know how to do this in other languages, but not C++, which I am forced to use here.
I have a Set of Strings that I\'m printing to out in a list, and they need a co
Can use functors:
#include
string getSeparatedValues(function condition, function output, string separator)
{
string out;
out += output();
while (condition())
out += separator + output();
return out;
}
Example:
if (!keywords.empty())
{
auto iter = keywords.begin();
cout << getSeparatedValues([&]() { return ++iter != keywords.end(); }, [&]() { return *iter; }, ", ") << endl;
}