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
to avoid placing an if
inside the loop, I use this:
vector keywords = {1, 2, 3, 4, 5};
if (!keywords.empty())
{
copy(keywords.begin(), std::prev(keywords.end()),
std::ostream_iterator (std::cout,", "));
std::cout << keywords.back();
}
It depends on the vector type, int
, but you can remove it with some helper.