更大的算子不起作用

ric*_*d.g 2 c++ generics templates stl functor

这是代码.

#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
    int a = 1;
    int b=2;
    if(greater<int>(a,b))
        cout<<"YES";
    else
        cout<<"NO";
}
Run Code Online (Sandbox Code Playgroud)

当我编译它时,错误消息是:错误C2661:"std :: greater <_Ty> :: greater":没有带有两个参数的重载函数.这很令人困惑,它应该采取两个参数,对吧?

我使用更多的排序算法,它工作得很好.但我不知道上述程序中的错误信息是如何产生的.

T-D*_*T-D 5

它将以这种方式工作:

int a = 1;
int b=2;
greater<int> g;
if(g(a,b))
cout<<"YES";
else
cout<<"NO";
Run Code Online (Sandbox Code Playgroud)