c++ - Is std::max_element a C++11 x feature? -
do know if std::max_element c++11 feature or has existed before that. using g++ 4.8.3 , not throw warning messages requesting use -std=c++11
i posting code may people compile on machines:
#include <iostream> #include <vector> #include <algorithm> #include <vector> class { 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)); result(*(std::max_element(v.begin(), v.end()))); std::cout << result.x; return 0; }
std::max_element
has existed since first c++ standard.
Comments
Post a Comment