mercredi 6 mai 2015

How to used const auto in C++ 11

I have a code in C++14. However, when I used it in C++ 11, it has error at const auto.How to use it in C++11. Thanks

vector<vector <int> > P;  
std::vector<double> f;
vector< pair<double, vector<int> > > X; 
for (int i=0;i<N;i++)
        X.push_back(make_pair(f[i],P[i]));

////Sorting fitness descending order
stable_sort(X.rbegin(), X.rend());
std::stable_sort(X.rbegin(), X.rend(),
                [](const auto&lhs, const auto& rhs) { return lhs.first < rhs.first; });

Aucun commentaire:

Enregistrer un commentaire