I am writing a simple function that iterates over the numbers in a container and computes some summarizing value (the entropy in this case).

I want to write it as generic as possible, so that it works with different containers (`vector`, `set`, ...) over different value types (`double`, `float`, ...), so I'm doing this:

```
template<class Iterator>
typename Iterator::value_type Entropy(Iterator begin, Iterator end) {
  typedef typename Iterator::value_type Value;
  Value result = Value(); // assignment needed?
  for (Iterator it = begin; it != end; ++it) {
    result -= *it * log(*it);
  }
  return result;
}

```

I'm interested in what this code would look like according to all best practices. In other words, what exactly would an STL implementation of this little function look like?