How to pass a custom comparator to a custom function C++
<p>so assuming I have a series of custom comparators like so:</p>

<pre><code>template &lt;typename T&gt;
class less_class {
    bool operator() (T obj, T value) const {
        return obj &lt; value;
    }
};

template &lt;typename T&gt;
class greater_than {
    bool operator() (T obj, T value) const {
        return obj &gt; value;
    }
};

template &lt;typename T&gt;
class equal_to {
    bool operator() (T obj, T value) const {
        return obj == value;
    }
};
</code></pre>

<p>and I have a function like this:</p>

<pre><code>template &lt;typename T&gt;
bool compare_values(T obj, T value, T comparator(T obj, T value)) {
    if comparator(obj, value) return true;
    return false;
}
</code></pre>

<p>What syntax should I use in the compare_values function such that it can take in either one of the aforementioned comparators and use it in its implementation? Currently, my comparator argument to the function is written in a similar way as above and Xcode is throwing a fit with errors. I have tried messing with the arguments a bit to see if anything would work but I think I need to better understand what I am trying to do here. Any help would be appreciated!</p>