std::min_element
takes a range. front
and back
return references to actual values. You should be using the begin
and end
methods to return an iterator to the corresponding positions in the vector:
min_element(choices.begin(), choices.end());
// ^^^^^ ^^^
If you find this tedious, you can create a function which wraps around the standard min_element
:
template <class Container>
auto min_element(Container c) -> decltype(std::min_element(c.begin(), c.end()))
{
return std::min_element(c.begin(), c.end());
}
And use it as:
min_element(choices);