I have a std::set<std::string>
and I need to know the total number of characters (sum of all strings length):
static size_t SumLength(size_t value, const std::string &str)
{
return str.length() + value;
}
size_t TotalLength(std::set<std::string> &stringSet)
{
return std::accumulate(stringSet.begin(), stringSet.end(), 0, SumLength);
}
What do you think of this approach?