title: max over c++ array with function call
body: <p>I have a list of <code>obj</code> objects which each have an <code>eval()</code> method, returning a <code>double</code>. I'd like to get the maximum value of all of these. So far, I've always done</p>
  <pre class="lang-cpp prettyprint-override"><code>double maxval = std::numeric_limits&lt;double&gt;::lowest();
  for (const auto &amp;obj: objs) {
    maxval = std::max(maxval, obj-&gt;eval());
  }
  </code></pre>
  <p>I was wondering if there's a more elegant solution where you don't have to set the initial value -inf, something like Python's</p>
  <pre class="lang-py prettyprint-override"><code>max_value = max(obj.eval() for obj in objs)
  </code></pre>
  <p>perhaps. Note than <code>eval()</code> may be expensive, so I only want to <code>eval()</code> once per <code>obj</code>.</p>
  <p>Any hints? Bonus points for readability.</p>