I am trying to a template class driven with a template parameter of std::less
, std::greater
or. This is a follow up to this question since, the answer doesn't provide a full example and I am unable to successfully use the template comparator.
#include <functional>
#include <algorithm>
template <typename C>
class Test
{
int compare(int l, int n, int x, int y)
{
public:
bool z = C(x, y);
if(l < n && z)
{
return 1;
}
else
{
return 2;
}
}
};
int main() {
Test<std::less<int>> foo;
Test<std::greater<int>> bar;
foo.compare(1, 2, 3, 4);
bar.compare(1, 2, 3, 4);
}