I’m trying to add in an optional parameter in a template function… Basically a parameter that overloads the relational operator depending on the user’s type. It’s my first template funct so I’m pretty basic. This should sort through a vector of the user’s type and return the greatest element. Something like:
template <typename Type>
Type FindMax(std::vector<Type> vec, RelationalOverloadHere)
/..../
What would the second “optional” parameter look like?
Usually this is like
So the standard comparator is
<, but can be customized if desired.In the standard library, the respective algorithm is
max_elementwith the following overload: