How can I find the index of the highest value in a vector, defaulting to the greater index if there are two "greatest" indices?
<p>I have been using <code>std::max_element(vec)</code>, but from what I can tell, it returns the smallest index if two "greatest" indices are equal.</p>

<p>Example:</p>

<pre><code>vector&lt;int&gt; v = {1, 2, 3, 4, 5, 3, 3, 2, 5};
</code></pre>

<p><code>std::max_element(v)</code> would reference <code>v[4]</code>, but for the purposes of my project I need it to reference <code>v[8]</code> instead. What would be the best way to do this?</p>