Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/162.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 是std::max_元素a C++;11 x功能?_C++_C++11 - Fatal编程技术网

C++ 是std::max_元素a C++;11 x功能?

C++ 是std::max_元素a C++;11 x功能?,c++,c++11,C++,C++11,您知道std::max_元素是C++11特性还是以前存在过 那个。 我使用的是g++4.8.3,不会抛出警告消息,请求使用-std=c++11 我发布代码是为了帮助人们在机器上编译: #include <iostream> #include <vector> #include <algorithm> #include <vector> class A { public: int x; explicit A(

您知道std::max_元素是C++11特性还是以前存在过 那个。 我使用的是g++4.8.3,不会抛出警告消息,请求使用-std=c++11

我发布代码是为了帮助人们在机器上编译:

#include <iostream>
#include <vector>
#include <algorithm>
#include <vector>

class A
{
    public:
        int x;
        explicit A(int x): x(x) {}
        bool operator<(const A& a) { return x < a.x; }
};

int
main()
{
    std::vector<A> v;
    v.push_back(A(20));
    v.push_back(A(10));
    v.push_back(A(15));
    v.push_back(A(5));

    A result(*(std::max_element(v.begin(), v.end())));
    std::cout << result.x;

    return 0;
}
#包括
#包括
#包括
#包括
甲级
{
公众:
int x;
显式A(intx):x(x){}

bool操作符
std::max_元素
从第一个C++标准开始就存在了。

是什么阻止了您简单地查找它?或者在C++03中尝试它?很抱歉。它确实是用C++03编译的。